mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-21 19:01:49 +00:00
fix nil vmss name
This commit is contained in:
parent
8b8de03168
commit
55fd3685d9
@ -740,7 +740,7 @@ func (ss *scaleSet) getAgentPoolScaleSets(nodes []*v1.Node) (*[]string, error) {
|
|||||||
// (depending vmType configured) for service load balancer. If the service has
|
// (depending vmType configured) for service load balancer. If the service has
|
||||||
// no loadbalancer mode annotation returns the primary VMSet. If service annotation
|
// no loadbalancer mode annotation returns the primary VMSet. If service annotation
|
||||||
// for loadbalancer exists then return the eligible VMSet.
|
// for loadbalancer exists then return the eligible VMSet.
|
||||||
func (ss *scaleSet) GetVMSetNames(service *v1.Service, nodes []*v1.Node) (vmSetNames *[]string, err error) {
|
func (ss *scaleSet) GetVMSetNames(service *v1.Service, nodes []*v1.Node) (*[]string, error) {
|
||||||
hasMode, isAuto, serviceVMSetNames := getServiceLoadBalancerMode(service)
|
hasMode, isAuto, serviceVMSetNames := getServiceLoadBalancerMode(service)
|
||||||
useSingleSLB := ss.useStandardLoadBalancer() && !ss.EnableMultipleStandardLoadBalancers
|
useSingleSLB := ss.useStandardLoadBalancer() && !ss.EnableMultipleStandardLoadBalancers
|
||||||
if !hasMode || useSingleSLB {
|
if !hasMode || useSingleSLB {
|
||||||
@ -764,7 +764,7 @@ func (ss *scaleSet) GetVMSetNames(service *v1.Service, nodes []*v1.Node) (vmSetN
|
|||||||
sort.Strings(*scaleSetNames)
|
sort.Strings(*scaleSetNames)
|
||||||
|
|
||||||
if !isAuto {
|
if !isAuto {
|
||||||
if serviceVMSetNames == nil || len(serviceVMSetNames) == 0 {
|
if len(serviceVMSetNames) == 0 {
|
||||||
return nil, fmt.Errorf("service annotation for LoadBalancerMode is empty, it should have __auto__ or availability sets value")
|
return nil, fmt.Errorf("service annotation for LoadBalancerMode is empty, it should have __auto__ or availability sets value")
|
||||||
}
|
}
|
||||||
// validate scale set exists
|
// validate scale set exists
|
||||||
@ -782,10 +782,10 @@ func (ss *scaleSet) GetVMSetNames(service *v1.Service, nodes []*v1.Node) (vmSetN
|
|||||||
return nil, fmt.Errorf("scale set (%s) - not found", serviceVMSetNames[sasx])
|
return nil, fmt.Errorf("scale set (%s) - not found", serviceVMSetNames[sasx])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
vmSetNames = &serviceVMSetNames
|
scaleSetNames = &serviceVMSetNames
|
||||||
}
|
}
|
||||||
|
|
||||||
return vmSetNames, nil
|
return scaleSetNames, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// extractResourceGroupByVMSSNicID extracts the resource group name by vmss nicID.
|
// extractResourceGroupByVMSSNicID extracts the resource group name by vmss nicID.
|
||||||
|
@ -1436,7 +1436,7 @@ func TestGetVMSetNames(t *testing.T) {
|
|||||||
expectedVMSetNames: &[]string{"vmss"},
|
expectedVMSetNames: &[]string{"vmss"},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: "GetVMSetNames should return nil if the service has auto mode annotation",
|
description: "GetVMSetNames should return all scale sets if the service has auto mode annotation",
|
||||||
service: &v1.Service{
|
service: &v1.Service{
|
||||||
ObjectMeta: metav1.ObjectMeta{Annotations: map[string]string{ServiceAnnotationLoadBalancerMode: ServiceAnnotationLoadBalancerAutoModeValue}},
|
ObjectMeta: metav1.ObjectMeta{Annotations: map[string]string{ServiceAnnotationLoadBalancerMode: ServiceAnnotationLoadBalancerAutoModeValue}},
|
||||||
},
|
},
|
||||||
@ -1447,6 +1447,7 @@ func TestGetVMSetNames(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
expectedVMSetNames: &[]string{"vmss"},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: "GetVMSetNames should report the error if there's no such vmss",
|
description: "GetVMSetNames should report the error if there's no such vmss",
|
||||||
@ -1516,7 +1517,7 @@ func TestGetVMSetNames(t *testing.T) {
|
|||||||
|
|
||||||
vmSetNames, err := ss.GetVMSetNames(test.service, test.nodes)
|
vmSetNames, err := ss.GetVMSetNames(test.service, test.nodes)
|
||||||
assert.Equal(t, test.expectedErr, err, test.description+", but an error occurs")
|
assert.Equal(t, test.expectedErr, err, test.description+", but an error occurs")
|
||||||
assert.Equal(t, test.expectedVMSetNames, vmSetNames)
|
assert.Equal(t, test.expectedVMSetNames, vmSetNames, test.description)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user