-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ensure capacity does not exceed ASG MaxSize #35
Conversation
Thanks @nitrocode, we'll give this a test run and get back to you 🙏 |
after this is tested and merged, could we have a new release We're eager to get past this issue. For now to be safe, we've raised all of our ASG |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this @nitrocode.
It'd be great to avoid the extra API call to fetch the ASG state, and I just noticed that we have existing code for capping the scale out to MaxSize:
buildkite-agent-scaler/scaler/scaler.go
Lines 118 to 124 in 12d9dfb
if desired > current.MaxSize { | |
log.Printf("⚠️ Desired count exceed MaxSize, capping at %d", current.MaxSize) | |
desired = current.MaxSize | |
} else if desired < current.MinSize { | |
log.Printf("⚠️ Desired count is less than MinSize, capping at %d", current.MinSize) | |
desired = current.MinSize | |
} |
Unfortunately, that capping happens before the scale factors are applied.
I haven't explored this idea fully or tested it, but what do you think about moving the application of the scale factors (in and out) to happen before the capping process? Maybe as an extra unexported function like this:
diff --git a/scaler/scaler.go b/scaler/scaler.go
index b6a4334..6f5bcef 100644
--- a/scaler/scaler.go
+++ b/scaler/scaler.go
@@ -115,6 +115,12 @@ func (s *Scaler) Run() (time.Duration, error) {
return metrics.PollDuration, err
}
+ if desired > current {
+ desired = s.applyScaleOutFactor(desired)
+ } else if desired < current {
+ desired = s.applyScaleInFactor(desired)
+ }
+
if desired > current.MaxSize {
log.Printf("⚠️ Desired count exceed MaxSize, capping at %d", current.MaxSize)
desired = current.MaxSize
Sure, sounds better than making another api call I suppose. As long as it works, I'm happy. |
I reverted my change and added yours. Are there any unit or integration tests that can be run on this? @yob |
Thanks @nitrocode 🙏 We ended up extending this PR with a slightly different solution to the one I suggested, and added some unit tests in #37. |
Perfect! Thanks @yob Could we get this released as part of a 5.0 beta 2 for the elastic ci stack? |
yup, that's the plan 👍 |
Closes #34
@yob