Skip to content
This repository was archived by the owner on Sep 9, 2026. It is now read-only.

NO_ISSUE: Fix refresh script race conditions causing e2e-vmaas flakes - #122

Merged
openshift-merge-bot[bot] merged 3 commits into
mainfrom
fix-refresh-script-flakes
May 19, 2026
Merged

openshift-merge-bot[bot] merged 3 commits into
mainfrom
fix-refresh-script-flakes

Conversation

@omer-vishlitzky

@omer-vishlitzky omer-vishlitzky commented May 19, 2026

Copy link
Copy Markdown
Contributor

Problem

The e2e-vmaas CI job has a high failure rate, with the vast majority of failures caused by race conditions in the refresh script — not actual test failures.

Four root causes account for ~80% of all CI failures:

Root Cause Description
Route patching API endpoint 10.128.0.1:443 refuses connections after snapshot boot
trust-manager webhook No endpoints when kustomize applies Bundle CRs
Keycloak TLS cert cert-manager reissuing keycloak-tls after recert causes TLS handshake failures
gRPC fulfillment osac CLI calls fail before server is reachable

All four are the same fundamental bug: the script doesn't wait for what it's about to use. The cluster passes the operator readiness gate (34/34), but individual services need additional time after snapshot boot + recert.

Fix

Parallel stability gate (before any steps)

A single parallel gate waits for all pre-kustomize dependencies concurrently:

  • oc rollout status deploy/trust-manager — trust-manager is not a cluster operator, so 34/34 misses it
  • oc wait --for=condition=Ready certificate/keycloak-tls — cert-manager reissues TLS certs after recert
  • Route patching with retry_command — API admission webhook needs time after recert

All three run in parallel. Total wall time = max(all three) ≈ 2-3 min typical.

Post-kustomize retries

osac login, osac delete hub, osac create hub wrapped in retry_command (5min timeout each) — handles gRPC server not being ready after deployment rollout.

Other fixes

  • retry_command helper in lib.sh with correct exit code handling (local rc=0; "$@" || rc=$? instead of the bash-broken local rc=$?)
  • Fixed bare wait calls that silently swallowed rollout failures under set -o errexit
  • Verbose logging: each retry attempt logs attempt number, elapsed time, and exit code

Timeout budget

Phase Timeout Typical
Parallel gate 5 min (all 3 concurrent) 2-3 min
osac CLI retries 5 min each × 3 0 (pass first try)
Worst case total added 20 min 2-3 min

Well under the 50-min SSH timeout.

@openshift-ci
openshift-ci Bot requested review from adriengentil and larsks May 19, 2026 10:56
@coderabbitai

coderabbitai Bot commented May 19, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

This PR adds a bash retry_command helper and uses it to retry transient cluster operations in two scripts. prepare-fulfillment-service.sh now queries routes with a quoted namespace and wraps osac login, hub deletion, and hub creation in retry_command. refresh-after-snapshot.sh now retries oc patch for route hosts and waits for cert-manager's trust-manager rollout (logging pods/endpoints) before applying overlays and deleting jobs.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: fixing race conditions in refresh scripts causing CI flakes. It is specific, concise, and directly relates to the core problem being solved.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed The pull request description clearly explains the root causes of CI failures and how the changes address them, with specific examples and timeout budgets.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@omer-vishlitzky omer-vishlitzky changed the title Fix refresh script race conditions causing e2e-vmaas flakes NO_ISSUE: Fix refresh script race conditions causing e2e-vmaas flakes May 19, 2026
@omer-vishlitzky
omer-vishlitzky force-pushed the fix-refresh-script-flakes branch 2 times, most recently from a237b4b to 4531c5b Compare May 19, 2026 12:12

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@scripts/lib.sh`:
- Around line 76-80: The if block is capturing $? too late so local rc gets 0;
run the command and capture its exit code immediately into rc before testing it:
execute "$@" then set rc=$? and use that rc in the conditional, the error log,
and the final return. Update the logic around the existing if "$@"; then ... fi
(and the local rc assignment) so all references use the captured rc variable
(from the immediate execution) instead of relying on `$?` after the if; ensure
the success branch still prints the retry message and the failure branch logs
"exit code $rc" and returns $rc.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Enterprise

Run ID: 2755a0d7-089c-4232-9208-70d4454ecb61

📥 Commits

Reviewing files that changed from the base of the PR and between 71a9ec7 and 4531c5b.

📒 Files selected for processing (3)
  • scripts/lib.sh
  • scripts/prepare-fulfillment-service.sh
  • scripts/refresh-after-snapshot.sh
🚧 Files skipped from review as they are similar to previous changes (2)
  • scripts/prepare-fulfillment-service.sh
  • scripts/refresh-after-snapshot.sh

Comment thread scripts/lib.sh Outdated
Add retry/wait logic at three failure points in the refresh script:
- Route patching: retry on API admission webhook connection refused
- Kustomize apply: wait for trust-manager deployment before applying Bundle CRs
- Fulfillment service: retry osac CLI gRPC calls until server is reachable
@omer-vishlitzky
omer-vishlitzky force-pushed the fix-refresh-script-flakes branch from 4531c5b to 9e5ba91 Compare May 19, 2026 14:02
@omer-vishlitzky

Copy link
Copy Markdown
Contributor Author

/retest

Replace scattered per-step retries with a single parallel stabilization
gate that waits for trust-manager, keycloak-tls certificate, and route
patching concurrently. Total wait = max of all three (~2-3 min typical).

Worst-case retry budget drops from 50min to 20min, well under the
50-min SSH timeout.

Fix (( attempt++ )) which returns exit code 1 when attempt is 0.
Replace bare wait with per-PID wait and failure tracking for both
fulfillment rollout steps. Bare wait under errexit does not propagate
background job failures.

@akshaynadkarni akshaynadkarni left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@openshift-ci

openshift-ci Bot commented May 19, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: akshaynadkarni, omer-vishlitzky

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:
  • OWNERS [akshaynadkarni,omer-vishlitzky]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants