jenkinsci / jenkinsci/lockable-resources-plugin
Pipeline: Locking multiple resources in one job and single resources in others breaks locking
- Dominant language
- Java
- Stars
- 99
- Forks
- 205
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 8
Description
### Version report
Jenkins and plugins versions report:
```
Jenkins: 2.289.3
OS: Linux - 4.14.238-182.422.amzn2.x86_64
---
blueocean-git-pipeline:1.24.8
blueocean-pipeline-editor:1.24.8
pipeline-stage-tags-metadata:1.9.1
lockable-resources:2.11
ansicolor:1.0.0
jdk-tool:1.0
command-launcher:1.2
jaxb:2.3.0
blueocean-autofavorite:1.2.4
checks-api:1.7.2
bouncycastle-api:2.20
locale:1.4
ec2-fleet:2.3.3
workflow-cps-global-lib:2.21
font-awesome-api:5.15.3-4
javadoc:1.6
github-branch-source:2.11.2
durable-task:1.39
echarts-api:5.1.2-9
blueocean-bitbucket-pipeline:1.24.8
variant:1.4
workflow-support:3.8
run-condition:1.5
structs:1.23
docker-commons:1.17
blueocean-github-pipeline:1.24.8
gradle:1.37.1
pubsub-light:1.16
apache-httpcomponents-client-4-api:4.5.13-1.0
configuration-as-code:1.51
git-client:3.9.0
okhttp-api:3.14.9
git:4.8.1
popper2-api:2.9.3-1
pipeline-model-definition:1.9.1
groovy-postbuild:2.5
blueocean-jwt:1.24.8
aws-secrets-manager-credentials-provider:0.5.3
badge:1.8
azure-ad:155.v745ce80af7ea
docker-workflow:1.26
github:1.33.1
sshd:3.1.0
blueocean-i18n:1.24.8
blueocean-commons:1.24.8
pipeline-stage-view:2.19
pipeline-input-step:2.12
ace-editor:1.1
caffeine-api:2.9.2-29.v717aac953ff3
github-api:1.123
influxdb:3.0.2
ssh-slaves:1.32.0
pipeline-stage-step:2.5
maven-plugin:3.12
workflow-cps:2.93
copyartifact:1.46.1
parameterized-trigger:2.41
rebuild:1.32
blueocean-pipeline-scm-api:1.24.8
trilead-api:1.0.13
bootstrap5-api:5.1.0-1
xvfb:1.2
blueocean-config:1.24.8
workflow-step-api:2.24
authentication-tokens:1.4
popper-api:1.16.1-2
envinject:2.4.0
envinject-api:1.7
workflow-api:2.46
junit:1.52
blueocean-personalization:1.24.8
momentjs:1.1.1
workflow-multibranch:2.26
jquery3-api:3.6.0-2
workflow-durable-task-step:2.39
handlebars:3.0.8
pipeline-build-step:2.15
jsch:0.1.55.2
jackson2-api:2.12.4
jjwt-api:0.11.2-9.c8b45b8bb173
workflow-scm-step:2.13
token-macro:266.v44a80cf277fd
blueocean-events:1.24.8
pipeline-model-extensions:1.9.1
cloudbees-bitbucket-branch-source:2.9.10
bootstrap4-api:4.6.0-3
antisamy-markup-formatter:2.1
script-security:1.78
blueocean-core-js:1.24.8
blueocean-rest-impl:1.24.8
blueocean-display-url:2.4.1
aws-java-sdk:1.11.995
git-server:1.10
pipeline-model-api:1.9.1
blueocean-rest:1.24.8
workflow-basic-steps:2.23
ssh-credentials:1.19
workflow-job:2.41
workflow-aggregator:2.6
credentials-binding:1.27
handy-uri-templates-2-api:2.1.8-1.0
favorite:2.3.3
aws-credentials:1.30
pipeline-rest-api:2.19
matrix-auth:2.6.8
blueocean-web:1.24.8
credentials:2.5
plain-credentials:1.7
snakeyaml-api:1.29.1
branch-api:2.6.5
pipeline-graph-analysis:1.11
conditional-buildstep:1.4.1
blueocean-dashboard:1.24.8
greenballs:1.15.1
blueocean-pipeline-api-impl:1.24.8
cloudbees-folder:6.16
sse-gateway:1.24
matrix-project:1.19
pipeline-milestone-step:1.3.2
config-file-provider:3.8.1
scm-api:2.6.5
blueocean:1.24.8
jenkins-design-language:1.24.8
display-url-api:2.3.5
job-dsl:1.77
plugin-util-api:2.4.0
htmlpublisher:1.25
mailer:1.34
```
- What Operating System are you using (both controller, and any agents involved in the problem)?
```
Linux on both the controller and the agents
```
### Reproduction steps
1. Create the following pipeline script jobs:
```
job-1:
node {
stage('lock') {
lock(resource: 'resource-1', variable: 'LOCKED_RESOURCE') {
echo env.LOCKED_RESOURCE
input 'continue?'
}
}
}
job-2:
node {
stage('lock') {
lock(resource: 'resource-2', variable: 'LOCKED_RESOURCE') {
echo env.LOCKED_RESOURCE
input 'continue?'
}
}
}
job-all:
node {
stage('lock') {
lock(extra: [[resource: 'resource-1'], [resource: 'resource-2']], variable: 'LOCKED_RESOURCE') {
echo env.LOCKED_RESOURCE
input 'continue?'
}
}
}
```
2. Start a build of job-1 and job-2, they will take the locks and wait for your input
3. Start a build of job-all, it will wait for the locks to be available
4. Finish the build of job-1 by selecting "proceed" at the "continue?" input query
5. Finish the build of job-2 by selecting "proceed" at the "continue?" input query
6. Notice that the build of job-all is now also waiting for your input. Now look at the https://.../lockable-resources/ overview.
### Results
Expected result:
Resources resource-1 and resource-2 should be shown as locked by the job-all build.
Actual result:
Only the last released resource, resource-2 in the above example, is shown as locked by the job-all build.
(To be clear: The lockable resources overview appears to correctly display the internal state. The issue is not the incorrect _display_ of the locked resource. If you start another build of job-1 it will immediately grab resource-1 even if the build of job-all is still running.)
### Things I tried
- I could not reproduce the problem if all to-be-locked resources are released at the same time, e.g. two builds of job-all correctly create/lock/release/destroy resource-1 and resource-2 when run concurrently.
- I could not reproduce the problem if the locked resources are created in advance, i.e. the problem only appears to affect ephemeral resources.
Contributor guide
Research direction
Start by reproducing the three pipeline jobs and the sequential release steps described in the issue, then inspect the lockable-resources overview and internal resource state. Done means that after job-1 and job-2 release their resources, job-all retains both resource-1 and resource-2 exclusively until its build finishes, including for ephemeral resources.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- ci-cd, devops
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 42/100