← Back to Pull requests

fix(ctl): reject agent names already used by another cluster #1154

Closed
unknown closed this pull request without merging on Oct 16, 2026 17:07 UTC
View on GitHub
unknown unknown commented on Oct 16, 2026 10:27 UTC
Author

What does this PR do / why we need it:

argocd-agentctl agent create only 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 create succeeds, but Argo CD can no longer resolve spec.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 (GetDestinationServer in util/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:

  • Makes agent create fail early if a secret other than the agent's own, labelled argocd.argoproj.io/secret-type=cluster, already has the agent name in its name field. name and server are read directly from the secret data, as Argo CD does, so an unrelated secret with a malformed config cannot break the check.

  • Documents the requirement in the agent naming section of the getting started guide and in the hybrid architecture guide.
  • 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 -v

    Not covered:

  • agent reconfigure (it does not change the agent name)

  • agents created through self-registration, which use a different code path.
  • 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 -->

    Diff: 323 lines (+242 / -81) across 4 files Reviewer: jannfis Review duration: 400m
    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
    0.42
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    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
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 42.0% (MEDIUM) · Higher = larger blast radius
    42.0%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 16.6% · Safe to merge
    16.6%