mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-26 05:03:09 +00:00
Avoid caching the VMSS instances whose network profile is nil
This commit is contained in:
parent
a5489431cf
commit
4abaccc12e
@ -198,6 +198,11 @@ func (ss *scaleSet) newVMSSVirtualMachinesCache(resourceGroupName, vmssName, cac
|
|||||||
}
|
}
|
||||||
|
|
||||||
computerName := strings.ToLower(*vm.OsProfile.ComputerName)
|
computerName := strings.ToLower(*vm.OsProfile.ComputerName)
|
||||||
|
if vm.NetworkProfile == nil || vm.NetworkProfile.NetworkInterfaces == nil {
|
||||||
|
klog.Warningf("skip caching vmssVM %s since its network profile hasn't initialized yet (probably still under creating)", computerName)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
vmssVMCacheEntry := &vmssVirtualMachinesEntry{
|
vmssVMCacheEntry := &vmssVirtualMachinesEntry{
|
||||||
resourceGroup: resourceGroupName,
|
resourceGroup: resourceGroupName,
|
||||||
vmssName: vmssName,
|
vmssName: vmssName,
|
||||||
|
@ -1385,16 +1385,25 @@ func TestGetAgentPoolScaleSets(t *testing.T) {
|
|||||||
{
|
{
|
||||||
VirtualMachineScaleSetVMProperties: &compute.VirtualMachineScaleSetVMProperties{
|
VirtualMachineScaleSetVMProperties: &compute.VirtualMachineScaleSetVMProperties{
|
||||||
OsProfile: &compute.OSProfile{ComputerName: to.StringPtr("vmss-vm-000000")},
|
OsProfile: &compute.OSProfile{ComputerName: to.StringPtr("vmss-vm-000000")},
|
||||||
|
NetworkProfile: &compute.NetworkProfile{
|
||||||
|
NetworkInterfaces: &[]compute.NetworkInterfaceReference{},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
VirtualMachineScaleSetVMProperties: &compute.VirtualMachineScaleSetVMProperties{
|
VirtualMachineScaleSetVMProperties: &compute.VirtualMachineScaleSetVMProperties{
|
||||||
OsProfile: &compute.OSProfile{ComputerName: to.StringPtr("vmss-vm-000001")},
|
OsProfile: &compute.OSProfile{ComputerName: to.StringPtr("vmss-vm-000001")},
|
||||||
|
NetworkProfile: &compute.NetworkProfile{
|
||||||
|
NetworkInterfaces: &[]compute.NetworkInterfaceReference{},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
VirtualMachineScaleSetVMProperties: &compute.VirtualMachineScaleSetVMProperties{
|
VirtualMachineScaleSetVMProperties: &compute.VirtualMachineScaleSetVMProperties{
|
||||||
OsProfile: &compute.OSProfile{ComputerName: to.StringPtr("vmss-vm-000002")},
|
OsProfile: &compute.OSProfile{ComputerName: to.StringPtr("vmss-vm-000002")},
|
||||||
|
NetworkProfile: &compute.NetworkProfile{
|
||||||
|
NetworkInterfaces: &[]compute.NetworkInterfaceReference{},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -1463,6 +1472,20 @@ func TestGetVMSetNames(t *testing.T) {
|
|||||||
},
|
},
|
||||||
expectedErr: fmt.Errorf("scale set (vmss-1) - not found"),
|
expectedErr: fmt.Errorf("scale set (vmss-1) - not found"),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
description: "GetVMSetNames should report an error if vm's network profile is nil",
|
||||||
|
service: &v1.Service{
|
||||||
|
ObjectMeta: metav1.ObjectMeta{Annotations: map[string]string{ServiceAnnotationLoadBalancerMode: "vmss"}},
|
||||||
|
},
|
||||||
|
nodes: []*v1.Node{
|
||||||
|
{
|
||||||
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
|
Name: "vmss-vm-000003",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
expectedErr: fmt.Errorf("instance not found"),
|
||||||
|
},
|
||||||
{
|
{
|
||||||
description: "GetVMSetNames should return the correct vmss names",
|
description: "GetVMSetNames should return the correct vmss names",
|
||||||
service: &v1.Service{
|
service: &v1.Service{
|
||||||
@ -1496,16 +1519,30 @@ func TestGetVMSetNames(t *testing.T) {
|
|||||||
{
|
{
|
||||||
VirtualMachineScaleSetVMProperties: &compute.VirtualMachineScaleSetVMProperties{
|
VirtualMachineScaleSetVMProperties: &compute.VirtualMachineScaleSetVMProperties{
|
||||||
OsProfile: &compute.OSProfile{ComputerName: to.StringPtr("vmss-vm-000000")},
|
OsProfile: &compute.OSProfile{ComputerName: to.StringPtr("vmss-vm-000000")},
|
||||||
|
NetworkProfile: &compute.NetworkProfile{
|
||||||
|
NetworkInterfaces: &[]compute.NetworkInterfaceReference{},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
VirtualMachineScaleSetVMProperties: &compute.VirtualMachineScaleSetVMProperties{
|
VirtualMachineScaleSetVMProperties: &compute.VirtualMachineScaleSetVMProperties{
|
||||||
OsProfile: &compute.OSProfile{ComputerName: to.StringPtr("vmss-vm-000001")},
|
OsProfile: &compute.OSProfile{ComputerName: to.StringPtr("vmss-vm-000001")},
|
||||||
|
NetworkProfile: &compute.NetworkProfile{
|
||||||
|
NetworkInterfaces: &[]compute.NetworkInterfaceReference{},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
VirtualMachineScaleSetVMProperties: &compute.VirtualMachineScaleSetVMProperties{
|
VirtualMachineScaleSetVMProperties: &compute.VirtualMachineScaleSetVMProperties{
|
||||||
OsProfile: &compute.OSProfile{ComputerName: to.StringPtr("vmss-vm-000002")},
|
OsProfile: &compute.OSProfile{ComputerName: to.StringPtr("vmss-vm-000002")},
|
||||||
|
NetworkProfile: &compute.NetworkProfile{
|
||||||
|
NetworkInterfaces: &[]compute.NetworkInterfaceReference{},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
VirtualMachineScaleSetVMProperties: &compute.VirtualMachineScaleSetVMProperties{
|
||||||
|
OsProfile: &compute.OSProfile{ComputerName: to.StringPtr("vmss-vm-000003")},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user