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

azure vmss cache fixes and improvements #4685

Merged
merged 1 commit into from
Feb 17, 2022

Conversation

marwanad
Copy link
Member

@marwanad marwanad commented Feb 16, 2022

With the merge of #3717, we lost the optimistic in memory cache we've added. The PR stopped bubbling down the sizeRefreshPeriod which was then removed in #4541 because it was unused.

The realization is that we still need this back for the following scenario:

  1. Assume a cache TTL of 60s, minCount = 2, currentTarget = 3
  2. Two nodes are eligible for deletion by autoscaler, minCount=2 and because CA core won't do the min count check for us in empty node removal.
  3. First node gets removed, we decrement scale.Set.CurSize to 2
  4. Second call toscaleSet.DeleteNodes() comes in and this calls into GetScaleSetSize which in turn ends up reading from manager.cache which would have a cached count of 3 and thus will return you 3 so you end up deleting that node as well

With this PR, we'll extend the last refresh time by sizeRefreshPeriod to ensure that next time we expire, manager.cache would've had the chance to refresh and give us fresh data. That's basically the behaviour prior to #3717. See in 1.19.

The PR also cleans up the logging to refer to "in-memory size" vs the one we get back from the manager cache.

This will impact 1.21+.

/area cloudprovider/azure

@k8s-ci-robot
Copy link
Contributor

@marwanad: The label(s) area/cloudprovider/azure cannot be applied, because the repository doesn't have them.

In response to this:

With the merge of #3717, we lost the optimistic in memory cache we've added. The PR stopped bubbling down the sizeRefreshPeriod which was then removed in #4541 because it was unused.

The realization is that we still need this back for the following scenario:

  1. Assume a cache TTL of 60s, minCount = 2, currentTarget = 3
  2. Two nodes are eligible for deletion by autoscaler, minCount=2 and because CA core won't do the min count check for us in empty node removal.
  3. First node gets removed, we decrement scale.Set.CurSize to 2
  4. Second call toscaleSet.DeleteNodes() comes in and this calls into GetScaleSetSize which in turn ends up reading from manager.cache which would have a cached count of 3 and thus will return you 3 so you end up deleting that node as well

With this PR, we'll extend the last refresh time by sizeRefreshPeriod to ensure that next time we expire, manager.cache would've had the chance to refresh and give us fresh data. That's basically the behaviour prior to #3717. See in 1.19.

The PR also cleans up the logging to refer to "in-memory size" vs the one we get back from the manager cache.

/area cloudprovider/azure

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Feb 16, 2022
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: marwanad

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 16, 2022
@@ -567,6 +579,7 @@ func (scaleSet *ScaleSet) setInstanceStatusByProviderID(providerID string, statu
scaleSet.instanceCache[k].Status = &status
}
}
scaleSet.lastInstanceRefresh = time.Now()
Copy link
Member Author

Choose a reason for hiding this comment

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

This added recently with the same motivation too. If we proactively update the instance state to Deletion, we don't want it to be invalidated in the next loop in case that cache is stale.

@marwanad
Copy link
Member Author

/area provider/azure

@k8s-ci-robot k8s-ci-robot added the area/provider/azure Issues or PRs related to azure provider label Feb 16, 2022
@nilo19
Copy link
Member

nilo19 commented Feb 17, 2022

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 17, 2022
@k8s-ci-robot k8s-ci-robot merged commit 2f0a452 into kubernetes:master Feb 17, 2022
k8s-ci-robot added a commit that referenced this pull request Apr 7, 2022
Cherry-pick #4685, #47874 - Azure vmss cache improvements
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/provider/azure Issues or PRs related to azure provider cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants