add SEMAPHORE_AGENT_ASG_MAX_INSTANCE_LIFETIME#169
Merged
lucaspin merged 3 commits intorenderedtext:masterfrom Mar 31, 2025
Merged
add SEMAPHORE_AGENT_ASG_MAX_INSTANCE_LIFETIME#169lucaspin merged 3 commits intorenderedtext:masterfrom
lucaspin merged 3 commits intorenderedtext:masterfrom
Conversation
Contributor
|
/sem-approve |
Contributor
|
/sem-approve |
lucaspin
approved these changes
Mar 31, 2025
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.
Change description
This pull request introduces a new configuration option to set the maximum instance lifetime for the Semaphore agent auto-scaling group. This allows users to specify the maximum time an instance can exist before it must be terminated and replaced. This will help catch the scenario where an instance is in a bad state with the Semaphore agent not running and there isn't a way to recover it, other than manually terminating the instance. We see this sometimes happen if userdata fails to run properly (for example if the IMDS returns a 500 error, which also prevents the error handling self cleanup from running)
The default value is 0 which indicates no maximum lifetime. See https://docs.aws.amazon.com/autoscaling/ec2/userguide/asg-max-instance-lifetime.html for more details.
I considered an approach where the value would be determined programmatically as
SEMAPHORE_AGENT_DISCONNECT_AFTER_IDLE_TIMEOUT+ 24 hours (because 24 hours is the maximum during of a Semaphore job). However, I decided against it because that would have yielded more complicated conditional logic when onlySEMAPHORE_AGENT_DISCONNECT_AFTER_IDLE_TIMEOUTwas set and that approach wouldn't allow users to have as much control.Testing
added a unit test