Skip to content

fix: New resources now unblock waiting jobs immediately#1004

Merged
github-actions[bot] merged 2 commits intomasterfrom
fix/892-new-resource-unblocks-waiting-jobs
Apr 16, 2026
Merged

fix: New resources now unblock waiting jobs immediately#1004
github-actions[bot] merged 2 commits intomasterfrom
fix/892-new-resource-unblocks-waiting-jobs

Conversation

@mPokornyETM
Copy link
Copy Markdown
Contributor

Summary

When a new resource is added via createResourceWithLabel() or addResource(), waiting jobs now automatically pick it up instead of remaining blocked.

Fixes #892
See also: JENKINS-46744

Changes

Core fix in LockableResourcesManager.addResource():

  • Invalidate cachedCandidates when adding new resources
  • Process waiting pipeline contexts via proceedNextContext()
  • Call scheduleQueueMaintenance() to notify freestyle jobs
  • All cache/queue operations inside synchronized block to prevent race conditions

New public API:

  • refreshQueue() method for users who modify labels on existing resources (label changes don't auto-trigger re-evaluation)

Documentation:

  • Added "Dynamic resource behavior" section to README.md explaining limitations
  • New example file dynamic-resource-pool-expansion.md with usage patterns

Testing

  • newResourceWithLabelUnblocksWaitingPipelineJob() - Pipeline job waiting for label gets unblocked when matching resource is added
  • newResourceUnblocksWaitingFreestyleJob() - Freestyle job waiting for label gets unblocked when matching resource is added

Limitations documented

Modifying labels on existing resources does not automatically trigger queue re-evaluation. Users must call LockableResourcesManager.get().refreshQueue() manually after such changes.

When a new resource is added via createResourceWithLabel() or
addResource(), waiting jobs now automatically pick it up instead
of remaining blocked.

Changes:
- Invalidate cachedCandidates and process waiting pipeline contexts
  when adding new resources (inside synchronized block for atomicity)
- Call scheduleQueueMaintenance() to notify freestyle jobs
- Add refreshQueue() public method for users who modify labels on
  existing resources (label changes don't auto-trigger re-evaluation)
- Add documentation explaining dynamic resource behavior and limitations

Fixes #892
See also: JENKINS-46744
@mPokornyETM mPokornyETM requested a review from a team as a code owner April 13, 2026 19:53
@github-actions github-actions Bot added bug java Pull requests that update Java code documentation tests labels Apr 13, 2026
@mPokornyETM mPokornyETM added the merge-in-3-days-without-review Auto-approve countdown label Apr 13, 2026
@github-actions github-actions Bot added merge-in-2-days-without-review Auto-approve countdown and removed merge-in-3-days-without-review Auto-approve countdown labels Apr 14, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Auto-merge countdown: This PR will be auto-approved in 2 day(s) if no review is submitted.

@github-actions github-actions Bot added merge-in-1-day-without-review Auto-approve countdown and removed merge-in-2-days-without-review Auto-approve countdown labels Apr 15, 2026
@github-actions
Copy link
Copy Markdown
Contributor

⚠️ Auto-merge countdown: This PR will be auto-approved in 1 day(s) if no review is submitted.

@github-actions github-actions Bot removed the merge-in-1-day-without-review Auto-approve countdown label Apr 16, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Auto-approved: No review received within 3 days. Merging now.

@github-actions github-actions Bot added the merged-without-review Auto-approve countdown label Apr 16, 2026
Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Auto-approved: no review received within 3 days of opening.

@github-actions github-actions Bot merged commit 8be7238 into master Apr 16, 2026
21 checks passed
@github-actions github-actions Bot deleted the fix/892-new-resource-unblocks-waiting-jobs branch April 16, 2026 08:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug documentation java Pull requests that update Java code merged-without-review Auto-approve countdown tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[JENKINS-46744] Jobs waiting to lock resource could be searching for newly added resources

1 participant