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

improve logging for scale set size changes #4541

Merged

Conversation

marwanad
Copy link
Member

This adds logging around previous + refreshed VMSS size and lowers the verbosity for one other log.

It also removes some fields that are no longer used after #3717 move to global azure_manager cache

@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 Dec 20, 2021
@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 Dec 20, 2021
sizeMutex sync.Mutex
curSize int64
lastSizeRefresh time.Time
sizeRefreshPeriod time.Duration
Copy link
Member Author

Choose a reason for hiding this comment

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

The sizeRefreshPeriod was always 0 after #3717. The TTL for VMSS cache refreshes is in honoured there where we depend on the CA core cloudprovider.Refresh() calls to update the caches.

https://github.com/kubernetes/autoscaler/blob/master/cluster-autoscaler/cloudprovider/azure/azure_manager.go#L166-L168

@@ -142,35 +140,30 @@ func (scaleSet *ScaleSet) getCurSize() (int64, error) {
scaleSet.sizeMutex.Lock()
defer scaleSet.sizeMutex.Unlock()

if scaleSet.lastSizeRefresh.Add(scaleSet.sizeRefreshPeriod).After(time.Now()) {
Copy link
Member Author

@marwanad marwanad Dec 20, 2021

Choose a reason for hiding this comment

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

this was always no-op after #3717 as lastSizeRefresh + 0 will always be in the past so this conditional was skipped.

if scaleSet.curSize != curSize {
// Invalidate the instance cache if the capacity has changed.
klog.V(5).Infof("VMSS %q size changed from: %d to %d, invalidating instance cache", scaleSet.Name, scaleSet.curSize, curSize)
Copy link
Member Author

Choose a reason for hiding this comment

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

keeping it as v=5 intentionally because it can be inferred from L64.

@marwanad
Copy link
Member Author

/assign @nilo19

@marwanad marwanad changed the title Improve logging for scale set size changes improve logging for scale set size changes Dec 20, 2021
@marwanad marwanad force-pushed the improve-azure-cache-logging branch from e0e2a5b to 091c72c Compare December 20, 2021 13:14
@@ -128,11 +126,11 @@ func (scaleSet *ScaleSet) MaxSize() int {
return scaleSet.maxSize
}

func (scaleSet *ScaleSet) getVMSSFromCache() (compute.VirtualMachineScaleSet, *retry.Error) {
func (scaleSet *ScaleSet) getVMSSFromCache() (compute.VirtualMachineScaleSet, error) {
Copy link
Member Author

@marwanad marwanad Dec 20, 2021

Choose a reason for hiding this comment

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

no reason to return the ARM error type here. The call to scaleSet.manager.azureCache.getScaleSets() is always a cache read call.

err = ss.IncreaseSize(100)
expectedErr := fmt.Errorf("the scale set test-asg is under initialization, skipping IncreaseSize")
expectedErr := fmt.Errorf("could not find vmss: test-asg-doesnt-exist")
Copy link
Member Author

@marwanad marwanad Dec 20, 2021

Choose a reason for hiding this comment

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

technically with the changes in #3717, we'll never end with the "-1" initialization case because the cache wont have the VMSS and we exit earlier. (keeping it there for now though)

@marwanad
Copy link
Member Author

marwanad commented Dec 20, 2021

/area provider/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:

/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.

@nilo19
Copy link
Member

nilo19 commented Dec 21, 2021

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Dec 21, 2021
@k8s-ci-robot k8s-ci-robot merged commit 1b63233 into kubernetes:master Dec 21, 2021
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/cluster-autoscaler 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.

4 participants