Skip to content

[WIP][DNM]: OCPBUGS-105240: test-only delay MemberRemove to reproduce bootstrap race - #1673

Closed
Neilhamza wants to merge 1 commit into
openshift:mainfrom
Neilhamza:OCPBUGS-105240-reproducer
Closed

[WIP][DNM]: OCPBUGS-105240: test-only delay MemberRemove to reproduce bootstrap race#1673
Neilhamza wants to merge 1 commit into
openshift:mainfrom
Neilhamza:OCPBUGS-105240-reproducer

Conversation

@Neilhamza

@Neilhamza Neilhamza commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

DO NOT MERGE

Test-only reproducer for OCPBUGS-105240. Injects a 5-minute time.Sleep between EtcdRunningInCluster=True and MemberRemove() in removeBootstrap() to hold the race window open and force the TNF pacemaker startup deadlock deterministically.

Usage with cluster-bot

Reproduce the deadlock (PR A alone):

cluster-bot build openshift/cluster-etcd-operator#<this-PR>

Deploy the resulting payload on a TNF fencing cluster. Expected: deadlock every time — pacemaker sees 3 etcd members, logs "found 3 members, need 2".

Verify the fix (PR A + fix PR together):

cluster-bot build openshift/cluster-etcd-operator#<this-PR>,openshift/cluster-etcd-operator#1672

Expected: TNF gate stays closed during the 5-minute delay, then proceeds to clean install after the bootstrap member is removed.

Related

/hold

Summary by CodeRabbit

  • Bug Fixes

    • Bootstrap teardown operations now allow up to ten minutes to complete, reducing failures during slower shutdowns.
  • Tests

    • Added a controlled delay to teardown test scenarios before completion checks and bootstrap member removal.

@openshift-merge-bot

Copy link
Copy Markdown
Contributor

Pipeline controller notification
This repo is configured to use the pipeline controller. Second-stage tests will be triggered either automatically or after lgtm label is added, depending on the repository configuration. The pipeline controller will automatically detect which contexts are required and will utilize /test Prow commands to trigger the second stage.

For optional jobs, comment /test ? to see a list of all defined jobs. To trigger manually all jobs from second stage use /pipeline required command.

This repository is configured in: LGTM mode

@openshift-ci openshift-ci Bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 9, 2026
@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Aug 9, 2026
@openshift-ci openshift-ci Bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Aug 9, 2026
@openshift-ci-robot

Copy link
Copy Markdown

@Neilhamza: This pull request references Jira Issue OCPBUGS-105240, which is invalid:

  • expected the bug to target the "5.0.0" version, but no target version was set

Comment /jira refresh to re-evaluate validity if changes to the Jira bug are made, or edit the title of this pull request to link to a different bug.

The bug has been updated to refer to the pull request using the external bug tracker.

Details

In response to this:

DO NOT MERGE

Test-only reproducer for OCPBUGS-105240. Injects a 5-minute time.Sleep between EtcdRunningInCluster=True and MemberRemove() in removeBootstrap() to hold the race window open and force the TNF pacemaker startup deadlock deterministically.

Usage with cluster-bot

Reproduce the deadlock (PR A alone):

cluster-bot build openshift/cluster-etcd-operator#<this-PR>

Deploy the resulting payload on a TNF fencing cluster. Expected: deadlock every time — pacemaker sees 3 etcd members, logs "found 3 members, need 2".

Verify the fix (PR A + fix PR together):

cluster-bot build openshift/cluster-etcd-operator#<this-PR>,openshift/cluster-etcd-operator#1672

Expected: TNF gate stays closed during the 5-minute delay, then proceeds to clean install after the bootstrap member is removed.

Related

/hold

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci-robot openshift-ci-robot added the jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. label Aug 9, 2026
@openshift-ci

openshift-ci Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@coderabbitai

coderabbitai Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 789d91d9-7b9c-47cb-9228-acca0ae1e846

📥 Commits

Reviewing files that changed from the base of the PR and between 6e8b52a and 1df0224.

📒 Files selected for processing (1)
  • pkg/operator/bootstrapteardown/bootstrap_teardown_controller.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • pkg/operator/bootstrapteardown/bootstrap_teardown_controller.go

Walkthrough

The bootstrap teardown controller now uses a ten-minute sync timeout and adds a test-only five-minute delay before bootstrap completion validation and etcd bootstrap member removal.

Changes

Bootstrap teardown timing

Layer / File(s) Summary
Teardown timeout and validation delay
pkg/operator/bootstrapteardown/bootstrap_teardown_controller.go
Increases the sync timeout from one minute to ten minutes. Adds a test-only five-minute sleep before bootstrap completion validation and etcd bootstrap member removal.

Estimated code review effort: 1 (Trivial) | ~2 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 15
✅ Passed checks (15 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the test-only MemberRemove delay and its purpose of reproducing the bootstrap race.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
Stable And Deterministic Test Names ✅ Passed The PR changes only bootstrap teardown controller logic; its one-file diff adds no Ginkgo It, Describe, Context, or When test title.
Test Structure And Quality ✅ Passed The patch changes only bootstrap_teardown_controller.go and adds no Ginkgo tests, assertions, resource setup, cleanup, or Eventually/Consistently waits to assess.
Microshift Test Compatibility ✅ Passed The pull request changes only the controller; it adds no Ginkgo It, Describe, Context, or When tests, so MicroShift test compatibility does not apply.
Single Node Openshift (Sno) Test Compatibility ✅ Passed The commit changes only the controller and adds no *_test.go files or Ginkgo declarations, so the SNO test compatibility check is not applicable.
Topology-Aware Scheduling Compatibility ✅ Passed The commit changes only bootstrap teardown timing: a 10-minute context and 5-minute sleep; it adds no manifests, replicas, affinity, topology spread, selectors, tolerations, or PDBs.
Ote Binary Stdout Contract ✅ Passed The PR changes only the controller. Its added klog.Warningf uses klog's stderr-default path; direct fmt.Print calls remain inside test execution functions, not OTE setup.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed The commit changes only the controller; it adds no Ginkgo e2e test or network access, and the added code contains no IPv4 assumptions or external connectivity.
No-Weak-Crypto ✅ Passed The PR diff only changes the sync timeout and adds a five-minute time.Sleep; no MD5, SHA1, DES, RC4, Blowfish, ECB, crypto, or secret-comparison code was added.
Container-Privileges ✅ Passed The PR changes only Go controller logic. The added timeout, logging, and sleep introduce no privileged, hostPID, hostNetwork, hostIPC, SYS_ADMIN, or container security settings.
No-Sensitive-Data-In-Logs ✅ Passed The only new log is a static test warning; the change adds no passwords, tokens, API keys, PII, hostnames, or customer data.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (2.12.2)

Error: can't load config: unsupported version of the configuration: "" See https://golangci-lint.run/docs/product/migration-guide for migration instructions
The command is terminated due to an error: can't load config: unsupported version of the configuration: "" See https://golangci-lint.run/docs/product/migration-guide for migration instructions


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

@Neilhamza Neilhamza changed the title DNM: OCPBUGS-105240: test-only delay MemberRemove to reproduce bootstrap race [WIP][DNM]: OCPBUGS-105240: test-only delay MemberRemove to reproduce bootstrap race Aug 9, 2026
@openshift-ci

openshift-ci Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign atiratree for approval. For more information see the Code Review Process.

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

Details Needs approval from an approver in each of these files:

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

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 2

🤖 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 `@pkg/operator/bootstrapteardown/bootstrap_teardown_controller.go`:
- Around line 146-152: Gate the five-minute sleep in the bootstrap member
removal flow behind an explicit test-only hook or mechanism, using the
surrounding removal logic and TestRemoveBootstrap integration point. Ensure
production reconciliation never delays, while the test can still enable the
delay to reproduce the race deterministically; leave normal removal behavior
unchanged.
- Around line 146-152: Replace the five-minute time.Sleep in removeBootstrap
with a timer that exits when ctx.Done() fires, and use a dedicated context whose
deadline spans both the intentional delay and subsequent MemberRemove call.
Alternatively, remove the entire TEST ONLY/DO NOT MERGE delay block before
merging.
🪄 Autofix

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: Repository: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 55f970c0-43a9-49f8-b128-6b0199aa1c1e

📥 Commits

Reviewing files that changed from the base of the PR and between 2f256f2 and 6e8b52a.

📒 Files selected for processing (1)
  • pkg/operator/bootstrapteardown/bootstrap_teardown_controller.go

Comment on lines +146 to +152
// TEST ONLY (OCPBUGS-105240): delay bootstrap member removal by 5 minutes
// to hold the race window open between EtcdRunningInCluster=True and MemberRemove().
// This forces the TNF pacemaker startup deadlock deterministically.
// DO NOT MERGE.
klog.Warningf("TEST ONLY (OCPBUGS-105240): delaying bootstrap member removal by 5 minutes to reproduce race condition")
time.Sleep(5 * time.Minute)

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.

🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy lift

Make the delay truly test-only.

The TEST ONLY comment does not gate this code. Normal bootstrap teardown now blocks for five minutes on every safe removal attempt. The supplied TestRemoveBootstrap test also adds at least ten minutes across its two complete-removal cases.

Inject the delay as a test hook or guard it with an explicit test-only mechanism. Keep the normal reconciliation path unchanged.

🤖 Prompt for 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.

In `@pkg/operator/bootstrapteardown/bootstrap_teardown_controller.go` around lines
146 - 152, Gate the five-minute sleep in the bootstrap member removal flow
behind an explicit test-only hook or mechanism, using the surrounding removal
logic and TestRemoveBootstrap integration point. Ensure production
reconciliation never delays, while the test can still enable the delay to
reproduce the race deterministically; leave normal removal behavior unchanged.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

rg -n -C 6 'WithTimeout|removeBootstrap|time\.Sleep|MemberRemove' \
  pkg/operator/bootstrapteardown

rg -n -C 6 '\bMemberRemove\s*\(' --glob '*.go'

Repository: openshift/cluster-etcd-operator

Length of output: 17857


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- controller imports and methods ---'
sed -n '1,185p' pkg/operator/bootstrapteardown/bootstrap_teardown_controller.go

printf '%s\n' '--- relevant tests ---'
sed -n '330,410p' pkg/operator/bootstrapteardown/bootstrap_teardown_controller_test.go

printf '%s\n' '--- timeout and sleep usage in the package ---'
rg -n -C 4 'context\.WithTimeout|time\.Sleep|MemberRemove|removeBootstrap' pkg/operator/bootstrapteardown

printf '%s\n' '--- current change summary ---'
git status --short
git diff --stat
git diff -- pkg/operator/bootstrapteardown/bootstrap_teardown_controller.go

Repository: openshift/cluster-etcd-operator

Length of output: 24248


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- EtcdClient and MemberRemove implementations ---'
rg -n -C 8 'type EtcdClient|func .*MemberRemove|MemberRemove\s*\(' \
  pkg --glob '*.go'

printf '%s\n' '--- timing probe ---'
python3 - <<'PY'
from dataclasses import dataclass

`@dataclass`
class Context:
    deadline_seconds: int

ctx = Context(deadline_seconds=60)
sleep_seconds = 5 * 60
member_remove_start = sleep_seconds

print(f"context deadline: {ctx.deadline_seconds}s")
print(f"MemberRemove starts: {member_remove_start}s")
print(f"context expired before MemberRemove: {member_remove_start >= ctx.deadline_seconds}")
PY

Repository: openshift/cluster-etcd-operator

Length of output: 15345


Make the test-only delay respect its context deadline.

sync passes a one-minute timeoutCtx to removeBootstrap, but this path blocks for five minutes with time.Sleep. MemberRemove then receives an expired context and returns context deadline exceeded. Replace time.Sleep with a timer that observes ctx.Done(), and use a dedicated context whose deadline covers the delay and member removal. Otherwise, remove this DO NOT MERGE block before merging.

🤖 Prompt for 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.

In `@pkg/operator/bootstrapteardown/bootstrap_teardown_controller.go` around lines
146 - 152, Replace the five-minute time.Sleep in removeBootstrap with a timer
that exits when ctx.Done() fires, and use a dedicated context whose deadline
spans both the intentional delay and subsequent MemberRemove call.
Alternatively, remove the entire TEST ONLY/DO NOT MERGE delay block before
merging.

Source: Path instructions

…rap race

Inject a 5-minute sleep between EtcdRunningInCluster=True and
MemberRemove() in removeBootstrap() to hold the race window open
and force the TNF pacemaker startup deadlock deterministically.

Also extend the sync() context timeout from 1m to 10m so the sleep
doesn't cause a context deadline exceeded before MemberRemove() runs.

DO NOT MERGE — this is a reproducer for testing only.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@Neilhamza
Neilhamza force-pushed the OCPBUGS-105240-reproducer branch from 6e8b52a to 1df0224 Compare August 9, 2026 19:56
@Neilhamza Neilhamza closed this Aug 9, 2026
@openshift-ci-robot

Copy link
Copy Markdown

@Neilhamza: This pull request references Jira Issue OCPBUGS-105240. The bug has been updated to no longer refer to the pull request using the external bug tracker.

Details

In response to this:

DO NOT MERGE

Test-only reproducer for OCPBUGS-105240. Injects a 5-minute time.Sleep between EtcdRunningInCluster=True and MemberRemove() in removeBootstrap() to hold the race window open and force the TNF pacemaker startup deadlock deterministically.

Usage with cluster-bot

Reproduce the deadlock (PR A alone):

cluster-bot build openshift/cluster-etcd-operator#<this-PR>

Deploy the resulting payload on a TNF fencing cluster. Expected: deadlock every time — pacemaker sees 3 etcd members, logs "found 3 members, need 2".

Verify the fix (PR A + fix PR together):

cluster-bot build openshift/cluster-etcd-operator#<this-PR>,openshift/cluster-etcd-operator#1672

Expected: TNF gate stays closed during the 5-minute delay, then proceeds to clean install after the bootstrap member is removed.

Related

/hold

Summary by CodeRabbit

  • Bug Fixes

  • Bootstrap teardown operations now allow up to ten minutes to complete, reducing failures during slower shutdowns.

  • Tests

  • Added a controlled delay to teardown test scenarios before completion checks and bootstrap member removal.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

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

Labels

do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants