Skip to content

OCPEDGE-2491: Log pcs status and etcd member list after every recovery#30949

Merged
openshift-merge-bot[bot] merged 3 commits intoopenshift:mainfrom
lucaconsalvi:tnf-recovery-post-test-logging
Apr 10, 2026
Merged

OCPEDGE-2491: Log pcs status and etcd member list after every recovery#30949
openshift-merge-bot[bot] merged 3 commits intoopenshift:mainfrom
lucaconsalvi:tnf-recovery-post-test-logging

Conversation

@lucaconsalvi
Copy link
Copy Markdown
Contributor

Summary

  • Add post-test logging of sudo pcs status and sudo podman exec etcd etcdctl member list
    -w table after every recovery test (pass or fail)
  • Uses SSH through the hypervisor instead of the Kubernetes API, which may be unavailable
    after recovery tests
  • Gated on HasHypervisorConfig() — no-op when hypervisor SSH credentials are not
    configured
  • Errors are logged but never fail the test

Details

Recovery tests currently don't log final cluster state, making it harder to diagnose
failures. This adds a logFinalClusterStatus helper registered via DeferCleanup in
BeforeEach that SSHs through the hypervisor to collect pacemaker and etcd membership
status from the cluster nodes after every test completes.

The function tries each node in order and stops after the first node where both commands
succeed (since both commands return cluster-wide state). If a node is unreachable or a
command fails, it logs the error and tries the next node.

Test plan

  • Verified logging fires on a passing test (etcd process crash recovery)
  • Verified logging fires on a failing test (BMC credential rotation — etcd timeout)
  • Confirmed graceful error handling when etcd container is stopped on a node

Fixes: OCPEDGE-2491

…y test

Add post-test logging of `sudo pcs status` and `sudo podman exec etcd
etcdctl member list -w table` via SSH through the hypervisor after every
recovery test (pass or fail). This provides visibility into the final
cluster state without relying on the Kubernetes API, which may be
unavailable after recovery tests.

The logging is registered via DeferCleanup in BeforeEach and is gated
on HasHypervisorConfig(). Errors are logged but never fail the test.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@openshift-ci-robot
Copy link
Copy Markdown

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

@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci bot commented Apr 1, 2026

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

@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 Apr 1, 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 Apr 1, 2026
@openshift-ci-robot
Copy link
Copy Markdown

openshift-ci-robot commented Apr 1, 2026

@lucaconsalvi: This pull request references OCPEDGE-2491 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 bug to target the "4.22.0" version, but no target version was set.

Details

In response to this:

Summary

  • Add post-test logging of sudo pcs status and sudo podman exec etcd etcdctl member list
    -w table after every recovery test (pass or fail)
  • Uses SSH through the hypervisor instead of the Kubernetes API, which may be unavailable
    after recovery tests
  • Gated on HasHypervisorConfig() — no-op when hypervisor SSH credentials are not
    configured
  • Errors are logged but never fail the test

Details

Recovery tests currently don't log final cluster state, making it harder to diagnose
failures. This adds a logFinalClusterStatus helper registered via DeferCleanup in
BeforeEach that SSHs through the hypervisor to collect pacemaker and etcd membership
status from the cluster nodes after every test completes.

The function tries each node in order and stops after the first node where both commands
succeed (since both commands return cluster-wide state). If a node is unreachable or a
command fails, it logs the error and tries the next node.

Test plan

  • Verified logging fires on a passing test (etcd process crash recovery)
  • Verified logging fires on a failing test (BMC credential rotation — etcd timeout)
  • Confirmed graceful error handling when etcd container is stopped on a node

Fixes: OCPEDGE-2491

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.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 1, 2026

Walkthrough

Added a post-spec cleanup hook that always collects concise Pacemaker (pcs) and etcd membership status for the two selected nodes. Tightened hypervisor SSH config and private key validation and introduced a file-local helper to perform SSH-based diagnostics, which no-ops when SSH prerequisites are missing.

Changes

Cohort / File(s) Summary
Test file
test/extended/two_node/tnf_recovery.go
Added g.DeferCleanup in BeforeEach to always run final diagnostics. Updated setupMinimalTestEnvironment to error when hypervisor SSH config is nil and to treat any os.Stat error on the private key as fatal. Added file-local logFinalClusterStatus(nodes []corev1.Node) that no-ops if SSH config unavailable, validates private key, prepares local/remote known_hosts, runs services.PcsStatus and sudo podman exec etcd etcdctl member list -w table over SSH per node, logs stdout/stderr, and stops after the first node where both commands succeed (otherwise logs errors/continues).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@lucaconsalvi lucaconsalvi marked this pull request as ready for review April 2, 2026 13:08
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Apr 2, 2026
@openshift-ci openshift-ci bot requested review from jaypoulz and jeff-roche April 2, 2026 13:09
Copy link
Copy Markdown

@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: 1

🤖 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 828-843: The SSH helper calls currently discard stderr (using `_`)
and only log the error object on failure, losing valuable diagnostics; update
the calls to services.PcsStatus and core.ExecuteRemoteSSHCommand so they capture
both stdout and stderr (e.g., pcsOutput, pcsErrOutput, pcsErr and etcdOutput,
etcdErrOutput, etcdErr), and when pcsErr or etcdErr is non-nil include both the
stdout and stderr variables in the framework.Logf message (alongside the error)
to preserve command output for debugging while keeping the existing success-path
logging unchanged.
🪄 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: Pro

Run ID: 562d68bd-fc7c-43f9-8584-c2979c2c83dc

📥 Commits

Reviewing files that changed from the base of the PR and between a938a04 and 78e49b4.

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

@openshift-ci-robot
Copy link
Copy Markdown

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

Include stdout and stderr in error log messages for pcs status and etcd
member list commands, so diagnostic output is not lost on failure.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@openshift-ci-robot
Copy link
Copy Markdown

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

@lucaconsalvi
Copy link
Copy Markdown
Contributor Author

/test e2e-gcp-ovn-upgrade

@lucaconsalvi
Copy link
Copy Markdown
Contributor Author

/test e2e-metal-ipi-ovn-ipv6

@openshift-trt
Copy link
Copy Markdown

openshift-trt bot commented Apr 7, 2026

Job Failure Risk Analysis for sha: d451f3c

Job Name Failure Risk
pull-ci-openshift-origin-main-e2e-aws-ovn-fips Low
[Jira:Node][sig-node] Node non-cnv swap configuration should reject user override of swap settings via KubeletConfig API [OCP-86395] [Suite:openshift/conformance/parallel]
This test has passed 38.68% of 287 runs on release 5.0 [Overall] in the last week.
pull-ci-openshift-origin-main-e2e-gcp-ovn Low
[Jira:Node][sig-node] Node non-cnv swap configuration should reject user override of swap settings via KubeletConfig API [OCP-86395] [Suite:openshift/conformance/parallel]
This test has passed 0.00% of 2 runs on release 5.0 [Architecture:amd64 FeatureSet:default Installer:ipi JobTier:standard Network:ovn NetworkStack:ipv4 OS:rhcos9 Owner:eng Platform:gcp Procedure:none SecurityMode:default Topology:ha Upgrade:major] in the last week.
pull-ci-openshift-origin-main-e2e-metal-ipi-ovn-ipv6 Low
[Jira:Node][sig-node] Node non-cnv swap configuration should reject user override of swap settings via KubeletConfig API [OCP-86395] [Suite:openshift/conformance/parallel]
This test has passed 38.68% of 287 runs on release 5.0 [Overall] in the last week.
pull-ci-openshift-origin-main-e2e-vsphere-ovn Low
[Jira:Node][sig-node] Node non-cnv swap configuration should reject user override of swap settings via KubeletConfig API [OCP-86395] [Suite:openshift/conformance/parallel]
This test has passed 38.46% of 13 runs on release 5.0 [Architecture:amd64 FeatureSet:default Installer:ipi JobTier:standard Network:ovn NetworkStack:ipv4 OS:rhcos9 Owner:eng Platform:vsphere Procedure:none SecurityMode:default Topology:ha Upgrade:none] in the last week.
pull-ci-openshift-origin-main-e2e-vsphere-ovn-upi Low
[Jira:Node][sig-node] Node non-cnv swap configuration should reject user override of swap settings via KubeletConfig API [OCP-86395] [Suite:openshift/conformance/parallel]
This test has passed 38.68% of 287 runs on release 5.0 [Overall] in the last week.

Copy link
Copy Markdown
Contributor

@fonta-rh fonta-rh left a comment

Choose a reason for hiding this comment

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

LGTM — clean diagnostic addition, follows existing patterns well.

Three optional nit-level suggestions inline (not blocking):

  1. os.Stat guard: err != nil catches all stat failures, not just "not found"
  2. Nil-guard on GetHypervisorConfig() return (defensive, matches a pre-existing gap in setupMinimalTestEnvironment)
  3. Comment clarifying relationship with deferDiagnosticsOnFailure

// Select the remaining index
targetNode = nodes.Items[(randomIndex+1)%len(nodes.Items)]

// Log final pcs and etcd status after every test (pass or fail) via SSH
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.

Nit: a reader seeing both this and deferDiagnosticsOnFailure in the It blocks may wonder about redundancy. Consider clarifying:

Suggested change
// Log final pcs and etcd status after every test (pass or fail) via SSH
// Log concise pcs and etcd status after every test (pass or fail) via SSH.
// Complements deferDiagnosticsOnFailure which gathers verbose diagnostics only on failure.

return
}

sshConfig := exutil.GetHypervisorConfig()
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.

Nit: HasHypervisorConfig() only checks that the config string is non-empty — if the JSON is malformed, GetHypervisorConfig() returns nil and the next line panics. Same gap exists in setupMinimalTestEnvironment (line 673), but a panic inside DeferCleanup is uglier since it fails the test.

Suggested change
sshConfig := exutil.GetHypervisorConfig()
sshConfig := exutil.GetHypervisorConfig()
if sshConfig == nil {
framework.Logf("Skipping final cluster status: failed to parse hypervisor config")
return
}

Comment on lines +801 to +804
if _, err := os.Stat(hypervisorConfig.PrivateKeyPath); os.IsNotExist(err) {
framework.Logf("Skipping final cluster status: private key not found at %s", hypervisorConfig.PrivateKeyPath)
return
}
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.

Nit: os.IsNotExist(err) only matches one specific stat error. If os.Stat fails with e.g. EACCES, the guard is false, execution continues, and SSH fails later with a misleading auth error. Checking err != nil is strictly better here.

Suggested change
if _, err := os.Stat(hypervisorConfig.PrivateKeyPath); os.IsNotExist(err) {
framework.Logf("Skipping final cluster status: private key not found at %s", hypervisorConfig.PrivateKeyPath)
return
}
if _, err := os.Stat(hypervisorConfig.PrivateKeyPath); err != nil {
framework.Logf("Skipping final cluster status: cannot access private key at %s: %v", hypervisorConfig.PrivateKeyPath, err)
return
}

@fonta-rh
Copy link
Copy Markdown
Contributor

fonta-rh commented Apr 8, 2026

/hold to leave time to address optional nits, feel free to /unhold

@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 Apr 8, 2026
@fonta-rh
Copy link
Copy Markdown
Contributor

fonta-rh commented Apr 8, 2026

/approve

@fonta-rh
Copy link
Copy Markdown
Contributor

fonta-rh commented Apr 8, 2026

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Apr 8, 2026
Address review feedback on PR openshift#30949:
- Guard against nil GetHypervisorConfig() return on malformed JSON
- Broaden os.Stat check from os.IsNotExist to err != nil
- Clarify logFinalClusterStatus vs deferDiagnosticsOnFailure roles

Applied to both logFinalClusterStatus and setupMinimalTestEnvironment.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@openshift-ci openshift-ci bot removed the lgtm Indicates that a PR is ready to be merged. label Apr 9, 2026
@fonta-rh
Copy link
Copy Markdown
Contributor

fonta-rh commented Apr 9, 2026

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Apr 9, 2026
Copy link
Copy Markdown

@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)

799-819: Extract the hypervisor SSH bootstrap into one helper.

Line 799 through Line 819 duplicate the same config-parse / core.SSHConfig population / key validation / known-hosts setup flow already in setupMinimalTestEnvironment at Line 679 onward. This PR already had to harden both paths the same way, so they’re likely to drift again. A small shared helper that returns a validated SSH config plus known-hosts path would keep the skip/fail behavior consistent in one place.

As per coding guidelines, "-Focus on major issues impacting performance, readability, maintainability and security. Avoid nitpicks and avoid verbosity."

🤖 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 799 - 819, Extract the
duplicated hypervisor SSH bootstrap sequence into a single helper (e.g.,
PrepareValidatedHypervisorSSH or GetValidatedHypervisorSSHConfig) that performs
exutil.GetHypervisorConfig(), populates and returns a core.SSHConfig, validates
the private key file (os.Stat), calls core.PrepareLocalKnownHostsFile and
returns the knownHostsPath and error; then replace the duplicated blocks in
tnf_recovery.go (the final-cluster-status skip block) and in
setupMinimalTestEnvironment with calls to this helper and propagate/handle its
error to keep skip/fail behavior consistent.
🤖 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 799-819: Extract the duplicated hypervisor SSH bootstrap sequence
into a single helper (e.g., PrepareValidatedHypervisorSSH or
GetValidatedHypervisorSSHConfig) that performs exutil.GetHypervisorConfig(),
populates and returns a core.SSHConfig, validates the private key file
(os.Stat), calls core.PrepareLocalKnownHostsFile and returns the knownHostsPath
and error; then replace the duplicated blocks in tnf_recovery.go (the
final-cluster-status skip block) and in setupMinimalTestEnvironment with calls
to this helper and propagate/handle its error to keep skip/fail behavior
consistent.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d09c518c-879a-4dce-8ebe-32cb7512c300

📥 Commits

Reviewing files that changed from the base of the PR and between d451f3c and fd1ba82.

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

@lucaconsalvi
Copy link
Copy Markdown
Contributor Author

Test results

Ran the double node failure (cold-boot) recovery test on a
fresh 4.22 nightly cluster:

Test should recover from a double node failure (cold-boot) [Requires:HypervisorSSHConfig]
Result ✅ PASSED
Duration ~4m8s
Cluster 2-node, OCP 4.22.0-0.nightly-2026-04-06-051707`

What was verified

  • setupMinimalTestEnvironment nil guard and broadened
    os.Stat check exercised without issues
  • logFinalClusterStatus fired in DeferCleanup after
    test completion
  • pcs status and etcd member list successfully collected
    via SSH from first reachable node
  • Loop correctly broke after both commands succeeded on
    the first node

Sample output from the new logging

========== FINAL CLUSTER STATUS ==========
pcs status from node master-1:

  • Online: [ master-0 master-1 ]
  • Clone Set: etcd-clone [etcd]:
    • Started: [ master-0 master-1 ]

etcd member list from node master-1:
| 3519e88796a78dca | started | master-1 | ... | false |
| 53a497614a730789 | started | master-0 | ... | false |
========== END FINAL CLUSTER STATUS ==========

@openshift-merge-bot
Copy link
Copy Markdown
Contributor

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

@lucaconsalvi
Copy link
Copy Markdown
Contributor Author

/unhold

@openshift-ci openshift-ci bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Apr 9, 2026
@jaypoulz
Copy link
Copy Markdown
Contributor

jaypoulz commented Apr 9, 2026

/approve
/lgtm

Thank you for putting this together! This will help a lot for CI debugging.

@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci bot commented Apr 9, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: fonta-rh, jaypoulz, lucaconsalvi

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:

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

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 9, 2026
@jaypoulz
Copy link
Copy Markdown
Contributor

jaypoulz commented Apr 9, 2026

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

@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci bot commented Apr 9, 2026

@jaypoulz: trigger 3 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-recovery-techpreview-1of3
  • periodic-ci-openshift-release-main-nightly-4.22-e2e-metal-ovn-two-node-fencing-recovery-techpreview-2of3
  • periodic-ci-openshift-release-main-nightly-4.22-e2e-metal-ovn-two-node-fencing-recovery-techpreview-3of3

See details on https://pr-payload-tests.ci.openshift.org/runs/ci/3312eb00-344d-11f1-9853-1c153a7c7070-0

@lucaconsalvi
Copy link
Copy Markdown
Contributor Author

/verified by lucaconsalvi

@openshift-ci-robot openshift-ci-robot added the verified Signifies that the PR passed pre-merge verification criteria label Apr 10, 2026
@openshift-ci-robot
Copy link
Copy Markdown

@lucaconsalvi: This PR has been marked as verified by lucaconsalvi.

Details

In response to this:

/verified by lucaconsalvi

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

openshift-ci bot commented Apr 10, 2026

@lucaconsalvi: 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.

@openshift-merge-bot openshift-merge-bot bot merged commit ea94b16 into openshift:main Apr 10, 2026
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged. verified Signifies that the PR passed pre-merge verification criteria

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants