Skip to content

Proposal: Extensible Cloud Provider Interface for Agent Configuration - #180

Open
Vaishnav88sk wants to merge 2 commits into
open-cluster-management-io:mainfrom
Vaishnav88sk:cluster-name-provider-interface
Open

Proposal: Extensible Cloud Provider Interface for Agent Configuration#180
Vaishnav88sk wants to merge 2 commits into
open-cluster-management-io:mainfrom
Vaishnav88sk:cluster-name-provider-interface

Conversation

@Vaishnav88sk

@Vaishnav88sk Vaishnav88sk commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

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#1564 and PR open-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

  • Documentation
    • Added a design proposal for an extensible, vendor-neutral cloud provider interface to automatically detect a deterministic cluster name.
    • Describes how optional --cluster-name-provider selects a provider, with graceful fallback to existing cluster-name mechanisms when unavailable or failing.
    • Includes risks/mitigations, test plan, and upgrade guidance.
  • Chores
    • Added enhancement metadata for this provisional proposal.

Signed-off-by: Vaishnav88sk <vaishnavsk8804@gmail.com>
@openshift-ci
openshift-ci Bot requested review from deads2k and qiujian16 June 10, 2026 13:36
@openshift-ci

openshift-ci Bot commented Jun 10, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Vaishnav88sk
Once this PR has been reviewed and has the lgtm label, please assign deads2k for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@coderabbitai

coderabbitai Bot commented Jun 10, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 24667be1-3f0d-47d5-925f-5980320e4bf0

📥 Commits

Reviewing files that changed from the base of the PR and between 8e3420a and 34dc196.

📒 Files selected for processing (1)
  • enhancements/sig-architecture/179-cluster-name-provider-interface/README.md
✅ Files skipped from review due to trivial changes (1)
  • enhancements/sig-architecture/179-cluster-name-provider-interface/README.md

Walkthrough

This 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.

Changes

Cloud Provider Interface Enhancement

Layer / File(s) Summary
Enhancement charter, goals, and risk assessment
enhancements/sig-architecture/179-cluster-name-provider-interface/metadata.yaml, enhancements/sig-architecture/179-cluster-name-provider-interface/README.md
Enhancement metadata and release checklist establish context. The problem statement, goals, non-goals, and risk section define the proposed vendor-neutral provider model and its timeout/fallback handling.
Provider interface and agent integration
enhancements/sig-architecture/179-cluster-name-provider-interface/README.md
Defines the ClusterProvider interface and registry API, then describes agent startup flow that resolves a provider, calls DetectClusterName, and falls back when detection is unavailable or unsuccessful.
Testing strategy, upgrade path, and design alternatives
enhancements/sig-architecture/179-cluster-name-provider-interface/README.md
Documents registry and provider tests, CLI parsing coverage, opt-in backward-compatible upgrade behavior, version-skew handling, and two rejected implementation alternatives.

Estimated code review effort: 2 (Simple) | ~8 minutes

Possibly related issues

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the proposal to add an extensible cloud provider interface for agent configuration.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
enhancements/sig-architecture/179-cluster-name-provider-interface/README.md (1)

67-69: ⚡ Quick win

Add duplicate registration detection.

The Register function 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

📥 Commits

Reviewing files that changed from the base of the PR and between 5b06921 and 8e3420a.

📒 Files selected for processing (2)
  • enhancements/sig-architecture/179-cluster-name-provider-interface/README.md
  • enhancements/sig-architecture/179-cluster-name-provider-interface/metadata.yaml

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