← Back to Pull requests

OCPBUGS-130459: prevent cached annotation races in deployment controller #463

Open
unknown opened this pull request with 482 lines diff across 6 files
View on GitHub
unknown unknown commented on Oct 12, 2026 03:01 UTC
Author

This pull request was generated by the Product Reliability Agent. To help us improve product stability and CI, please focus review on functional correctness and material concerns. The agent will automatically address feedback, but we’d appreciate keeping non-blocking nits from delaying an otherwise correct PR. Within a week, please merge, provide blocking feedback, or close the PR with a reason.

Motivation

An intermittent fatal error: concurrent map read and map write in openshift-controller-manager was traced through library-go/pkg/apps/appsutil.AnnotationFor while reconciling deployment configurations. The crash interrupted controller work and caused downstream test failures while the controller recovered.

The underlying defect was a deployment controller mutating annotations on a ReplicationController obtained from an informer cache. That shared map could be read concurrently by another controller. The affected failure was recorded against OCPBUGS-130459.

Changes

  • Deep-copy the cached ReplicationController once and use the private copy for outgoing annotation updates.

  • Keep cancellation decisions transition-aware so a Succeeded deployer preserves the permitted Complete transition and does not enter cancellation cleanup, including across an update conflict and retry.

  • Add regression coverage for cancelled New, Pending, and Running deployments, successful deployer and hook-pod retention, unchanged input annotations, cleared outgoing cancellation annotations, unrelated metadata preservation, and an injected update-conflict retry.
  • Evidence

    The original failure was observed in the rejected 5.1.0-0.nightly-2026-10-09-053625 payload. Representative failed CI runs:

  • Aggregated HyperShift AKS conformance analysis

  • Azure OVN upgrade

  • AWS upgrade OVN single-node
  • Validation

  • go test -mod=vendor -race ./pkg/apps/deployer -run '^TestHandle_(cancelledDeploymentSucceeded|cleanupPostNew|cancelNew|cleanupNewWithDeployers)$' -count=1

  • go test -mod=vendor -race ./pkg/apps/deployer ./pkg/apps/deploymentconfig

  • GOFLAGS='-tags=containers_image_openpgp' make build

  • git diff --check
  • The focused race tests, affected package race tests, tagged build, formatting, and diff checks passed. The ordinary untagged build could not run in the workspace because the system gpgme development package was unavailable.

    Only pkg/apps/deployer/deployer_controller.go and pkg/apps/deployer/deployer_controller_test.go changed; go.mod, go.sum, and vendor/ remain unchanged.

    ---
    AI-generated. Review for accuracy.

    @stbenjam requested from Slack

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

    Summary by CodeRabbit

    Bug Fixes
    Cancelled deployments whose deployer finishes successfully now remain Failed, with cancellation metadata preserved.
    Unrelated succeeded pods no longer affect deployment status or get deleted as related deployer pods; related hook pods are cleaned up.
    Deployer and hook pods are cleaned up when a deployment is Failed and its deployer has succeeded.
    * A completed deployer no longer causes a new deployment to be incorrectly marked as timed out.
    <!-- end of auto-generated comment: release notes by coderabbit.ai -->

    Diff: 482 lines (+361 / -121) across 6 files Reviewer: atiratree Review duration: 71346m
    All Vouch review confidence checks passed
    Residual risk 0.46 = Change Risk (0.77) × (1 − Review Confidence (0.41)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.77 · 482 lines diff across 6 files
    0.77
    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%
    40%
    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.370
    Shallow Review Depth shallow_review_depth
    0.344
    Sensitive Paths sensitive_paths
    0.077
    Real PR Conversation Timeline
    1 comments
    "Review active on #463"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: medium confidence: 40.9% reviewed sensitive_module
    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: 77.5% (HIGH) · Higher = larger blast radius
    77.5%
    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: 40.9% · Lower = rushed or shallow review
    40.9%
    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: 45.8% · Moderate risk
    45.8%