Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resubmitted build uses the parameters of the last build instead of the failed build #335

Closed
benipeled opened this issue May 1, 2022 · 3 comments

Comments

@benipeled
Copy link

Issue Details

In case of spot termination, a new build is submitted with the last build parameters

if (task instanceof WorkflowJob) {
final WorkflowRun failedBuild = ((WorkflowJob) task).getLastBuild();
actions.addAll(failedBuild.getActions(ParametersAction.class));
}

But... in the case of multiple builds, the last one is not necessarily the build that should be rebuilt, which causes the resubmitted job uses incorrect parameters.

To Reproduce

  1. Trigger a workflow job with parameters
  2. Trigger another workflow job with parameters
  3. Terminate the instance used for the 1st build - a new build should be added to the queue
  4. Check the new build parameters - it will be the 2nd build parameters instead of the 1st one.

Environment Details

Plugin Version?
2.5.1

Jenkins Version?
2.343

Spot Fleet or ASG?
Spot Fleet

Label based fleet?
Yes

Linux or Windows?
Linux

@benipeled benipeled added the bug label May 1, 2022
@benipeled benipeled changed the title The resubmitted build uses the parameters of the last build instead of the failed build Resubmitted build uses the parameters of the last build instead of the failed build May 1, 2022
@haugenj haugenj added the stalebot-ignore To NOT let the stalebot update or close the Issue / PR label May 24, 2022
@sebek64
Copy link

sebek64 commented Nov 16, 2022

I've seen the same issue. Basically, without this being fixed, spot workers with auto-retry are usable only for non-parameterized builds. For anything more sophisticated like pull-requests checks, you cannot rely on it. Any chance this will be fixed? Or should I just provide a patch?

@sebek64
Copy link

sebek64 commented Nov 16, 2022

As already written in the original report, the problem is on this line:

final WorkflowRun failedBuild = ((WorkflowJob) task).getLastBuild();

One can call getLastFailedBuild instead of getLastBuild, that would work better in some cases, but it is not perfect either. To me, it seems that jenkins api doesn't provide the means to properly resubmit the failed job.

@pdk27 pdk27 added good first issue and removed stalebot-ignore To NOT let the stalebot update or close the Issue / PR labels Jun 28, 2023
@naraharip2017 naraharip2017 self-assigned this Jul 10, 2023
@naraharip2017 naraharip2017 mentioned this issue Jul 18, 2023
@pdk27 pdk27 closed this as completed in efbed25 Aug 23, 2023
@benipeled
Copy link
Author

@naraharip2017, @pdk27 thanks for the work done on efbed25 but I believe we should reopen this issue since it's not resolved the described issue,

The getLastFailedBuild() fixed will work only in the case of two builds while in our case it might be 10 different builds running in parallel (maybe I should've clarified that above) and the last failure might be a later job and not the one with the spot-termination event,

In addition, in our case, spot-termination marks the pipeline as ABORTED and not FAILURE which I'm not sure if it's caught by the getLastFailedBuild() function,

IMO, the resubmit feature should look for the exact fail-build, gather the parameters, and trigger a new one with those parameters, WDYT?

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

No branches or pull requests

5 participants