Skip to content

DPTP-4077: Always run post steps on cancellation to prevent resource leaks#4920

Open
deepsm007 wants to merge 2 commits intoopenshift:mainfrom
deepsm007:fix-post-deprovision
Open

DPTP-4077: Always run post steps on cancellation to prevent resource leaks#4920
deepsm007 wants to merge 2 commits intoopenshift:mainfrom
deepsm007:fix-post-deprovision

Conversation

@deepsm007
Copy link
Contributor

/cc @openshift/test-platform

@openshift-ci-robot
Copy link
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: automatic mode

@openshift-ci openshift-ci bot requested a review from a team February 2, 2026 19:30
@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Feb 2, 2026
@openshift-ci-robot
Copy link
Contributor

openshift-ci-robot commented Feb 2, 2026

@deepsm007: This pull request references DPTP-4077 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:

/cc @openshift/test-platform

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

coderabbitai bot commented Feb 2, 2026

Walkthrough

Adds phase tracking to multi-stage test execution: new exported label constant, a phase field on pod-generation options that labels created Pods when set, and a refactored Run flow that records pre/test errors separately, detects cancellation during pre/test, and guarantees post-phase execution (using background context when cancelled).

Changes

Cohort / File(s) Summary
Phase-aware pod generation
pkg/steps/multi_stage/gen.go, pkg/steps/multi_stage/run.go
Added optional phase string to generatePodOptions and pass it from run logic; when non-empty, generated Pods are labeled with MultiStageTestPhaseLabel. Also added synchronization (s.subLock) when appending s.subTests.
Phase tracking and execution flow
pkg/steps/multi_stage/multi_stage.go
Added exported constant MultiStageTestPhaseLabel = "ci.openshift.io/multi-stage-test-phase". Refactored Run to separate pre/test error capture, detect cancellation during pre/test phases, and ensure post runs unconditionally (using background context if cancelled), with adjusted logging and aggregated errors.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 2, 2026
@hector-vido
Copy link
Contributor

/lgtm

@openshift-ci openshift-ci bot added lgtm Indicates that a PR is ready to be merged. and removed lgtm Indicates that a PR is ready to be merged. labels Feb 2, 2026
@deepsm007 deepsm007 force-pushed the fix-post-deprovision branch from de15f69 to cf901c9 Compare February 2, 2026 20:14
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: 1

🤖 Fix all issues with AI agents
In `@pkg/steps/multi_stage/multi_stage.go`:
- Around line 248-288: The post steps always use context.Background() which
ignores job deadlines/cancellation; change postCtx to use the original ctx by
default and only switch to context.Background() when cancelledDuringPreOrTest is
true: set postCtx := ctx, and if cancelledDuringPreOrTest then set postCtx =
context.Background(); then call s.runSteps(postCtx, "post", s.post, ...) so post
steps respect the original deadline/cancellation unless a prior cancellation
occurred. Ensure this change is applied around the existing
cancelledDuringPreOrTest, postCtx, and runSteps usage (refer to
cancelledDuringPreOrTest, postCtx, runSteps, cancelObserversContext, s.name).

@hector-vido
Copy link
Contributor

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Feb 2, 2026
@deepsm007
Copy link
Contributor Author

/hold

@openshift-ci openshift-ci bot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. and removed lgtm Indicates that a PR is ready to be merged. labels Feb 2, 2026
@deepsm007 deepsm007 force-pushed the fix-post-deprovision branch from 32d1d0c to aafadc2 Compare February 2, 2026 21:10
@deepsm007
Copy link
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 Feb 2, 2026
@openshift-ci-robot
Copy link
Contributor

Scheduling required tests:
/test e2e

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Feb 3, 2026
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Feb 3, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: deepsm007, hector-vido, liangxia

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 [deepsm007,hector-vido,liangxia]

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

@openshift-ci-robot
Copy link
Contributor

/retest-required

Remaining retests: 0 against base HEAD 4188be3 and 2 for PR HEAD aafadc2 in total

@deepsm007
Copy link
Contributor Author

/hold

@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 Feb 3, 2026
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Feb 3, 2026

@deepsm007: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/breaking-changes aafadc2 link false /test breaking-changes

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.

@petr-muller
Copy link
Member

/cc

@openshift-ci openshift-ci bot requested a review from petr-muller February 3, 2026 13:23
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. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants