fix: prevent duplicate ECS agent provisioning while JNLP agent is starting, #311, #416#432
Open
mslipets wants to merge 4 commits intojenkinsci:masterfrom
Open
fix: prevent duplicate ECS agent provisioning while JNLP agent is starting, #311, #416#432mslipets wants to merge 4 commits intojenkinsci:masterfrom
mslipets wants to merge 4 commits intojenkinsci:masterfrom
Conversation
Author
|
@Stericson Kindly requesting a review. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ECS agents use JNLP (agent-initiated connection), so they are invisible to Jenkins'
connectingExecutorsmetric while the container is starting up.This creates a gap: once the
PlannedNodefuture resolves (nearly instantly afterProvisioningCallbackreturns theECSSlave), the node is removed frompendingLaunchesbut isn't yet online.Every subsequent
ECSProvisioningStrategycycle - which fires every 10 seconds - seesexcessWorkload > 0and launches another duplicate ECS task.The fix accounts for offline
ECSSlavenodes matching the requested label as already-pending capacity, subtracting their executors fromexcessWorkloadbefore the provisioning loop.Failed agents are cleaned up by
ECSLauncher.launch()'s catch block (agent.terminate()), so they don't linger as false pending capacity.Fixes #311, #416
Testing done
5 automated tests added in
ECSProvisioningStrategyTestcovering:noOfflineECSNodes_provisionsWhenWorkloadExistsofflineECSNodeMatchingLabel_suppressesProvisioningofflineECSNodeDifferentLabel_provisionsNormallyofflineECSNodeCoversPartOfWorkload_provisionsRemaindermultipleOfflineECSNodesCoversWorkload_suppressesProvisioningAll 43 tests pass on Java 21 (
BUILD SUCCESS, 3 pre-existing@Ignoreskips inECSServiceTest).Submitter checklist