Skip to content

Finalize recovered CPS executions with no threads#1793

Open
AnantSingh1510 wants to merge 1 commit into
jenkinsci:masterfrom
AnantSingh1510:master
Open

Finalize recovered CPS executions with no threads#1793
AnantSingh1510 wants to merge 1 commit into
jenkinsci:masterfrom
AnantSingh1510:master

Conversation

@AnantSingh1510

@AnantSingh1510 AnantSingh1510 commented Jun 16, 2026

Copy link
Copy Markdown

Handle an unrecoverable Pipeline state where a CpsFlowExecution is restored with no CPS threads while its flow graph is still non-terminal.

When this happens, there is nothing for Pipeline to resume or interrupt, but the owning WorkflowRun can still remain marked as building. Treat an empty restored CpsThreadGroup on a non-complete execution as a program load failure, so the existing recovery path finalizes the run as FAILURE instead of leaving it stuck.

This also moves the done = true assignment in placeholder node creation until after the fallback nodes/actions are created, avoiding action persistence warnings on that path.

Fixes #1792

Testing done

Added PersistenceProblemsTest#inProgressWithStepEndHeadButNoCpsThreads.

The test creates the persisted state directly:

  1. Run a simple Pipeline to completion.
  2. Move the persisted flow head back to a StepEndNode.
  3. Clear the WorkflowRun completion/result state.
  4. Save an empty CpsThreadGroup to program.dat.
  5. Simulate a hard Jenkins restart.
  6. Verify the build is recovered as FAILURE.

Ran locally:

export JAVA_HOME=$(/opt/homebrew/bin/brew --prefix openjdk)/libexec/openjdk.jdk/Contents/Home
/opt/homebrew/bin/mvn -ntp -pl plugin -Dtest=PersistenceProblemsTest#inProgressWithStepEndHeadButNoCpsThreads test

Result:

Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
BUILD SUCCESS

Related pull requests: none.

Submitter checklist

  • Make sure you are opening from a topic/feature/bugfix branch (right side) and not your main branch!
  • Ensure that the pull request title represents the desired changelog entry
  • Please describe what you did
  • Link to relevant issues in GitHub or Jira
  • Link to relevant pull requests, esp. upstream and downstream changes
  • Ensure you have provided tests that demonstrate the feature works or the issue is fixed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pipeline build remains stuck after recovery with StepEndNode head and no executor

1 participant