-
Notifications
You must be signed in to change notification settings - Fork 21
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
Prepare delayed downscale #131
Merged
Merged
Conversation
This file contains 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
pracucci
approved these changes
Feb 5, 2024
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.
Great work and very nice test! I left few minor comments only. Thanks!
Thanks for review, I've applied all your suggestions. |
pstibrany
added a commit
that referenced
this pull request
Feb 7, 2024
pstibrany
added a commit
that referenced
this pull request
Feb 7, 2024
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.
This PR adds support for downscale delay when using reference resource as a source of number of replicas.
Two annotations are used for configuration:
grafana.com/rollout-delayed-downscale
grafana.com/rollout-prepare-delayed-downscale-url
.How it works: When rollout-operator detects that statefulset configured with these annotations should be scaled down, it first calls
POST <URL>
on all pods that should be scaled down. Pods are expected to prepare for scaledown and return timestamp when such preparation happened (possibly in the past). Any errors from these calls (networking, non-200 status code, invalid JSON object) will cause that downscale is aborted (and retried later, if scaledown condition is still true).Operator then computes Maximum of returned timestamps. If this maximum is in the past for more than "delay duration", scaledown proceeds. Otherwise, scaledown is not allowed at this point, and will be retried later.
All other pods that are NOT going to be scaled down also receive HTTP request to given URL, however with
DELETE
method. This tells pod to "cancel" any possible preparation for scaledown in the past.For example, if statefulset has 100 pods, and 30 of them are going to be scaled down, then pods from 0 to 69 receive
DELETE <url>
call, while pods 70 .. 99 receivePOST <url>
call.If rollout operator detects no change of replicas, or scale up, it will still perform
DELETE <url>
calls, to make sure that any possible previous preparations are cancelled. Since these DELETE calls are repeated all the time, errors from them are ignored.JSON response expected by rollout-operator is simply
{"timestamp": <unix-seconds as number>}
.Format of the URL annotation is full URL like
http://pod/prepare-delayed-downscale
, in which the "host" part of the URL will be replaced with pod's fully-qualified domain name, eg.ingester-zone-b-0.ingester-zone-b.namespace.svc.cluster.local.
.How is this different from
grafana.com/min-time-between-zones-downscale
?grafana.com/min-time-between-zones-downscale
is applied to delay downscaling of zones based on downscale timestamp of another zone.How is this different from
grafana.com/prepare-downscale-http-path
?grafana.com/prepare-downscale-http-path
together withgrafana.com/prepare-downscale-http-port
annotation are used to signal pod that is being scaled down. Ie. after call tografana.com/prepare-downscale-http-path+port
, pod will be downscaled right after.grafana.com/rollout-prepare-delayed-downscale-url
tells pod about downscale in the future, which can be minutes or hours later.