Repository navigation
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
/cc @LiZhenCheng9527 @LiZhenCheng9527 This PR is ready for review, thank you! |
Previously, ControlMonitoring attempted to initialize the Kubernetes
client via utils.CreateKubeClient() before checking whether any flags
were supplied and before validating their values. When executed in an
offline environment or without kubeconfig, commands without arguments or
with invalid flags failed with a generic client initialization error
instead of reporting the missing or invalid flags.
Furthermore, invalid flag values (values other than "enable" or
"disable") were only caught downstream inside the per-pod loop after
starting port-forwarding to each daemon.
Fix this by:
1. Validating that at least one monitoring flag is provided before
initializing the Kubernetes client.
2. Validating flag values ("enable" or "disable") up front.
3. Supporting client injection via setKubeClient for unit testing.
4. Adding unit test coverage in ctl/monitoring/monitoring_test.go for
missing parameters and invalid flag values.
Signed-off-by: Norway-02 <anshulkhetade02@gmail.com>
7fb5e12 to
579df22
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Continue to review full report in Codecov by Harness.
🚀 New features to boost your workflow:
|
What type of PR is this?
/kind bug
What this PR does / why we need it:
Previously,
ControlMonitoringattempted to initialize the Kubernetes client viautils.CreateKubeClient()before checking whether any monitoring flags were supplied and before validating their values.When executed without valid flags (or in offline/local environments without kubeconfig), running
kmeshctl monitoringfailed with a generic client initialization error instead of clearly notifying the user about missing flags (no parameters. Need --accesslog, --workloadMetrics, --connectionMetrics or --all).Furthermore, invalid flag values (values other than
"enable"or"disable") were previously only caught downstream inside the per-pod loop after starting port-forwarding to each daemon.This PR fixes this by:
"enable"or"disable") up front before making cluster connections.setKubeClientfor testability.ctl/monitoring/monitoring_test.gocovering parameter validation, invalid values, and error returns.Which issue(s) this PR fixes:
None
Special notes for your reviewer:
All unit tests in
ctl/monitoringpass cleanly andmake copyright-checkpasses.Does this PR introduce a user-facing change?: