-
Notifications
You must be signed in to change notification settings - Fork 7
🐛 upsert fcc-agent namespace independently of join #73
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
🐛 upsert fcc-agent namespace independently of join #73
Conversation
Signed-off-by: Artur Shad Nik <arturshadnik@gmail.com>
WalkthroughAdds Helm template mutual-exclusion checks and safe defaults for kubeconfig blocks, removes several Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
💤 Files with no reviewable changes (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
fleetconfig-controller/charts/fleetconfig-controller/templates/fleetconfig.yaml(3 hunks)fleetconfig-controller/charts/fleetconfig-controller/values.yaml(1 hunks)fleetconfig-controller/internal/controller/v1beta1/spoke_handler.go(3 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-09-22T18:42:03.404Z
Learnt from: arturshadnik
PR: open-cluster-management-io/lab#59
File: fleetconfig-controller/PROJECT:28-31
Timestamp: 2025-09-22T18:42:03.404Z
Learning: In the open-cluster-management-io/lab repository's fleetconfig-controller, the PROJECT file defines multiple API resources with different webhook configurations: FleetConfig v1alpha1 has defaulting: true (requiring MutatingWebhookConfiguration), while Hub and Spoke v1beta1 resources have defaulting: false. MutatingWebhookConfiguration resources in the manifests serve the v1alpha1 FleetConfig, not the v1beta1 Hub/Spoke resources.
Applied to files:
fleetconfig-controller/charts/fleetconfig-controller/templates/fleetconfig.yaml
🧬 Code graph analysis (1)
fleetconfig-controller/internal/controller/v1beta1/spoke_handler.go (3)
fleetconfig-controller/internal/controller/v1beta1/spoke_controller.go (1)
SpokeReconciler(52-58)fleetconfig-controller/api/v1beta1/constants.go (2)
InstanceTypeUnified(89-89)PivotComplete(31-31)fleetconfig-controller/internal/kube/kube.go (1)
KubeconfigFromSecretOrCluster(113-119)
🪛 GitHub Check: test (fleetconfig-controller) / Run Helm Chart Tests
fleetconfig-controller/charts/fleetconfig-controller/values.yaml
[failure] 222-222:
222:22 [trailing-spaces] trailing spaces
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
- GitHub Check: e2e (fleetconfig-controller) / e2e
- GitHub Check: test (fleetconfig-controller) / Ensure PR is reviewable & run tests
- GitHub Check: e2e (fleetconfig-controller) / e2e
- GitHub Check: test (fleetconfig-controller) / Ensure PR is reviewable & run tests
🔇 Additional comments (7)
fleetconfig-controller/charts/fleetconfig-controller/templates/fleetconfig.yaml (3)
43-52: LGTM! Mutual exclusivity check correctly prevents configuration errors.The template correctly validates that
inClusterandsecretReferenceare mutually exclusive for hub kubeconfig, and applies safe defaults (empty string for context, false for inCluster). This prevents runtime configuration conflicts.Based on learnings: The v1beta1 Hub/Spoke resources don't have defaulting webhooks, so these template-level checks and defaults are the correct approach.
87-97: LGTM! Spoke kubeconfig validation mirrors hub implementation.The mutual exclusivity check and defaults for spoke kubeconfig follow the same pattern as the hub kubeconfig, ensuring consistent behavior across both resource types.
116-127: LGTM! ManagedClusterKubeconfig validation follows established pattern.The mutual exclusivity validation for
managedClusterKubeconfigis consistent with the hub and spoke kubeconfig implementations, providing uniform validation across all kubeconfig sources in the template.fleetconfig-controller/internal/controller/v1beta1/spoke_handler.go (3)
279-311: Refactor improves encapsulation and consistency.The refactored
createAgentNamespacemethod now:
- Accepts the entire Spoke object instead of individual parameters
- Self-fetches the kubeconfig from the Spoke's spec using the Spoke's namespace
- Contains clear early-exit logic for cases where namespace creation is not needed
- Uses consistent logging with
spoke.NameThis improves maintainability and aligns with the pattern used elsewhere in the codebase (e.g.,
KubeconfigFromSecretOrClusterat line 286).
282-284: Early-exit conditions look correct.The early exits for Unified, hub-as-spoke, and PivotComplete instances are appropriate:
- Unified: The agent runs locally, no remote namespace needed
- Hub-as-spoke: Special case where hub acts as its own spoke
- PivotComplete: Agent has already taken over, namespace already exists
These align with the instance type checks in the related code snippets (spoke_controller.go).
173-181: Agent namespace creation now upserts on every reconcile
MovedcreateAgentNamespaceoutside the initial join block to align with “upsert fcc-agent namespace independently of join.” It’s safe and idempotent thanks to the IsAlreadyExists check.fleetconfig-controller/charts/fleetconfig-controller/values.yaml (1)
225-225: Replace placeholder secret name
Use an empty default ("") instead of"foog"in fleetconfig-controller/charts/fleetconfig-controller/values.yaml.- name: "foog" + name: ""If this is for testing, add a comment or note in the PR explaining its use.
fleetconfig-controller/charts/fleetconfig-controller/values.yaml
Outdated
Show resolved
Hide resolved
Signed-off-by: Artur Shad Nik <arturshadnik@gmail.com>
Signed-off-by: Artur Shad Nik <arturshadnik@gmail.com>
Signed-off-by: Artur Shad Nik <arturshadnik@gmail.com>
|
@karl-cardenas-coding: changing LGTM is restricted to collaborators In response to this: Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
I don't need your sassy attitude robot 🤖 |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: arturshadnik, karl-cardenas-coding, TylerGillson The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
33026ef
into
open-cluster-management-io:main
Summary by CodeRabbit
New Features
Bug Fixes
Chores
Documentation