Skip to content

JENKINS-66373: idle timeout should not fight with min spare instances setting#945

Open
sparrowt wants to merge 1 commit intojenkinsci:masterfrom
sparrowt:patch-2
Open

JENKINS-66373: idle timeout should not fight with min spare instances setting#945
sparrowt wants to merge 1 commit intojenkinsci:masterfrom
sparrowt:patch-2

Conversation

@sparrowt
Copy link
Copy Markdown
Contributor

@sparrowt sparrowt commented Mar 6, 2024

The problem

Currently if you use the "Minimum number of spare instances" setting as well as "Idle termination time", then there is a constant battle going on between:

  • MinimumInstanceChecker.checkForMinimumInstances provisioning new agents to try and maintain the minimum number of spare instances as configured
  • however the idle timeout checks in this method are killing off the 'spare' instances once they reach the idle termination time

This means that the spare instances are repeatedly killed & recreated as described on https://issues.jenkins.io/browse/JENKINS-66373 which is wasteful and means that, some percentage of the time, there are never enough spare instances because they are being booted (again).

Solution

This PR makes a simple change to the idle termination logic so that it takes account of "Minimum number of spare instances" in the same way that it already accounts for the main "Minimum number of instances" setting.

Testing done

None yet - EC2RetentionStrategyTest.java seems like the right place to add a test case for this specific scenario.

Right now I've got very limited time and wanted to at least get the proposed fix up for discussion to start with.

### Submitter checklist
- [x] Make sure you are opening from a **topic/feature/bugfix branch** (right side) and not your main branch!
- [x] Ensure that the pull request title represents the desired changelog entry
- [x] Please describe what you did
- [x] Link to relevant issues in GitHub or Jira
- [ ] Link to relevant pull requests, esp. upstream and downstream changes
- [ ] Ensure you have provided tests - that demonstrates feature works or fixes the issue

… setting

Prior to this change, if you use "Minimum number of spare instances" setting as well as "Idle termination time", then there is a constant battle going on between:
- `checkForMinimumInstances` trying to maintain the minimum spare instances as requested
- the idle timeout checks in this method are killing off the 'spare' instances

Make this method take account of "Minimum number of _spare_ instances" in the same way that it already accounts for the main "Minimum number of instances" setting.
@sparrowt
Copy link
Copy Markdown
Contributor Author

@res0nance who would be good to have an initial review of this?

@res0nance
Copy link
Copy Markdown
Contributor

@res0nance who would be good to have an initial review of this?

Could you add some unit tests for this change?

@jperez3
Copy link
Copy Markdown

jperez3 commented Mar 31, 2025

@sparrowt @res0nance I'm running into something similar, any thoughts on getting this updated/reviewed? 🙏🏽

@sparrowt
Copy link
Copy Markdown
Contributor Author

Hi folks I'm afraid I don't have time right now to add tests (much as I approve that this would be a good idea!)

If others are keen for this too I'm open to contributions in a PR against my branch

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants