Skip to content

Commit bac4e60

Browse files
refactor: update capacity calculation to use actual VM count instead of requested capacity
1 parent 8755c3e commit bac4e60

File tree

1 file changed

+12
-3
lines changed
  • plugins/builtin/target/azure-vmss/plugin

1 file changed

+12
-3
lines changed

plugins/builtin/target/azure-vmss/plugin/plugin.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,15 +130,24 @@ func (t *TargetPlugin) Scale(action sdk.ScalingAction, config map[string]string)
130130
return fmt.Errorf("failed to get Azure vmss: %w", err)
131131
}
132132

133-
capacity := *currVMSS.SKU.Capacity
133+
orchestrationMode := string(*currVMSS.Properties.OrchestrationMode)
134+
135+
// Recommended removing this since it only gets the requested capacity and not the actual count.
136+
// capacity := *currVMSS.SKU.Capacity
137+
138+
vms, err := t.getVMSSVMs(ctx, resourceGroup, orchestrationMode, vmScaleSet)
139+
140+
if err != nil {
141+
return fmt.Errorf("failed to get VMSS VMs: %w", err)
142+
}
143+
144+
capacity := int64(len(vms))
134145

135146
// The Azure VMSS target requires different details depending on which
136147
// direction we want to scale. Therefore calculate the direction and the
137148
// relevant number so we can correctly perform the AWS work.
138149
num, direction := t.calculateDirection(capacity, action.Count)
139150

140-
orchestrationMode := string(*currVMSS.Properties.OrchestrationMode)
141-
142151
switch direction {
143152
case "in":
144153
err = t.scaleIn(ctx, resourceGroup, vmScaleSet, num, config, orchestrationMode)

0 commit comments

Comments
 (0)