jenkinsci / jenkinsci/rake-plugin

Rake can be run on the wrong executor if concurrent builds are enabled

Open
#18 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
12
Forks
28
PR merge metrics
No merged PRs in 30d

Description

Rake can be scheduled on the wrong machine.

To reproduce:
- Create a job with "Execute concurrent builds if necessary" enabled
- Add build steps:
- Shell build step: `echo 'task(:default) { puts `hostname`; sleep 8 }' > Rakefile`
- A few rake build steps (e.g. 5) with all options as default
- Ensure you have enough executors available, on different hosts, to run at least two instances of the job at once
- Trigger the job several times
- In the logs, observe that rake may switch between hosts during the build, as in the following example:

```
Started by user Rohan McGovern
Started by user Rohan McGovern
[EnvInject] - Loading node environment variables.
Building remotely on rmcgover-ws-02 (docker) in workspace /home/jenkins/workspace/rake test
[rake test] $ /bin/sh -xe /tmp/hudson1005075034362718171.sh
+ echo 'task(:default) { puts `hostname`; sleep 8 }'
[rake test] $ /usr/bin/rake
dd8166383c1d
[rake test] $ /usr/bin/rake
dd8166383c1d
[rake test] $ /usr/bin/rake
5ea60c3d5e02
[rake test] $ /usr/bin/rake
5ea60c3d5e02
[rake test] $ /usr/bin/rake
5ea60c3d5e02
[rake test] $ /usr/bin/rake
5ea60c3d5e02
Finished: SUCCESS
```

I'm not too familiar with Jenkins' APIs, but to me, this code in Rake.java looks suspicious:

```
private Launcher getLastBuiltLauncher(AbstractBuild build, Launcher launcher, BuildListener listener) {
AbstractProject project = build.getProject();
Node lastBuiltOn = project.getLastBuiltOn();
Launcher lastBuiltLauncher = launcher;
if (lastBuiltOn != null) {
lastBuiltLauncher = lastBuiltOn.createLauncher(listener);
}

return lastBuiltLauncher;
}
```

... since the value of project.getLastBuiltOn() presumably can change during a build.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.