kloudlite / kl

Kloudlite CLI Client
GNU Affero General Public License v3.0
5 stars 1 forks source link

Feat/deployment tracker #171

Closed nxtcoder36 closed 2 weeks ago

nxtcoder36 commented 2 weeks ago

Summary by Sourcery

Introduce a deployment tracker to monitor k3s server readiness, enhance status and connection commands to utilize the tracker, and add a build process for the k3s-tracker tool.

New Features:

Enhancements:

Build:

sourcery-ai[bot] commented 2 weeks ago

Reviewer's Guide by Sourcery

This pull request implements a deployment tracker for the Kloudlite system. It introduces a new K3s tracker component that monitors the status of various deployments and services, and updates a status file. The changes also include modifications to existing commands and utilities to work with this new tracking system.

Sequence diagram for K3s Tracker Status Update

sequenceDiagram
    participant Main
    participant KubeClient
    participant File

    Main->>KubeClient: connectConfig()
    KubeClient-->>Main: rest.Config
    Main->>KubeClient: kubeClient()
    KubeClient-->>Main: kubernetes.Clientset
    loop every second
        Main->>KubeClient: checkDeploymentReady()
        KubeClient-->>Main: bool
        Main->>KubeClient: grabServiceIP()
        KubeClient-->>Main: string
        Main->>File: Write status to file
    end

Class diagram for K3s Tracker Integration

classDiagram
    class k3sTracker {
        bool Compute
        bool Gateway
        string DeviceRouterIP
        string LastCheckedAt
    }

    class fileclient {
        +GetK3sTracker() k3sTracker
    }

    class apiClient {
        +InterceptApp(app, status, ports, envName, options)
    }

    fileclient --> k3sTracker
    apiClient --> fileclient

    class main {
        +connectConfig() rest.Config
        +kubeClient() kubernetes.Clientset
        +checkDeploymentReady(ctx, k, namespace, name) bool
        +grabServiceIP(ctx, k, namespace, name) string
    }

    main --> k3sTracker

File-Level Changes

Change Details Files
Implement K3s tracker for deployment status monitoring
  • Add new k3s-tracker package with main.go, go.mod, and Runfile.yml
  • Implement periodic checking of deployment and service statuses
  • Create and update a JSON status file with deployment information
pkg/k3s/k3s-tracker/main.go
pkg/k3s/k3s-tracker/go.mod
pkg/k3s/k3s-tracker/Runfile.yml
Update status command to use K3s tracker information
  • Modify getK3sStatus function to read from K3s tracker status file
  • Add checks for compute and gateway readiness
  • Implement workspace status checking with ping
cmd/status/status.go
Refactor connect command and improve error handling
  • Add check for envclient.InsideBox() before performing certain operations
  • Improve error messages for K3s container not found scenarios
cmd/connect/connect.go
cmd/box/boxpkg/utils.go
Update intercept functionality to use K3s tracker information
  • Add K3s tracker status check before intercepting
  • Use DeviceRouterIP from K3s tracker for interception
domain/apiclient/app.go
Enhance file client with K3s tracker support
  • Add GetK3sTracker method to FileClient interface
  • Implement k3sTracker struct and related functions
domain/fileclient/context.go
domain/fileclient/main.go
Update dependencies and configurations
  • Add go-ping/ping dependency
  • Update go.mod file with new dependencies
go.mod

Tips and commands #### Interacting with Sourcery - **Trigger a new review:** Comment `@sourcery-ai review` on the pull request. - **Continue discussions:** Reply directly to Sourcery's review comments. - **Generate a GitHub issue from a review comment:** Ask Sourcery to create an issue from a review comment by replying to it. - **Generate a pull request title:** Write `@sourcery-ai` anywhere in the pull request title to generate a title at any time. - **Generate a pull request summary:** Write `@sourcery-ai summary` anywhere in the pull request body to generate a PR summary at any time. You can also use this command to specify where the summary should be inserted. #### Customizing Your Experience Access your [dashboard](https://app.sourcery.ai) to: - Enable or disable review features such as the Sourcery-generated pull request summary, the reviewer's guide, and others. - Change the review language. - Add, remove or edit custom review instructions. - Adjust other review settings. #### Getting Help - [Contact our support team](mailto:support@sourcery.ai) for questions or feedback. - Visit our [documentation](https://docs.sourcery.ai) for detailed guides and information. - Keep in touch with the Sourcery team by following us on [X/Twitter](https://x.com/SourceryAI), [LinkedIn](https://www.linkedin.com/company/sourcery-ai/) or [GitHub](https://github.com/sourcery-ai).