Skip to content

Conversation

@AdamSadek
Copy link
Contributor

Extended all log-level commands (set, show, unset) to support managed clusters as requested in issue #41. Added optional parameters --namespace, --clusterName, and --clusterType to enable log level management in both ClusterAPI and SveltosCluster managed clusters using clusterproxy.GetKubernetesClient. Maintains full backward compatibility with existing management cluster functionality.

I first created the test cluster and then ran the actual deployment.

Examples of testing

Some new unit tests passsing:

$ go test ./internal/commands/loglevel/... -v
=== RUN   TestCollectLogLevelConfigurationFromClient_Empty
--- PASS: TestCollectLogLevelConfigurationFromClient_Empty (0.00s)
=== RUN   TestCollectLogLevelConfigurationFromClient_Existing  
--- PASS: TestCollectLogLevelConfigurationFromClient_Existing (0.00s)
=== RUN   TestUpdateLogLevelConfigurationWithClient_Create
--- PASS: TestUpdateLogLevelConfigurationWithClient_Create (0.00s)
=== RUN   TestUpdateLogLevelConfigurationWithClient_Update
--- PASS: TestUpdateLogLevelConfigurationWithClient_Update (0.00s)
=== RUN   TestShowLogSettingsInManaged
--- PASS: TestShowLogSettingsInManaged (0.00s)
=== RUN   TestUnsetDebuggingConfigurationInManaged
--- PASS: TestUnsetDebuggingConfigurationInManaged (0.00s)
PASS
ok      github.com/projectsveltos/sveltosctl/internal/commands/loglevel    0.123s

Management Cluster Tests (Backward Compatibility):

$ ./sveltosctl log-level show
+-----------+-----------+
| COMPONENT | VERBOSITY |
+-----------+-----------+
+-----------+-----------+

$ ./sveltosctl log-level set --component=SveltosAgent --debug

$ ./sveltosctl log-level show
+--------------+---------------+
|  COMPONENT   |   VERBOSITY   |
+--------------+---------------+
| SveltosAgent | LogLevelDebug |
+--------------+---------------+

$ ./sveltosctl log-level unset --component=SveltosAgent

$ ./sveltosctl log-level show
+-----------+-----------+
| COMPONENT | VERBOSITY |
+-----------+-----------+
+-----------+-----------+

Managed cluster tests

$ kubectl apply -f test-simple-adam.yaml
sveltoscluster.lib.projectsveltos.io/test-cluster created

$ kubectl get sveltosclusters -A
NAMESPACE      NAME           READY   VERSION
mgmt           mgmt           true    v1.29.1
test-cluster   test-cluster

$ ./sveltosctl log-level set --component=SveltosAgent --info \
  --namespace=test-cluster --clusterName=test-cluster --clusterType=Sveltos
# Command accepts parameters and attempts cluster connection (expected behavior)
# There are no "unknown flag" errors

For managed clusters

# SveltosCluster
./sveltosctl log-level set --component=SveltosAgent --info \
  --namespace=test-cluster --clusterName=test-cluster --clusterType=Sveltos

# ClusterAPI cluster  
./sveltosctl log-level show \
  --namespace=default --clusterName=workload-cluster --clusterType=Capi

AdamSadek added 2 commits May 31, 2025 00:35
…og-level set command to support managed clusters as requested in issue projectsveltos#41. Added support for --namespace, --clusterName, and --clusterType parameters using clusterproxy.GetKubernetesClient. Includes comprehensive unit tests and maintains backward compatibility.
…naged cluster support to log-level show and unset commands to complete the implementation of GitHub issue projectsveltos#41. Both commands now support --namespace, --clusterName, and --clusterType parameters with comprehensive unit tests and maintain backward compatibility.
@AdamSadek AdamSadek changed the base branch from main to dev May 31, 2025 00:44
@AdamSadek AdamSadek force-pushed the feature/extend-log-command-managed-clusters-v2 branch from 0ea007d to da08016 Compare May 31, 2025 00:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant