fix(ctl): reject agent names already used by another cluster #1154
All Vouch review confidence checks passed
Residual risk 0.17 = Change Risk (0.42) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.42 · 323 lines diff across 4 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.346
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #1154"
general
weight: 0.35
jannfis
What does this PR do / why we need it:
argocd-agentctl agent createonly verifies that the agent's own cluster secret (cluster-<agent-name>) does not exist. It does not check whether another cluster secret already uses the agent name as its Argo CD cluster name.This happens in hybrid setups where the same cluster is registered both as a regular cluster and as an agent under one name.
agent createsucceeds, but Argo CD can no longer resolvespec.destination.name, and every Application targeting the agent fails with:there are 2 clusters with the same name: [https://argocd-agent-resource-proxy:9090?agentName=<name> https://<api-server>]
The error comes from Argo CD (
GetDestinationServerinutil/argo/argo.go) and appears long after its cause. The hybrid docs mention that the two secrets "have different names" but not that this is required.This PR:
agent createfail early if a secret other than the agent's own, labelledargocd.argoproj.io/secret-type=cluster, already has the agent name in itsnamefield.nameandserverare read directly from the secret data, as Argo CD does, so an unrelated secret with a malformedconfigcannot break the check.Example error:
cluster name "my-cluster" is already used by cluster secret "cluster-abc123" (server: https://xyz.eks.amazonaws.com); Argo CD requires cluster names to be unique to resolve destination.name, please choose a different name for the agent
Which issue(s) this PR fixes:
N/A (no existing issue)
Related to #713
How to test changes / Special notes to the reviewer:
go test ./cmd/ctl/ -run Test_checkClusterNameConflict -vNot covered:
agent reconfigure(it does not change the agent name)Checklist
[x] Documentation update is required by this PR (and has been updated) OR no documentation update is required.
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
Summary by CodeRabbit
Bug Fixes
Agent creation now rejects names already used by another registered cluster, preventing destination resolution errors caused by duplicate names.
Documentation
* Clarified that agent names must be unique among registered clusters and suggested adding a suffix to avoid conflicts.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->