Merge pull request #92257 from andyzhangx/deallocating

fix: Azure deallocating node should be regarded as shut down
This commit is contained in:
Kubernetes Prow Robot 2020-06-19 11:38:03 -07:00 committed by GitHub
commit e201c6b8df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 5 deletions

View File

@ -32,9 +32,10 @@ import (
)
const (
vmPowerStatePrefix = "PowerState/"
vmPowerStateStopped = "stopped"
vmPowerStateDeallocated = "deallocated"
vmPowerStatePrefix = "PowerState/"
vmPowerStateStopped = "stopped"
vmPowerStateDeallocated = "deallocated"
vmPowerStateDeallocating = "deallocating"
)
var (
@ -230,7 +231,8 @@ func (az *Cloud) InstanceShutdownByProviderID(ctx context.Context, providerID st
}
klog.V(5).Infof("InstanceShutdownByProviderID gets power status %q for node %q", powerStatus, nodeName)
return strings.ToLower(powerStatus) == vmPowerStateStopped || strings.ToLower(powerStatus) == vmPowerStateDeallocated, nil
status := strings.ToLower(powerStatus)
return status == vmPowerStateStopped || status == vmPowerStateDeallocated || status == vmPowerStateDeallocating, nil
}
// InstanceMetadataByProviderID returns metadata of the specified instance.

View File

@ -284,7 +284,7 @@ func TestInstanceShutdownByProviderID(t *testing.T) {
vmList: map[string]string{"vm3": "PowerState/Deallocating"},
nodeName: "vm3",
providerID: "azure:///subscriptions/subscription/resourceGroups/rg/providers/Microsoft.Compute/virtualMachines/vm3",
expected: false,
expected: true,
},
{
name: "InstanceShutdownByProviderID should return false if the vm is in PowerState/Starting status",