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

Disable increaseSize when the node group is under initialilzation. #3242

Merged

Conversation

nilo19
Copy link
Member

@nilo19 nilo19 commented Jun 25, 2020

Disable increaseSize when the node group is under initialilzation.

fixes: #3240

/kind bug
/area provider/azure

@k8s-ci-robot k8s-ci-robot added kind/bug Categorizes issue or PR as related to a bug. area/provider/azure Issues or PRs related to azure provider cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Jun 25, 2020
@nilo19
Copy link
Member Author

nilo19 commented Jun 25, 2020

The unit test for agentPool will be added after #3223 (review) is merged.

@@ -327,6 +327,11 @@ func (scaleSet *ScaleSet) TargetSize() (int, error) {

// IncreaseSize increases Scale Set size
func (scaleSet *ScaleSet) IncreaseSize(delta int) error {
if scaleSet.curSize == -1 {
klog.V(1).Infof("the scale set %s is under initialization, would skip the operation", scaleSet.Name)
return nil
Copy link
Member

Choose a reason for hiding this comment

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

I think we should return an error still so autoscaler can backoff and try to resize a different agentpool.

In a super rare scenario where you have many nodepools - some of them are initialized and some aren't. You still want to to be able to scale whatever was initialized.

@@ -327,6 +327,11 @@ func (scaleSet *ScaleSet) TargetSize() (int, error) {

// IncreaseSize increases Scale Set size
func (scaleSet *ScaleSet) IncreaseSize(delta int) error {
if scaleSet.curSize == -1 {
klog.V(1).Infof("the scale set %s is under initialization, would skip the operation", scaleSet.Name)
Copy link
Member

@marwanad marwanad Jun 25, 2020

Choose a reason for hiding this comment

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

Suggested change
klog.V(1).Infof("the scale set %s is under initialization, would skip the operation", scaleSet.Name)
klog.V(1).Infof("the scale set %s is under initialization, skipping the increase size operation", scaleSet.Name)

klog.V(1).Infof("the scale set %s is under initialization, would skip the operation", scaleSet.Name)
return nil
}

Copy link
Member

Choose a reason for hiding this comment

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

I'd also move this check under the line where it gets the currSize.

The

	size, err := scaleSet.GetScaleSetSize()
	if err != nil {
		return err
	}

happens under a mutex so it should be safer.

@nilo19 nilo19 force-pushed the bug/disable-increase-when-initializing branch from abe22ae to e3ff7f2 Compare June 25, 2020 03:58
Copy link
Member

@marwanad marwanad left a comment

Choose a reason for hiding this comment

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

minor comments, otherwise looks good

@@ -336,6 +336,10 @@ func (scaleSet *ScaleSet) IncreaseSize(delta int) error {
return err
}

if scaleSet.curSize == -1 {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if scaleSet.curSize == -1 {
if size == -1 {

@@ -302,6 +303,10 @@ func (as *AgentPool) IncreaseSize(delta int) error {
as.mutex.Lock()
defer as.mutex.Unlock()

if as.curSize == -1 {
return fmt.Errorf("the availability set %s is under initialization, skipping the operation", as.Name)
Copy link
Member

Choose a reason for hiding this comment

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

skipping the "increase size" or "scale up" operation - whatever works so its easier to figure out from logs without having to look at the source code

@nilo19 nilo19 force-pushed the bug/disable-increase-when-initializing branch from e3ff7f2 to 13cecd2 Compare June 25, 2020 05:35
@marwanad
Copy link
Member

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added lgtm "Looks good to me", indicates that a PR is ready to be merged. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Jun 25, 2020
Copy link
Member

@feiskyer feiskyer left a comment

Choose a reason for hiding this comment

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

thanks for the quick fix.

could you fix the unit test failures?

@nilo19 nilo19 force-pushed the bug/disable-increase-when-initializing branch from 13cecd2 to 81cb1a7 Compare June 25, 2020 11:33
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 25, 2020
Copy link
Member

@feiskyer feiskyer left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 25, 2020
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: feiskyer, 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

@feiskyer
Copy link
Member

@nilo19 let's cherry-pick this to older releases

@k8s-ci-robot k8s-ci-robot merged commit 1434d14 into kubernetes:master Jun 25, 2020
k8s-ci-robot added a commit that referenced this pull request Jun 25, 2020
Cherry-pick #3242: Disable increaseSize when the node group is under initialilzation.
k8s-ci-robot added a commit that referenced this pull request Jun 26, 2020
Cherry-pick #3242: Disable increaseSize when the node group is under initialilzation.
k8s-ci-robot added a commit that referenced this pull request Jun 26, 2020
Cherry-pick #3242: Disable increaseSize when the node group is under initialilzation.
k8s-ci-robot added a commit that referenced this pull request Jun 26, 2020
Cherry-pick #3242: Disable increaseSize when the node group is under initialilzation.
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. kind/bug Categorizes issue or PR as related to a bug. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Azure: cluster autoscaler incorrectly scales down cluster when Azure API calls get throttled
4 participants