Skip to content

Commit

Permalink
Merge pull request #4804 from k8s-infra-cherrypick-robot/cherry-pick-…
Browse files Browse the repository at this point in the history
…4798-to-release-1.28

[release-1.28] report vmPowerStateUnknown when vmssVM intanceView is nil
  • Loading branch information
k8s-ci-robot authored Oct 16, 2023
2 parents 09dfced + b754ed3 commit 9d7bf14
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 15 deletions.
2 changes: 1 addition & 1 deletion pkg/provider/azure.go
Original file line number Diff line number Diff line change
Expand Up @@ -1357,7 +1357,7 @@ func (az *Cloud) updateNodeTaint(node *v1.Node) {
klog.Errorf("failed to add taint %s to the node %s", v1.TaintNodeOutOfService, node.Name)
}
} else {
klog.V(2).Infof("node %s is not ready but node shutdown taint is not added, skip adding node out-of-service taint", node.Name)
klog.V(2).Infof("node %s is not ready but either shutdown taint is missing or out-of-service taint is already added, skip adding node out-of-service taint", node.Name)
}
}
}
Expand Down
1 change: 1 addition & 0 deletions pkg/provider/azure_instances.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const (
vmPowerStateStopped = "stopped"
vmPowerStateDeallocated = "deallocated"
vmPowerStateDeallocating = "deallocating"
vmPowerStateUnknown = "unknown"

// nodeNameEnvironmentName is the environment variable name for getting node name.
// It is only used for out-of-tree cloud provider.
Expand Down
4 changes: 2 additions & 2 deletions pkg/provider/azure_standard.go
Original file line number Diff line number Diff line change
Expand Up @@ -515,8 +515,8 @@ func (as *availabilitySet) GetPowerStatusByNodeName(name string) (powerState str
}

// vm.InstanceView or vm.InstanceView.Statuses are nil when the VM is under deleting.
klog.V(3).Infof("InstanceView for node %q is nil, assuming it's stopped", name)
return vmPowerStateStopped, nil
klog.V(3).Infof("InstanceView for node %q is nil, assuming it's deleting", name)
return vmPowerStateUnknown, nil
}

// GetProvisioningStateByNodeName returns the provisioningState for the specified node.
Expand Down
8 changes: 4 additions & 4 deletions pkg/provider/azure_standard_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1042,18 +1042,18 @@ func TestGetStandardVMPowerStatusByNodeName(t *testing.T) {
expectedStatus: "Running",
},
{
name: "GetPowerStatusByNodeName should get vmPowerStateStopped if vm.InstanceView is nil",
name: "GetPowerStatusByNodeName should get vmPowerStateUnknown if vm.InstanceView is nil",
nodeName: "vm3",
vm: compute.VirtualMachine{
Name: pointer.String("vm3"),
VirtualMachineProperties: &compute.VirtualMachineProperties{
ProvisioningState: pointer.String("Succeeded"),
},
},
expectedStatus: vmPowerStateStopped,
expectedStatus: vmPowerStateUnknown,
},
{
name: "GetPowerStatusByNodeName should get vmPowerStateStopped if vm.InstanceView.statuses is nil",
name: "GetPowerStatusByNodeName should get vmPowerStateUnknown if vm.InstanceView.statuses is nil",
nodeName: "vm4",
vm: compute.VirtualMachine{
Name: pointer.String("vm4"),
Expand All @@ -1062,7 +1062,7 @@ func TestGetStandardVMPowerStatusByNodeName(t *testing.T) {
InstanceView: &compute.VirtualMachineInstanceView{},
},
},
expectedStatus: vmPowerStateStopped,
expectedStatus: vmPowerStateUnknown,
},
}
for _, test := range testcases {
Expand Down
4 changes: 2 additions & 2 deletions pkg/provider/azure_vmss.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,8 @@ func (ss *ScaleSet) GetPowerStatusByNodeName(name string) (powerState string, er
}

// vm.InstanceView or vm.InstanceView.Statuses are nil when the VM is under deleting.
klog.V(3).Infof("InstanceView for node %q is nil, assuming it's stopped", name)
return vmPowerStateStopped, nil
klog.V(3).Infof("InstanceView for node %q is nil, assuming it's deleting", name)
return vmPowerStateUnknown, nil
}

// GetProvisioningStateByNodeName returns the provisioningState for the specified node.
Expand Down
4 changes: 2 additions & 2 deletions pkg/provider/azure_vmss_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -787,10 +787,10 @@ func TestGetPowerStatusByNodeName(t *testing.T) {
expectedPowerState: "Running",
},
{
description: "GetPowerStatusByNodeName should return vmPowerStateStopped when the vm.InstanceView.Statuses is nil",
description: "GetPowerStatusByNodeName should return vmPowerStateUnknown when the vm.InstanceView.Statuses is nil",
vmList: []string{"vmss-vm-000001"},
nilStatus: true,
expectedPowerState: vmPowerStateStopped,
expectedPowerState: vmPowerStateUnknown,
},
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/provider/azure_vmssflex.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,8 @@ func (fs *FlexScaleSet) GetPowerStatusByNodeName(name string) (powerState string
}

// vm.InstanceView or vm.InstanceView.Statuses are nil when the VM is under deleting.
klog.V(3).Infof("InstanceView for node %q is nil, assuming it's stopped", name)
return vmPowerStateStopped, nil
klog.V(3).Infof("InstanceView for node %q is nil, assuming it's deleting", name)
return vmPowerStateUnknown, nil
}

// GetPrimaryInterface gets machine primary network interface by node name.
Expand Down
4 changes: 2 additions & 2 deletions pkg/provider/azure_vmssflex_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -551,12 +551,12 @@ func TestGetPowerStatusByNodeNameVmssFlex(t *testing.T) {
expectedErr: cloudprovider.InstanceNotFound,
},
{
description: "GetPowerStatusByNodeName should return stopped if the node powerstate is nil",
description: "GetPowerStatusByNodeName should return unknown if the node powerstate is nil",
nodeName: "vmssflex1000003",
testVMListWithoutInstanceView: testVMListWithoutInstanceView,
testVMListWithOnlyInstanceView: testVMListWithOnlyInstanceView,
vmListErr: nil,
expectedPowerStatus: "stopped",
expectedPowerStatus: "unknown",
expectedErr: nil,
},
}
Expand Down

0 comments on commit 9d7bf14

Please sign in to comment.