jenkinsci / jenkinsci/branch-api-plugin
[JENKINS-67754] Incorrect usage of rateLimit.count in multibranchPipelineJob
- Dominant language
- Java
- Stars
- 39
- Forks
- 154
- PR merge metrics
- No merged PRs in 30d
Description
There is a multibranchPipelineJob DSL configured with rateLimit to throttle builds:
multibranchPipelineJob('testJob') {
...
branchSources {
branchSource {
strategy {
allBranchesSame {
props {
rateLimit {
// The maximum number of builds allowed within the specified time period.
count(5)
// The time period within which the maximum number of builds will be enforced.
durationName('hour')
// Enable this option to permit user triggered builds to skip the rate limit.
userBoost(true)
}
}
}
}
}
}
...
}
The job's config.xml and also the branch jobs' config.xml shows the correct settings:
hour
5
true
After changing the value of count in DSL, the jenkins.branch.RateLimitBranchProperty shows the new, correct settings in config.xml.
But when running the new builds, it uses the previous count as logged:
Feb 08, 2022 11:20:40 AM FINER jenkins.branch.RateLimitBranchProperty
test-job/test-branch has a rate limit of 5 builds per hour
What is suspicious, is that the branch job's config.xml contains duplicated sections of :
...
"branch-api@2.7.0">
hour
5
true
"branch-api@2.7.0">
hour
12
true
...
I can see the previous and current settings in the branch job's config.xml, but when I start a new build again, this section duplicates again and still uses the older, incorrect count setting (maybe the first in order):
...
"branch-api@2.7.0">
hour
5
true
"branch-api@2.7.0">
hour
12
true
"branch-api@2.7.0">
hour
12
true
...
---
Originally reported by drubitsa, imported from: Incorrect usage of rateLimit.count in multibranchPipelineJob
Raw content of original issue
There is a multibranchPipelineJob DSL configured with rateLimit to throttle builds:
multibranchPipelineJob('testJob') {
...
branchSources {
branchSource {
strategy {
allBranchesSame {
props {
rateLimit {
// The maximum number of builds allowed within the specified time period.
count(5)
// The time period within which the maximum number of builds will be enforced.
durationName('hour')
// Enable this option to permit user triggered builds to skip the rate limit.
userBoost(true)
}
}
}
}
}
}
...
}The job's config.xml and also the branch jobs' config.xml shows the correct settings:
<jenkins.branch.RateLimitBranchProperty>
<durationName>hour</durationName>
<count>5</count>
<userBoost>true</userBoost>
</jenkins.branch.RateLimitBranchProperty>After changing the value of count in DSL, the jenkins.branch.RateLimitBranchProperty shows the new, correct settings in config.xml.
But when running the new builds, it uses the previous count as logged:
Feb 08, 2022 11:20:40 AM FINER jenkins.branch.RateLimitBranchProperty
test-job/test-branch has a rate limit of 5 builds per hourWhat is suspicious, is that the branch job's config.xml contains duplicated sections of <jenkins.branch.RateLimitBranchProperty_-JobPropertyImpl:
...
<jenkins.branch.RateLimitBranchProperty_-JobPropertyImpl plugin="branch-api@2.7.0">
<durationName>hour</durationName>
<count>5</count>
<userBoost>true</userBoost>
</jenkins.branch.RateLimitBranchProperty_-JobPropertyImpl>
<jenkins.branch.RateLimitBranchProperty_-JobPropertyImpl plugin="branch-api@2.7.0">
<durationName>hour</durationName>
<count>12</count>
<userBoost>true</userBoost>
</jenkins.branch.RateLimitBranchProperty_-JobPropertyImpl>
...I can see the previous and current settings in the branch job's config.xml, but when I start a new build again, this section duplicates again and still uses the older, incorrect count setting (maybe the first in order):
...
<jenkins.branch.RateLimitBranchProperty_-JobPropertyImpl plugin="branch-api@2.7.0">
<durationName>hour</durationName>
<count>5</count>
<userBoost>true</userBoost>
</jenkins.branch.RateLimitBranchProperty_-JobPropertyImpl>
<jenkins.branch.RateLimitBranchProperty_-JobPropertyImpl plugin="branch-api@2.7.0">
<durationName>hour</durationName>
<count>12</count>
<userBoost>true</userBoost>
</jenkins.branch.RateLimitBranchProperty_-JobPropertyImpl>
<jenkins.branch.RateLimitBranchProperty_-JobPropertyImpl plugin="branch-api@2.7.0">
<durationName>hour</durationName>
<count>12</count>
<userBoost>true</userBoost>
</jenkins.branch.RateLimitBranchProperty_-JobPropertyImpl>
...
environment
```
Jenkins version: 2.330
Branch API plugin: 2.7.0
Job DSL plugin: 1.78.3
GitLab plugin: 1.5.26
```
Contributor guide
Research direction
Start by tracing RateLimitBranchProperty and its JobPropertyImpl in the branch-api plugin, focusing on how multibranchPipelineJob settings become branch-job config.xml entries. Reproduce the count change and inspect the generated XML and build logging. Done means duplicate properties are not generated and new builds use the updated count.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100