Skip to content
This repository has been archived by the owner on Oct 24, 2023. It is now read-only.

fix: ensure correct agent pool selection in scale operations #4851

Merged
merged 3 commits into from
Mar 3, 2022

Conversation

haofan-ms
Copy link
Contributor

Reason for Change:

When there are multiple Windows / Linux agent pools, the scale operation is not selecting the correct agent pool.

For Windows agent pools, the code vmName[:9] == sc.containerService.Properties.GetAgentVMPrefix(sc.agentPool, winPoolIndex)[:9] will always be true and thus all Windows agent pools will be mixed in scaling and indexing.

For Linux agent pools, for example if one agentpool is named linuxpool and the other agentpool is named linxpool2, and scale operation targets linuxpool, then code strings.Contains(vmName, sc.agentPoolToScale) will also consider VMs from linuxpool2 are in agentpool linuxpool.

Issue Fixed:

#1065

Credit Where Due:

Does this change contain code from or inspired by another project?

  • No
  • Yes

If "Yes," did you notify that project's maintainers and provide attribution?

  • No
  • Yes

Requirements:

Notes:

jackfrancis
jackfrancis previously approved these changes Mar 2, 2022
Copy link
Member

@jackfrancis jackfrancis left a comment

Choose a reason for hiding this comment

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

/lgtm

agentPoolIndex: 0,
agentPoolToScale: "linuxpool",
agentPool: &api.AgentPoolProfile{
Name: "linuxpool2",
Copy link
Member

Choose a reason for hiding this comment

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

I am not sure you can find yourself in a situation where sc.agentPoolToScale and sc.agentPool.Name are different: https://github.com/Azure/aks-engine/blob/master/cmd/scale.go#L204-L227

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated agentPool.Name

@@ -135,3 +136,106 @@ func TestScaleCmdValidate(t *testing.T) {
})
}
}

func TestVmInVMASAgentPool(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

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

it seems we are missing a case where agentPoolToScale is the empty string

Copy link
Contributor Author

Choose a reason for hiding this comment

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

agentPoolToScale empty string case should have been covered by these lines (https://github.com/Azure/aks-engine/blob/master/cmd/scale.go#L209-L211)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants