Skip to content
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

Inhibit scale-down by autoscaler during roll-outs. #496

Merged
merged 3 commits into from
Sep 1, 2020

Conversation

hardikdr
Copy link
Member

@hardikdr hardikdr commented Aug 14, 2020

What this PR does / why we need it: With this PR, during roll out of the machine-deployment, all the machines under it are annotated with cluster-autoscaler.kubernetes.io/scale-down-disabled: "True".

This will help us keeping the cluster-autoscaler running even during the cluster-rollouts. CA will not scale-down a specific machine-deployment which is being rolled, but will be able to scale-down the rest of them. Also, CA will be able to scale-up all the machine-deployments during roll-outs.

There are mainly 2 parts to the PR:

  1. Adding the annotation during roll-out.

    • To determine if the roll-out if on-going we check if there are old-machine-sets that are not scaled-to-zero completely. We check the up-to-date, and ready replicas as well here.
  2. Removing the annotation after the roll-out.

    • Keeping the controller nature in mind, we need a way to differentiate between 2 possibilities:
      • Cluster rollout just got over, MachineDeployment is complete[all machine-replicas ready] and we should remove the annotation.
      • There have been no roll-outs recently, MachineDeployment is complete and we shouldn't remove the annotation. Looking at older machine-set doesn't help as I see them retained after roll-outs.
    • If we don't consider the possibilities above, we may end up removing the same ca-annotation which might have been added by the user via NodeTemplate.
    • I have mitigated the situation, by introducing the by-mcm annotation, which is added on the node along with the original annotation. This place-holder-annotation helps in deciding if the original annotation is added by mcm or by the user. This helps in avoiding potential race-condition with nodeTemplate logic.
    • Open for further suggestions or alternatives.

Unfortunately, we cant use the nodeTemplate feature for adding/removing the annotation:

  1. If we set the annotation on the MachineSet's nodeTemplate, machine-deployment overwrites it back.
    • If we ignore the specific annotation in code, user-provided CA-annotation might also be overwritten.
  2. If we set the annotation on the MachineDeployment's nodeTemplate, worker-controller will eventually overwrite it to the original state.

Which issue(s) this PR fixes:
Fixes https://github.com/gardener/autoscaler/issues/48
FIxes #472

Special notes for your reviewer:
We need to consider the possibility that users might also be using the same annotation for their use cases. We should make sure, autoscaler annotations from users are maintained.

Release note:

All nodes under machine deployments being rolled-out are annotated with `cluster-autoscaler.kubernetes.io/scale-down-disabled: "True"` during the period of rolling-update.
A new command line flag `autoscaler-scaldown-annotation-during-rollout` is introduced to disable annotating the nodes with cluster-autoscaler annotation `cluster-autoscaler.kubernetes.io/scale-down-disabled` during rollout.

@hardikdr hardikdr requested review from ggaurav10 and a team as code owners August 14, 2020 10:07
@gardener-robot-ci-3 gardener-robot-ci-3 added the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Aug 14, 2020
@gardener-robot-ci-2 gardener-robot-ci-2 added needs/ok-to-test Needs approval for testing (check PR in detail before setting this label because PR is run on CI/CD) and removed reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) labels Aug 14, 2020
@vlerenc
Copy link
Member

vlerenc commented Aug 18, 2020

I have mitigated the situation, by introducing the by-mcm annotation, which is added on the node along with the original annotation. This place-holder-annotation helps in deciding if the original annotation is added by mcm or by the user. This helps in avoiding potential race-condition with nodeTemplate logic.
Open for further suggestions or alternatives.

Not really, nothing more elegant. That would have been also my approach/was also what I was thinking when I heard/read the above.

Copy link

@amshuman-kr amshuman-kr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hardikdr Thanks for the PR. Just a couple of questions/comments. Otherwise looks good, apart from tests.

pkg/controller/deployment_rolling.go Outdated Show resolved Hide resolved
pkg/controller/deployment_rolling.go Outdated Show resolved Hide resolved
@hardikdr
Copy link
Member Author

Thanks for the reviews.
I'll rebase and add unit tests soon.

Copy link

@amshuman-kr amshuman-kr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One more question. The PR covers only the RollingUpdate strategy. Wouldn't the feature be complete if we cover the Recreate strategy too?

@hardikdr
Copy link
Member Author

The PR covers only the RollingUpdate strategy. Wouldn't the feature be complete if we cover the Recreate strategy too?

Recreate strategy simply deletes all the existing machines and creates the new ones altogether. That is already super disruptive, not sure how autoscaler could harm it any further.

@amshuman-kr
Copy link

Recreate strategy simply deletes all the existing machines and creates the new ones altogether. That is already super disruptive, not sure how autoscaler could harm it any further.

What if CA scales down/up while the new machines are still joining? Isn't it better to cover all bases?

@hardikdr hardikdr added this to the v0.34.0 milestone Aug 25, 2020
@hardikdr hardikdr force-pushed the feature/autoscaler-annotation branch from d003f2c to 1b48eaa Compare August 25, 2020 11:22
@gardener-robot-ci-1 gardener-robot-ci-1 added reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) and removed reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) labels Aug 25, 2020
@hardikdr hardikdr force-pushed the feature/autoscaler-annotation branch from 1b48eaa to 44d70a2 Compare August 25, 2020 11:27
@gardener-robot-ci-3 gardener-robot-ci-3 added reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) and removed reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) labels Aug 25, 2020
@hardikdr
Copy link
Member Author

What if CA scales down/up while the new machines are still joining? Isn't it better to cover all bases?

I spent a bit more time and experimented. Basically, during Recreate the old machine-set is completely brought down and made sure no old machines are running. Once there are no old machines running, the new machine set is brought up to the full. A couple of points to ponder upon:

  1. It is hard to differentiate between the following cases:
    • Scale-up of machineset due to usual-scale-up of machine-deployment
    • Scale-up of machineset due to recreate-update flow.
  • It's certainly possible to make it work, just that it'll demand more changes in the code as it seems.
  1. CA scales down a node only if the node is registered and under-utilized for a certain period of time. So if few nodes have joined the cluster and not taking any Pending workload for a certain timeout period during recreate-update, I believe CA will anyways remove it immediately after roll-out.

  2. Scale-up is anyways allowed in both strategies.

Overall, Recreate doesn't seem to be a production-friendly feature. If an application can survive literally no-machines in the cluster/worker-group, we should probably not invest too much to avoid minor scale down in between.

  • Just to add, this is not being exposed/used by the gardener, also not planned afaik.

In summary, I felt it definitely sounds sensible to cover all the strategies for the feature from bird's eye view, but there are more details. But if we see the value, I am more than happy to somehow make it work. :)

@gardener-robot-ci-2 gardener-robot-ci-2 added reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) and removed reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) labels Aug 26, 2020
@gardener-robot-ci-3 gardener-robot-ci-3 added the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Aug 26, 2020
@gardener-robot-ci-1 gardener-robot-ci-1 removed the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Aug 26, 2020
@hardikdr hardikdr force-pushed the feature/autoscaler-annotation branch from 3a557bb to b80203a Compare August 26, 2020 06:59
@gardener-robot-ci-3 gardener-robot-ci-3 added the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Aug 26, 2020
@gardener-robot-ci-1 gardener-robot-ci-1 removed the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Aug 26, 2020
@hardikdr hardikdr force-pushed the feature/autoscaler-annotation branch from b80203a to e5a4f64 Compare August 26, 2020 07:05
@gardener-robot-ci-2 gardener-robot-ci-2 added the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Aug 26, 2020
Copy link
Contributor

@prashanth26 prashanth26 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor typo.
/lgtm otherwise

Also ditto comment on squashing commits.

@gardener-robot gardener-robot added the reviewed/lgtm Has approval for merging label Aug 27, 2020
@gardener-robot-ci-1 gardener-robot-ci-1 added the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Aug 27, 2020
@gardener-robot-ci-2 gardener-robot-ci-2 removed the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Aug 27, 2020
@hardikdr hardikdr force-pushed the feature/autoscaler-annotation branch from ccde85d to 527a25f Compare August 27, 2020 12:07
@gardener-robot-ci-1 gardener-robot-ci-1 added the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Aug 27, 2020
@gardener-robot-ci-2 gardener-robot-ci-2 removed the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Aug 27, 2020
@hardikdr hardikdr force-pushed the feature/autoscaler-annotation branch from 527a25f to 0419c04 Compare August 27, 2020 12:37
@gardener-robot-ci-1 gardener-robot-ci-1 added the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Aug 27, 2020
@gardener-robot-ci-3 gardener-robot-ci-3 removed the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Aug 27, 2020
@hardikdr hardikdr added the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Aug 28, 2020
@gardener-robot-ci-1 gardener-robot-ci-1 removed the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Aug 28, 2020
@hardikdr hardikdr added the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Aug 28, 2020
@gardener-robot-ci-1 gardener-robot-ci-1 removed the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Aug 28, 2020
@hardikdr hardikdr force-pushed the feature/autoscaler-annotation branch from 0419c04 to f5a0478 Compare August 28, 2020 07:40
@gardener-robot-ci-3 gardener-robot-ci-3 added the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Aug 28, 2020
@gardener-robot-ci-2 gardener-robot-ci-2 removed the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Aug 28, 2020
@hardikdr
Copy link
Member Author

@amshuman-kr @ggaurav10 Can you please take a final look and approve if possible?

@prashanth26
Copy link
Contributor

/ping

@gardener-robot
Copy link

@prashanth26

Message

/ping

Copy link
Contributor

@ggaurav10 ggaurav10 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs/ok-to-test Needs approval for testing (check PR in detail before setting this label because PR is run on CI/CD) reviewed/lgtm Has approval for merging
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Disable scale-down during cluster-rollouts.
9 participants