← Back to Pull requests

Multi-cluster leader election: allow standby to sync and keep spec.resourceID #16432

Closed
unknown closed this pull request without merging on Nov 26, 2026 19:27 UTC
View on GitHub
unknown unknown commented on Nov 25, 2026 03:03 UTC
Author

This pull request was generated by an AI coding agent.

Summary

In multi-cluster leader election setups, standby clusters were failing to sync spec.resourceID on resources whose ID is service-generated (such as MonitoringGroup and other DCL-based kinds). This led to:
1. KRMSyncer remaining in SyncFailed (Ready=False) on standby clusters due to the admission webhook rejecting updates to immutable spec.resourceID.
2. A standby cluster that became leader creating duplicate resources in GCP because DCL controllers could not find an existing ID without spec.resourceID.
3. spec.resourceID flapping and repeatedly incrementing object generations when synced with both a status-only wildcard rule and per-kind rules under the same server-side apply field manager.

Changes

  • Admission Webhook (pkg/webhook): Allowed the KRM syncer service account (system:serviceaccount:cnrm-system:kcc-syncer) to update spec.resourceID while continuing to strictly enforce all other immutable fields, container annotations, and IAM specifications.

  • KRMSyncer Rules (pkg/controller/kccmanager): Consolidated desired rules in Status replication mode to a single wildcard rule syncing status and spec.resourceID. Deleted pkg/controller/kccmanager/syncer_exceptions.go.

  • Shared Constants (pkg/k8s): Shared k8s.SystemNamespace and k8s.SyncerServiceAccountName across pkg/webhook and pkg/cli/cmd/ha.

  • Tests: Added unit tests in pkg/webhook (TestWhoMaySetServiceGeneratedResourceID, TestSyncerCannotChangeOtherImmutableFields) and envtest integration tests in pkg/controller/kccmanager (TestStandbyKeepsLeaderResourceID), verifying that the standby receives and retains spec.resourceID across reconciliations without changing generation.
  • Fixes #16426

    ``release-note
    Multi-cluster leader election: a standby cluster now gets the leader's
    spec.resourceID. Before, a standby that became the leader created a second resource for DCL-based kinds whose ID the service generates (for example MonitoringGroup), and the standby's KRMSyncer stayed SyncFailed while such an object existed.
    ``

    <sub>🤖 Agent session</sub>

    <!-- factory:task-output kind=Change task=recipe-fix-20261125-022036-72a6 -->

    Diff: 297 lines (+222 / -75) across 3 files Reviewer: lovelace-coder-bot Review duration: 2424m
    All Vouch review confidence checks passed
    Residual risk 0.17 = Change Risk (0.40) × (1 − Review Confidence (0.57)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.40 · 297 lines diff across 3 files
    0.40
    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%
    56%
    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.341
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #16432"
    general weight: 0.35
    Assignees
    Unassigned
    Labels
    risk: low confidence: 56.8% 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: 40% (MEDIUM) · Higher = larger blast radius
    40%
    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: 56.8% · Lower = rushed or shallow review
    56.8%
    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: 17.3% · Safe to merge
    17.3%