зеркало из https://github.com/Azure/aks-engine.git
fix: use correct VMSS name comparison during Windows scale (#3590)
This commit is contained in:
Родитель
2e3b4f90cb
Коммит
b764e74a46
31
cmd/scale.go
31
cmd/scale.go
|
@ -391,9 +391,21 @@ func (sc *scaleCmd) run(cmd *cobra.Command, args []string) error {
|
|||
}
|
||||
for _, vmss := range vmssListPage.Values() {
|
||||
vmssName := *vmss.Name
|
||||
if !sc.vmInAgentPool(vmssName, vmss.Tags) {
|
||||
continue
|
||||
if sc.agentPool.OSType == api.Windows {
|
||||
possibleIndex, err := strconv.Atoi(vmssName[len(vmssName)-2:])
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
if !(sc.containerService.Properties.GetAgentVMPrefix(sc.agentPool, possibleIndex) == vmssName) {
|
||||
continue
|
||||
}
|
||||
winPoolIndex = possibleIndex
|
||||
} else {
|
||||
if !sc.vmInAgentPool(vmssName, vmss.Tags) {
|
||||
continue
|
||||
}
|
||||
}
|
||||
log.Infof("found VMSS %s in resource group %s that correlates with node pool %s", vmssName, sc.resourceGroupName, sc.agentPoolToScale)
|
||||
|
||||
if vmss.Sku != nil {
|
||||
currentNodeCount = int(*vmss.Sku.Capacity)
|
||||
|
@ -403,14 +415,11 @@ func (sc *scaleCmd) run(cmd *cobra.Command, args []string) error {
|
|||
} else if int(*vmss.Sku.Capacity) > sc.newDesiredAgentCount {
|
||||
log.Warnf("VMSS scale down is an alpha feature: VMSS VM nodes will not be cordoned and drained before scaling down!")
|
||||
}
|
||||
}
|
||||
|
||||
if sc.agentPool.OSType == api.Windows {
|
||||
winPoolIndexStr := vmssName[len(vmssName)-2:]
|
||||
var err error
|
||||
winPoolIndex, err = strconv.Atoi(winPoolIndexStr)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to get Windows pool index from VMSS name")
|
||||
} else {
|
||||
// Fall back to comparing against the known count value in the api model
|
||||
if sc.agentPool.Count == sc.newDesiredAgentCount {
|
||||
sc.printScaleTargetEqualsExisting(currentNodeCount)
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -571,7 +580,7 @@ func (sc *scaleCmd) vmInAgentPool(vmName string, tags map[string]*string) bool {
|
|||
}
|
||||
|
||||
// Fall back to checking the VM name to see if it fits the naming pattern
|
||||
if sc.agentPool.OSType == api.Windows && strings.HasPrefix(vmName, sc.containerService.Properties.GetClusterID()[:4]) {
|
||||
if sc.agentPool.OSType == api.Windows && sc.agentPool.AvailabilityProfile == api.AvailabilitySet && strings.HasPrefix(vmName, sc.containerService.Properties.GetClusterID()[:4]) {
|
||||
_, _, winPoolIndex, _, err := utils.WindowsVMNameParts(vmName)
|
||||
if err == nil {
|
||||
return vmName[:9] == sc.containerService.Properties.GetAgentVMPrefix(sc.agentPool, winPoolIndex)[:9]
|
||||
|
|
Загрузка…
Ссылка в новой задаче