mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-21 19:01:49 +00:00
Merge pull request #92257 from andyzhangx/deallocating
fix: Azure deallocating node should be regarded as shut down
This commit is contained in:
commit
e201c6b8df
@ -32,9 +32,10 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
vmPowerStatePrefix = "PowerState/"
|
vmPowerStatePrefix = "PowerState/"
|
||||||
vmPowerStateStopped = "stopped"
|
vmPowerStateStopped = "stopped"
|
||||||
vmPowerStateDeallocated = "deallocated"
|
vmPowerStateDeallocated = "deallocated"
|
||||||
|
vmPowerStateDeallocating = "deallocating"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
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)
|
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.
|
// InstanceMetadataByProviderID returns metadata of the specified instance.
|
||||||
|
@ -284,7 +284,7 @@ func TestInstanceShutdownByProviderID(t *testing.T) {
|
|||||||
vmList: map[string]string{"vm3": "PowerState/Deallocating"},
|
vmList: map[string]string{"vm3": "PowerState/Deallocating"},
|
||||||
nodeName: "vm3",
|
nodeName: "vm3",
|
||||||
providerID: "azure:///subscriptions/subscription/resourceGroups/rg/providers/Microsoft.Compute/virtualMachines/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",
|
name: "InstanceShutdownByProviderID should return false if the vm is in PowerState/Starting status",
|
||||||
|
Loading…
Reference in New Issue
Block a user