← Back to Pull requests

OCPMCP-538: relist ACM ManagedCluster watch on expired resourceVersion #580

Merged
matzew merged 3 files (254 lines) on Nov 12, 2026 15:11 UTC
View on GitHub
matzew matzew commented on Nov 10, 2026 15:48 UTC
Author

JIRA: https://issues.redhat.com/browse/OCPMCP-538

Problem


The ACM hub provider's watchManagedClusters loop reconnected with the same resourceVersion after a watch closed. Once that RV aged out, the apiserver returns 410 Gone / Expired, which the loop ignored - the in-stream watch.Error event (a metav1.Status) was dropped as "not Unstructured", and backoff only ran when Watch() itself errored. Result: a tight reconnect loop flooding the apiserver/audit logs (~250 watch/sec in one lab), and deletions during the gap were never reflected.

Fix


  • Handle both 410 shapes: the in-stream watch.Error event and Watch() returning ResourceExpired/Gone. Both clear the resourceVersion so the next iteration relists and rewatches from a fresh list RV.

  • refreshClusters reconciles against the authoritative list (prunes removed clusters), skips pruning on an empty/partial relist so a blip can't wipe all targets, and notifies only when the target set changed.

  • Reset backoff on watch progress (events received) instead of a fixed duration.
  • Tests


    reconcileClusters prune/no-op; watch loop relists + backs off for both the in-stream and direct 410 paths.

    Follow-up (out of scope)


    Consider migrating this bespoke relist/backoff loop to client-go tools/watch.RetryWatcher or an informer, which handle Expired detection, backoff, and bookmarks generically.

    <!-- This is an auto-generated comment: release notes by coderabbit.ai -->
    <!-- coderabbit-ai-generated:v1 -->

    Summary by CodeRabbit

    Bug Fixes
    Cluster listings now add newly reported clusters and remove clusters that are no longer present. Empty listings no longer remove existing clusters.
    Cluster updates recover more reliably after expired watch sessions by refreshing the cluster list before resuming updates.
    * Repeated watch retries now use a cancellable delay that increases up to a five-minute limit, and resets after progress or sustained activity.
    <!-- end of auto-generated comment: release notes by coderabbit.ai -->

    Diff: 254 lines (+190 / -64) across 3 files Reviewer: manusa Review duration: 2843m
    All Vouch review confidence checks passed
    Residual risk 0.21 = Change Risk (0.39) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.39 · 254 lines diff across 3 files
    0.39
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    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
    Shallow Review Depth shallow_review_depth
    0.344
    Diff Size diff_size
    0.332
    Real PR Conversation Timeline
    1 comments
    "Review active on #580"
    general weight: 0.35
    Reviewers
    Assignees
    matzew matzew
    Labels
    risk: low confidence: 46.7% 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: 39.1% (MEDIUM) · Higher = larger blast radius
    39.1%
    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: 46.7% · Lower = rushed or shallow review
    46.7%
    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: 20.8% · Safe to merge
    20.8%