← Back to Pull requests

Fix flaky "enqueue event for wrong name" Ready test #1085

Closed
unknown closed this pull request without merging on Nov 22, 2026 07:08 UTC
View on GitHub
unknown unknown commented on Nov 20, 2026 17:25 UTC
Author

This fixes a test that has failed 4 of the last 9 completed runs of pull-cert-manager-approver-policy-test on #1076, #1077 and #1083. It changes test code only. The follow-up for the controller is #1086.

What went wrong

The spec "After enqueue event but for wrong name, should not change returning not-ready" does this:

1. Waits for the policy to become not-ready.
2. Flips plugin 2 to report ready.
3. Sends an enqueue event for a different policy name.
4. Expects the policy to stay not-ready for 10 seconds.

The controller watches the policy without a predicate, so it reconciles the policy again in response to its own status update. When that reconcile runs after step 2, it marks the policy ready and the test fails. The enqueue event is not involved.

The fix

The test now waits until plugin 2 has been called twice, and then has not been called for one second, before it flips plugin 2 to ready. The two calls are the reconcile for the create and the reconcile for the controller's own status update.

The quiet second is only a guard against a third reconcile, which I do not expect. #1086 proposes that the controller ignore its own status updates. The wait can be deleted when that is fixed.

The second commit addresses review findings in the other Ready specs:

  • The controllers now start after each spec has set the plugins' Ready funcs. The specs used to replace each plugin's fake reconciler while the controllers were running.

  • The counters which the specs share with the controller goroutines are atomic values.
  • How I tested it

    <details>
    <summary>Evidence</summary>

    The unmodified test passed 30 of 30 runs on my machine, so I could not reproduce the failure by repetition. Instead I added a 100ms sleep to plugin 2's second and later calls, which delays the controller's second reconcile:

    | Version | Result with the sleep |
    |---|---|
    | Test on main | Failed on the first run with "expected the condition to maintain not-ready" |
    | Test in this PR | Passed 3 of 3 |

    The full controller suite passes with both commits (50 of 50 specs). The Ready specs also pass with --race (19 of 19). The race detector reports one race, in the cert-manager test webhook server, which is unrelated to this change. It reports the same race without the second commit.

    Failing CI runs:

  • https://prow.infra.cert-manager.io/view/gs/cert-manager-prow-artifacts/pr-logs/pull/cert-manager_approver-policy/1076/pull-cert-manager-approver-policy-test/2119938181452271616

  • https://prow.infra.cert-manager.io/view/gs/cert-manager-prow-artifacts/pr-logs/pull/cert-manager_approver-policy/1077/pull-cert-manager-approver-policy-test/2120884113752723456

  • https://prow.infra.cert-manager.io/view/gs/cert-manager-prow-artifacts/pr-logs/pull/cert-manager_approver-policy/1077/pull-cert-manager-approver-policy-test/2120926644393742336

  • #1083, run of 2026-11-20
  • In the first log the controller reconciles the policy a second time, reports ready=true, and the assertion fails 10ms later.

    </details>

    Not covered

  • A fifth failure, on #1077 on 14 November, was a different spec in the RBAC suite. I have not looked at it.

  • The controller change itself. See #1086.
  • /kind flake

    [Claude Fable 5.2]

    Diff: 422 lines (+316 / -106) across 5 files Reviewer: wallrj Review duration: 2263m
    All Vouch review confidence checks passed
    Residual risk 0.18 = Change Risk (0.45) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.45 · 422 lines diff across 5 files
    0.45
    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.362
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #1085"
    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: 45% (MEDIUM) · Higher = larger blast radius
    45%
    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: 17.8% · Safe to merge
    17.8%