-
Notifications
You must be signed in to change notification settings - Fork 27
feat(cli): Added Slice Health Status Functionality #96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
AyushSriv06
wants to merge
1
commit into
kubeslice:master
Choose a base branch
from
AyushSriv06:slice-health
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| package cmd | ||
|
|
||
| import ( | ||
| "github.com/kubeslice/kubeslice-cli/pkg" | ||
| "github.com/kubeslice/kubeslice-cli/util" | ||
| "github.com/spf13/cobra" | ||
| ) | ||
|
|
||
| var showHealthCmd = &cobra.Command{ | ||
| Use: "show-health", | ||
| Aliases: []string{"health"}, | ||
| Short: "Show health status of KubeSlice resources.", | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "Show health status of Slice Resources"
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. okay |
||
| Args: cobra.RangeArgs(1, 2), | ||
| Run: func(cmd *cobra.Command, args []string) { | ||
| var objectName string | ||
| ns, _ := cmd.Flags().GetString("namespace") | ||
| if ns == "" { | ||
| util.Fatalf("Namespace is required") | ||
| } | ||
| all, _ := cmd.Flags().GetBool("all") | ||
|
|
||
| if len(args) > 1 { | ||
| objectName = args[1] | ||
| } | ||
|
|
||
| pkg.SetCliOptions(pkg.CliParams{Config: Config, Namespace: ns, ObjectName: objectName, ObjectType: args[0], OutputFormat: outputFormat}) | ||
| switch args[0] { | ||
| case "slice": | ||
| if all { | ||
| pkg.ShowAllSliceHealth() | ||
| } else { | ||
| if objectName == "" { | ||
| util.Fatalf("Slice name is required when not using --all flag") | ||
| } | ||
| pkg.ShowSliceHealth() | ||
| } | ||
| default: | ||
| util.Fatalf("Invalid object type. Supported types: slice") | ||
| } | ||
| }, | ||
| } | ||
|
|
||
| func init() { | ||
| rootCmd.AddCommand(showHealthCmd) | ||
| showHealthCmd.Flags().StringP("namespace", "n", "", "namespace") | ||
| showHealthCmd.Flags().BoolP("all", "A", false, "show health for all slices") | ||
| showHealthCmd.Flags().StringVarP(&outputFormat, "output", "o", "", "supported values json, yaml") | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| # kubeslice-cli show-health | ||
|
|
||
| Show health status of KubeSlice resources. | ||
|
|
||
| ## Synopsis | ||
|
|
||
| The `show-health` command allows you to view the health status of KubeSlice slices. It provides detailed information about the health and status of slice configurations. | ||
|
|
||
| ```bash | ||
| kubeslice-cli show-health [resource-type] [resource-name] [flags] | ||
| ``` | ||
|
|
||
| ## Examples | ||
|
|
||
| ### Show health for a specific slice | ||
| ```bash | ||
| kubeslice-cli show-health slice my-slice -n kubeslice-demo | ||
| ``` | ||
|
|
||
| ### Show health for all slices | ||
| ```bash | ||
| kubeslice-cli show-health slice -A -n kubeslice-demo | ||
| ``` | ||
|
|
||
| ### Show health with JSON output | ||
| ```bash | ||
| kubeslice-cli show-health slice my-slice -n kubeslice-demo -o json | ||
| ``` | ||
|
|
||
| ### Show health with YAML output | ||
| ```bash | ||
| kubeslice-cli show-health slice my-slice -n kubeslice-demo -o yaml | ||
| ``` | ||
|
|
||
| ## Available Resource Types | ||
|
|
||
| - `slice` - Show health status of KubeSlice slice configurations | ||
|
|
||
| ## Flags | ||
|
|
||
| - `-A, --all` - Show health for all slices (when used with slice resource type) | ||
| - `-n, --namespace string` - Namespace where the slice is located (required) | ||
| - `-o, --output string` - Output format (json, yaml) | ||
|
|
||
| ## Global Flags | ||
|
|
||
| - `-c, --config string` - Path to topology configuration YAML file | ||
|
|
||
| ## Health Status Information | ||
|
|
||
| The command displays the following health information: | ||
|
|
||
| - **Status**: Ready/Not Ready/Unknown | ||
| - **Conditions**: Available health conditions | ||
| - **Slice Subnet**: Configuration status | ||
| - **Clusters**: Connection status | ||
| - **Raw Output**: Complete JSON/YAML output from kubectl | ||
|
|
||
| ## Usage Notes | ||
|
|
||
| 1. The `--namespace` flag is required for all show-health operations | ||
| 2. When using `--all` flag, you don't need to specify a resource name | ||
| 3. The command uses kubectl to fetch slice configuration data | ||
| 4. Health status is determined by parsing the slice configuration status | ||
| 5. Raw output is always displayed for debugging purposes | ||
|
|
||
| ## Error Handling | ||
|
|
||
| - If the slice doesn't exist, an error will be displayed | ||
| - If the namespace doesn't exist, an error will be displayed | ||
| - If kubectl is not available, an error will be displayed | ||
| - Network connectivity issues will be reported | ||
|
|
||
| ## Related Commands | ||
|
|
||
| - `kubeslice-cli get slice` - Get slice configuration details | ||
| - `kubeslice-cli describe slice` - Describe slice configuration | ||
| - `kubeslice-cli create slice` - Create a new slice | ||
| - `kubeslice-cli delete slice` - Delete a slice |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is another PR open for cluster health status, can you make this more specific with something like "show-slice-health" ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay, i will do that!