Proposal: Extensible Cloud Provider Interface for Agent Configuration - #180
Proposal: Extensible Cloud Provider Interface for Agent Configuration#180Vaishnav88sk wants to merge 2 commits into
Conversation
Signed-off-by: Vaishnav88sk <vaishnavsk8804@gmail.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: Vaishnav88sk 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 |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
✅ Files skipped from review due to trivial changes (1)
WalkthroughThis PR adds a design specification for an extensible cloud provider interface to auto-detect OCM Spoke Agent cluster names through an opt-in flag, including registry-based provider lookup, fallback behavior, testing plans, and upgrade guidance. ChangesCloud Provider Interface Enhancement
Estimated code review effort: 2 (Simple) | ~8 minutes Possibly related issues
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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.
Actionable comments posted: 2
🧹 Nitpick comments (1)
enhancements/sig-architecture/179-cluster-name-provider-interface/README.md (1)
67-69: ⚡ Quick winAdd duplicate registration detection.
The
Registerfunction silently overwrites any existing provider with the same name. If two vendor packages accidentally use the same provider name, the last one initialized wins without any warning, making debugging difficult.🛡️ Proposed enhancement to detect duplicates
func Register(name string, p ClusterProvider) { registryMu.Lock() defer registryMu.Unlock() + if _, exists := registry[name]; exists { + panic(fmt.Sprintf("provider %q is already registered", name)) + } registry[name] = p }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@enhancements/sig-architecture/179-cluster-name-provider-interface/README.md` around lines 67 - 69, The Register function currently overwrites any existing provider in the registry map; update Register(name string, p ClusterProvider) to detect duplicates by checking registry[name] before assignment and fail loudly (e.g., log.Fatalf or panic with a clear message including the duplicate name) instead of silently replacing the entry so two packages cannot accidentally register the same provider; reference the registry map and the Register and ClusterProvider symbols when making this change.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@enhancements/sig-architecture/179-cluster-name-provider-interface/README.md`:
- Around line 81-92: The call to provider.DetectClusterName currently uses
context.TODO(), which defeats the intended timeout guarantee; change the call
site in the block that checks o.ClusterNameProvider / providers.GetProvider to
create a cancellable context (e.g., context.WithTimeout) with an appropriate
short timeout (e.g., 5–30s), defer the cancel, and pass that context into
provider.DetectClusterName (after successfully creating config with
clientcmd.BuildConfigFromFlags using o.SpokeKubeconfigFile); this ensures
DetectClusterName cannot hang indefinitely and preserves the risk mitigation
promised by the interface.
- Around line 65-74: The registry map (registry) is accessed concurrently in
Register and GetProvider causing race panics; protect it with a sync.RWMutex
(e.g., add a package-level var registryMu sync.RWMutex) and use
registryMu.Lock()/Unlock() around writes in Register and
registryMu.RLock()/RUnlock() around reads in GetProvider (ensure the map
initialization remains the same and references to ClusterProvider, Register, and
GetProvider are unchanged).
---
Nitpick comments:
In `@enhancements/sig-architecture/179-cluster-name-provider-interface/README.md`:
- Around line 67-69: The Register function currently overwrites any existing
provider in the registry map; update Register(name string, p ClusterProvider) to
detect duplicates by checking registry[name] before assignment and fail loudly
(e.g., log.Fatalf or panic with a clear message including the duplicate name)
instead of silently replacing the entry so two packages cannot accidentally
register the same provider; reference the registry map and the Register and
ClusterProvider symbols when making this change.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 8bd49cce-a03b-4479-a95d-8e7896eb1ab5
📒 Files selected for processing (2)
enhancements/sig-architecture/179-cluster-name-provider-interface/README.mdenhancements/sig-architecture/179-cluster-name-provider-interface/metadata.yaml
Related: #179
This enhancement proposal introduces an extensible, plugin-based Cloud Provider Interface for the OCM Spoke Agent. It allows the agent to auto-detect environment-specific metadata (like
SpokeClusterName) without violating the vendor-neutrality of the core project.Context:
This proposal stems from the maintainer discussions in
open-cluster-management-io/ocm#1564and PRopen-cluster-management-io/ocm#1562. We agreed that hardcoding vendor APIs directly into the core agent is an anti-pattern, and a generic interface is required.A fully working Proof of Concept (PoC) implementing this exact design (including the registry and an OpenShift provider) has already been built and tested to ensure technical feasibility.
I look forward to your feedback on the design!
Summary by CodeRabbit
--cluster-name-providerselects a provider, with graceful fallback to existing cluster-name mechanisms when unavailable or failing.