Skip to content

OCPEDGE-2381: Add test to verify for backup container exists when etcd crashes#30922

Open
kasturinarra wants to merge 1 commit intoopenshift:mainfrom
kasturinarra:automate_case_86079
Open

OCPEDGE-2381: Add test to verify for backup container exists when etcd crashes#30922
kasturinarra wants to merge 1 commit intoopenshift:mainfrom
kasturinarra:automate_case_86079

Conversation

@kasturinarra
Copy link
Contributor

No description provided.

@openshift-ci-robot
Copy link

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: automatic mode

@coderabbitai
Copy link

coderabbitai bot commented Mar 23, 2026

Walkthrough

Adds a disruptive Ginkgo test suite that simulates ungraceful reboot recovery on a dual-replica cluster: it removes the etcd pod manifest, reboots the target node, validates etcd membership transitions (learner → learner started → promoted to voting), checks etcd container/runtime artifacts, and inspects pacemaker logs for pod recreation.

Changes

Cohort / File(s) Summary
Etcd recovery test
test/extended/two_node/tnf_recovery.go
New Ginkgo Describe suite "Two Node with Fencing etcd recovery" with a disruptive It test that: selects peer/target nodes, records epoch timestamp, removes /var/lib/etcd/pod.yaml, triggers an ungraceful reboot, validates etcd membership transitions using validateEtcdRecoveryState, checks etcd containers via podman (parsing with strings.TrimSpace/strings.Split), verifies etcd-previous presence, and inspects pacemaker journal for pod.yaml recreation. Updated imports to include strings.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~18 minutes

✨ 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.11.3)

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 and usage tips.

@kasturinarra kasturinarra changed the title Add test to verify for backup container exists when etcd crashes OCPEDGE-2381: Add test to verify for backup container exists when etcd crashes Mar 23, 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 Mar 23, 2026
@openshift-ci-robot
Copy link

openshift-ci-robot commented Mar 23, 2026

@kasturinarra: This pull request references OCPEDGE-2381 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.22.0" version, but no target version was set.

Details

In response to this:

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
Copy link
Contributor

openshift-ci bot commented Mar 23, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: kasturinarra
Once this PR has been reviewed and has the lgtm label, please assign suleymanakbas91 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

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (1)
test/extended/two_node/tnf_recovery.go (1)

475-480: Normalize shell output before asserting container-running state.

Line 479 compares exact raw output to "'true'". This is fragile against trailing newlines/format changes from shell commands.

Stabilize assertion
- o.Expect(got).To(o.Equal("'true'"), fmt.Sprintf("expected etcd container running on %s", targetNode.Name))
+ o.Expect(strings.TrimSpace(got)).To(
+ 	o.Or(o.Equal("true"), o.Equal("'true'")),
+ 	fmt.Sprintf("expected etcd container running on %s", targetNode.Name),
+ )
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/extended/two_node/tnf_recovery.go` around lines 475 - 480, The test is
asserting raw shell output equals "'true'" which is brittle; update the check
around the call to exutil.DebugNodeRetryWithOptionsAndChroot (and the got
variable from ensurePodmanEtcdContainerIsRunning) to normalize output
first—apply strings.TrimSpace and strip any surrounding quotes (e.g.,
strings.Trim(got, `"'`)) and then assert the normalized value equals "true" so
trailing newlines or quote variations won't break the assertion.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@test/extended/two_node/tnf_recovery.go`:
- Around line 442-446: The current approach captures a human-readable timestamp
via exutil.DebugNodeRetryWithOptionsAndChroot into timestampStr/rebootTimestamp
and then lexically filters pacemaker logs, which is brittle; change the
timestamp capture to epoch seconds (e.g., use date +%s via
DebugNodeRetryWithOptionsAndChroot to populate a numeric rebootEpoch variable)
and then filter pacemaker/journal logs numerically (e.g., use journalctl
--since=@<epoch> or compare numeric epoch fields in awk) instead of doing string
comparisons against full log lines; update all uses that reference
rebootTimestamp (and the later awk-based filter logic) to use the epoch-based
numeric filter so events remain correctly ordered across time boundaries.
- Around line 447-450: The test currently uses rm -f which masks a missing
/var/lib/etcd/pod.yaml and weakens the precondition; update the removal step in
tnf_recovery.go to first assert the file exists on the target node (use
exutil.DebugNodeRetryWithOptionsAndChroot with a "test -f
/var/lib/etcd/pod.yaml" or "stat" check against targetNode.Name) and fail the
test if it is missing, then run the remove command (without -f) to delete it and
keep the existing o.Expect check (or adjust the error message) so the test
verifies recreation after an actual deletion.
- Around line 414-436: The new duplicate Describe block titled "Two Node with
Fencing etcd recovery" must be removed and its It(...) test moved into the
existing Describe block that already contains the BeforeEach setup to avoid
duplicated setup and missing feature-gate labeling; update the target Describe
(the existing var _ = g.Describe(...) that includes BeforeEach and
utils.SkipIfNotTopology) to include the new It(...) and ensure the Describe
retains the OCPFeatureGate:DualReplica label so the test keeps the same label
set and topology gating (locate the duplicate Describe, the BeforeEach function,
and the new It(...) and merge the It into the original Describe rather than
creating a second Describe).

---

Nitpick comments:
In `@test/extended/two_node/tnf_recovery.go`:
- Around line 475-480: The test is asserting raw shell output equals "'true'"
which is brittle; update the check around the call to
exutil.DebugNodeRetryWithOptionsAndChroot (and the got variable from
ensurePodmanEtcdContainerIsRunning) to normalize output first—apply
strings.TrimSpace and strip any surrounding quotes (e.g., strings.Trim(got,
`"'`)) and then assert the normalized value equals "true" so trailing newlines
or quote variations won't break the assertion.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 4369e033-00f8-494d-b09f-a9506ad9e10c

📥 Commits

Reviewing files that changed from the base of the PR and between 785f8b0 and 5d285bf.

📒 Files selected for processing (1)
  • test/extended/two_node/tnf_recovery.go

@openshift-ci-robot
Copy link

Scheduling required tests:
/test e2e-aws-csi
/test e2e-aws-ovn-fips
/test e2e-aws-ovn-microshift
/test e2e-aws-ovn-microshift-serial
/test e2e-aws-ovn-serial-1of2
/test e2e-aws-ovn-serial-2of2
/test e2e-gcp-csi
/test e2e-gcp-ovn
/test e2e-gcp-ovn-upgrade
/test e2e-metal-ipi-ovn-ipv6
/test e2e-vsphere-ovn
/test e2e-vsphere-ovn-upi

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
test/extended/two_node/tnf_recovery.go (1)

477-479: Fragile command argument parsing with strings.Split.

Using strings.Split(ensurePodmanEtcdContainerIsRunning, " ")... to construct command arguments is fragile. If the command contains quoted strings, paths with spaces, or complex shell expressions, splitting by space will produce incorrect arguments.

Consider defining the command as a slice directly or using bash -c with the full command string (as done elsewhere in this file).

♻️ Suggested alternative approach
-		got, err := exutil.DebugNodeRetryWithOptionsAndChroot(oc, targetNode.Name, "openshift-etcd",
-			strings.Split(ensurePodmanEtcdContainerIsRunning, " ")...)
+		got, err := exutil.DebugNodeRetryWithOptionsAndChroot(oc, targetNode.Name, "openshift-etcd",
+			"bash", "-c", "podman inspect --format '{{.State.Running}}' etcd")
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/extended/two_node/tnf_recovery.go` around lines 477 - 479, The command
argument construction using strings.Split(ensurePodmanEtcdContainerIsRunning, "
") is fragile; update the call site that invokes
ensurePodmanEtcdContainerIsRunning so it either (a) passes a pre-built []string
of arguments instead of splitting the string, or (b) executes the full string
via a shell wrapper like "bash -c" with the entire
ensurePodmanEtcdContainerIsRunning string as a single argument; locate the usage
around the Expect(got).To(o.Equal("'true'")) assertion and replace the
strings.Split(...) spread with one of these safer approaches (refer to the
ensurePodmanEtcdContainerIsRunning symbol and the surrounding command execution
code to apply the change).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@test/extended/two_node/tnf_recovery.go`:
- Around line 477-479: The command argument construction using
strings.Split(ensurePodmanEtcdContainerIsRunning, " ") is fragile; update the
call site that invokes ensurePodmanEtcdContainerIsRunning so it either (a)
passes a pre-built []string of arguments instead of splitting the string, or (b)
executes the full string via a shell wrapper like "bash -c" with the entire
ensurePodmanEtcdContainerIsRunning string as a single argument; locate the usage
around the Expect(got).To(o.Equal("'true'")) assertion and replace the
strings.Split(...) spread with one of these safer approaches (refer to the
ensurePodmanEtcdContainerIsRunning symbol and the surrounding command execution
code to apply the change).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: bbe21470-c466-4c79-9601-acec05174456

📥 Commits

Reviewing files that changed from the base of the PR and between 5d285bf and 560c591.

📒 Files selected for processing (1)
  • test/extended/two_node/tnf_recovery.go

@kasturinarra
Copy link
Contributor Author

🧹 Nitpick comments (1)

test/extended/two_node/tnf_recovery.go (1)> 477-479: Fragile command argument parsing with strings.Split.

Using strings.Split(ensurePodmanEtcdContainerIsRunning, " ")... to construct command arguments is fragile. If the command contains quoted strings, paths with spaces, or complex shell expressions, splitting by space will produce incorrect arguments.
Consider defining the command as a slice directly or using bash -c with the full command string (as done elsewhere in this file).

♻️ Suggested alternative approach

-		got, err := exutil.DebugNodeRetryWithOptionsAndChroot(oc, targetNode.Name, "openshift-etcd",
-			strings.Split(ensurePodmanEtcdContainerIsRunning, " ")...)
+		got, err := exutil.DebugNodeRetryWithOptionsAndChroot(oc, targetNode.Name, "openshift-etcd",
+			"bash", "-c", "podman inspect --format '{{.State.Running}}' etcd")

🤖 Prompt for AI Agents

Verify each finding against the current code and only fix it if needed.

In `@test/extended/two_node/tnf_recovery.go` around lines 477 - 479, The command
argument construction using strings.Split(ensurePodmanEtcdContainerIsRunning, "
") is fragile; update the call site that invokes
ensurePodmanEtcdContainerIsRunning so it either (a) passes a pre-built []string
of arguments instead of splitting the string, or (b) executes the full string
via a shell wrapper like "bash -c" with the entire
ensurePodmanEtcdContainerIsRunning string as a single argument; locate the usage
around the Expect(got).To(o.Equal("'true'")) assertion and replace the
strings.Split(...) spread with one of these safer approaches (refer to the
ensurePodmanEtcdContainerIsRunning symbol and the surrounding command execution
code to apply the change).

🤖 Prompt for all review comments with AI agents

Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@test/extended/two_node/tnf_recovery.go`:
- Around line 477-479: The command argument construction using
strings.Split(ensurePodmanEtcdContainerIsRunning, " ") is fragile; update the
call site that invokes ensurePodmanEtcdContainerIsRunning so it either (a)
passes a pre-built []string of arguments instead of splitting the string, or (b)
executes the full string via a shell wrapper like "bash -c" with the entire
ensurePodmanEtcdContainerIsRunning string as a single argument; locate the usage
around the Expect(got).To(o.Equal("'true'")) assertion and replace the
strings.Split(...) spread with one of these safer approaches (refer to the
ensurePodmanEtcdContainerIsRunning symbol and the surrounding command execution
code to apply the change).

ℹ️ Review info

No update needed. The strings.Split(ensurePodmanEtcdContainerIsRunning, " ") pattern is the established convention in this codebase — tnf_topology.go:134 uses the exact
same approach with the same constant. The command podman inspect --format '{{.State.Running}}' etcd has no spaces within its arguments that would cause a split issue, so
it works correctly. Changing it would diverge from the existing pattern without benefit.

@openshift-ci-robot
Copy link

Scheduling required tests:
/test e2e-aws-csi
/test e2e-aws-ovn-fips
/test e2e-aws-ovn-microshift
/test e2e-aws-ovn-microshift-serial
/test e2e-aws-ovn-serial-1of2
/test e2e-aws-ovn-serial-2of2
/test e2e-gcp-csi
/test e2e-gcp-ovn
/test e2e-gcp-ovn-upgrade
/test e2e-metal-ipi-ovn-ipv6
/test e2e-vsphere-ovn
/test e2e-vsphere-ovn-upi

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Mar 24, 2026

@kasturinarra: all tests passed!

Full PR test history. Your PR dashboard.

Details

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 kubernetes-sigs/prow repository. I understand the commands that are listed here.

@kasturinarra
Copy link
Contributor Author

/pj-rehearse periodic-ci-openshift-release-main-nightly-4.22-e2e-metal-ovn-two-node-fencing-degraded-techpreview

@kasturinarra
Copy link
Contributor Author

/payload-job periodic-ci-openshift-release-main-nightly-4.22-e2e-metal-ovn-two-node-fencing-degraded-techpreview

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Mar 24, 2026

@kasturinarra: trigger 1 job(s) for the /payload-(with-prs|job|aggregate|job-with-prs|aggregate-with-prs) command

  • periodic-ci-openshift-release-main-nightly-4.22-e2e-metal-ovn-two-node-fencing-degraded-techpreview

See details on https://pr-payload-tests.ci.openshift.org/runs/ci/e97cdf30-2783-11f1-8365-3f97cbfc1ca9-0

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

Labels

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