Skip to content

OCPBUGS-59311: must-gather: Handle signals properly#2237

Merged
openshift-merge-bot[bot] merged 1 commit intoopenshift:mainfrom
tchap:must-gather-handle-signals
Mar 30, 2026
Merged

OCPBUGS-59311: must-gather: Handle signals properly#2237
openshift-merge-bot[bot] merged 1 commit intoopenshift:mainfrom
tchap:must-gather-handle-signals

Conversation

@tchap
Copy link
Copy Markdown
Contributor

@tchap tchap commented Mar 23, 2026

Since RunLogsContext is available now after rebase, I am finishing this issue.

@openshift-ci-robot openshift-ci-robot added jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. labels Mar 23, 2026
@openshift-ci-robot
Copy link
Copy Markdown

@tchap: This pull request references Jira Issue OCPBUGS-59311, which is invalid:

  • expected the bug to target either version "4.22." or "openshift-4.22.", but it targets "4.21" instead

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:

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 Mar 23, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: 2e8d721d-ff48-4a79-8238-92dbfc56246b

📥 Commits

Reviewing files that changed from the base of the PR and between 5fc4a6b and d10aa25.

📒 Files selected for processing (1)
  • pkg/cli/admin/mustgather/mustgather.go

Walkthrough

Modified signal handling and context management in the mustgather operation. Introduced OS signal-aware context using signal.NotifyContext to gracefully handle interrupt and termination signals. Refined error handling to suppress logging of context cancellation errors and updated container log retrieval to use context-aware methods.

Changes

Cohort / File(s) Summary
Signal-aware context management
pkg/cli/admin/mustgather/mustgather.go
Added signal.NotifyContext for os.Interrupt and syscall.SIGTERM handling in MustGatherOptions.Run(). Removed warning message when context is already canceled. Modified processNextWorkItem() to suppress logging of context.Canceled errors from getGatherContainerLogs(). Updated container log retrieval to call opts.RunLogsContext(ctx) instead of opts.RunLogs().

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

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

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

@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 Mar 23, 2026
@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci bot commented Mar 23, 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

@tchap tchap force-pushed the must-gather-handle-signals branch from 089ce25 to d10aa25 Compare March 23, 2026 10:41
@tchap tchap marked this pull request as ready for review March 23, 2026 10:42
@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 Mar 23, 2026
@openshift-ci openshift-ci bot requested review from ardaguclu and ingvagabund March 23, 2026 10:43
@tchap
Copy link
Copy Markdown
Contributor Author

tchap commented Mar 23, 2026

/jira refresh

@openshift-ci-robot openshift-ci-robot added jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. and removed jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. labels Mar 23, 2026
@openshift-ci-robot
Copy link
Copy Markdown

@tchap: This pull request references Jira Issue OCPBUGS-59311, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (4.22.0) matches configured target version for branch (4.22.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, POST)

No GitHub users were found matching the public email listed for the QA contact in Jira (yinzhou@redhat.com), skipping review request.

Details

In response to this:

/jira refresh

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.

@tchap
Copy link
Copy Markdown
Contributor Author

tchap commented Mar 23, 2026

/verified by @tchap

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

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

Details

In response to this:

/verified by @tchap

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.

}
// stream gather container logs
if err := o.getGatherContainerLogs(ctx, pod); err != nil {
log("gather logs unavailable: %v", err)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I found this message extra when sending SIGINT.

@ardaguclu
Copy link
Copy Markdown
Member

/hold
K8s bump is reverted

@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 Mar 23, 2026
@ardaguclu
Copy link
Copy Markdown
Member

Once #2241 merges, this PR can be ready for review

defer func() {
// Shortcircuit this in case the context is already cancelled.
if ctx.Err() != nil {
klog.Warning("Reprinting cluster state skipped, terminating...")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this removal necessary?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It's not necessary, but when you actually send an interrupt, this message doesn't feel like it adds any value.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is it possible that we check the error type in ctx.Err and ignore this log only when user interrupts?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

ctx.Err is not gonna give enough information, it's canceled on a signal and there is no other way it can be canceled. If you want to particularly skip on os.Interrupt, it can be done.

@ardaguclu
Copy link
Copy Markdown
Member

That looks good to me. Thank you
/lgtm
/approve
/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 Mar 30, 2026
@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Mar 30, 2026
@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci bot commented Mar 30, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ardaguclu, tchap

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 Mar 30, 2026
@tchap
Copy link
Copy Markdown
Contributor Author

tchap commented Mar 30, 2026

/verified by @tchap

@openshift-ci-robot
Copy link
Copy Markdown

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

Details

In response to this:

/verified by @tchap

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

/retest-required

Remaining retests: 0 against base HEAD c268e49 and 2 for PR HEAD d10aa25 in total

@tchap
Copy link
Copy Markdown
Contributor Author

tchap commented Mar 30, 2026

/retest

@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci bot commented Mar 30, 2026

@tchap: 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 bb4c3de into openshift:main Mar 30, 2026
17 checks passed
@openshift-ci-robot
Copy link
Copy Markdown

@tchap: Jira Issue Verification Checks: Jira Issue OCPBUGS-59311
✔️ This pull request was pre-merge verified.
✔️ All associated pull requests have merged.
✔️ All associated, merged pull requests were pre-merge verified.

Jira Issue OCPBUGS-59311 has been moved to the MODIFIED state and will move to the VERIFIED state when the change is available in an accepted nightly payload. 🕓

Details

In response to this:

Since RunLogsContext is available now after rebase, I am finishing this issue.

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

approved Indicates a PR has been approved by an approver from all required OWNERS files. jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. 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.

3 participants