kloudlite / kl

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

deployments checks handled #170

Closed nxtcoder36 closed 2 weeks ago

nxtcoder36 commented 2 weeks ago

Summary by Sourcery

Enhance the status command to include checks for K3s deployment readiness and improve logging and error handling in the container script execution process. Update constants for clarity and improve user feedback with updated spinner messages.

Enhancements:

Chores:

sourcery-ai[bot] commented 2 weeks ago

Reviewer's Guide by Sourcery

This pull request implements deployment checks for the Kloudlite system. It adds functionality to check the status of various deployments, improves error handling, and enhances the overall robustness of the system. The changes primarily focus on the status command, K3s cluster setup, and logging improvements.

Sequence diagram for deployment status checks

sequenceDiagram
    participant User
    participant Cmd as Command
    participant K3s as K3s Server
    participant KL as Kloudlite Gateway
    participant Agent as Kloudlite Agent
    participant Operator as Kloudlite Agent Operator

    User->>Cmd: Run status command
    Cmd->>K3s: GET /apis/apps/v1/namespaces/kl-gateway/deployments/default
    K3s-->>Cmd: Deployment status
    Cmd->>KL: Check if Available
    KL-->>Cmd: Status (Ready/Not Ready)
    Cmd->>K3s: GET /apis/apps/v1/namespaces/kloudlite/deployments/kl-agent
    K3s-->>Cmd: Deployment status
    Cmd->>Agent: Check if Available
    Agent-->>Cmd: Status (Ready/Not Ready)
    Cmd->>K3s: GET /apis/apps/v1/namespaces/kloudlite/deployments/kl-agent-operator
    K3s-->>Cmd: Deployment status
    Cmd->>Operator: Check if Available
    Operator-->>Cmd: Status (Ready/Not Ready)
    Cmd-->>User: Display status results

File-Level Changes

Change Details Files
Implemented deployment status checks
  • Added a new function getK3sStatus() to check the status of kloudlite gateway, agent, and agent operator deployments
  • Integrated the new status check function into the main command execution flow
  • Implemented JSON parsing of the Kubernetes API responses to determine deployment readiness
cmd/status/status.go
Improved K3s cluster setup and management
  • Refactored the CreateClustersAccounts function to use spinner for progress indication
  • Enhanced error handling and logging during cluster setup
  • Modified the runScriptInContainer function to provide better feedback during execution
  • Updated the EnsureK3sServerIsReady function to use a more efficient checking mechanism
pkg/k3s/impl.go
Enhanced logging and debugging capabilities
  • Added a new Debug function for conditional logging based on verbose mode
  • Modified the Log function to improve formatting and readability
  • Updated various parts of the code to use the new logging functions
pkg/functions/print.go
cmd/box/boxpkg/utils.go
Renamed HostIp constant to K3sServerIp
  • Changed the constant name from HostIp to K3sServerIp for better clarity
  • Updated references to this constant throughout the codebase
constants/main.go
pkg/k3s/impl.go
cmd/box/boxpkg/utils.go

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. #### 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).