Skip to content
Snippets Groups Projects
Unverified Commit ced8a1e0 authored by Kubernetes Prow Robot's avatar Kubernetes Prow Robot Committed by GitHub
Browse files

Merge pull request #2038 from mboersma/fix-azure-case-sensitive-instance-type-1.3

[cherry pick] Look up Azure instance types case-insensitively 1.3
parents b94ad127 6b0e130c
No related branches found
No related tags found
No related merge requests found
...@@ -43,12 +43,16 @@ type VirtualMachineScaleSetsClientMock struct { ...@@ -43,12 +43,16 @@ type VirtualMachineScaleSetsClientMock struct {
// Get gets the VirtualMachineScaleSet by vmScaleSetName. // Get gets the VirtualMachineScaleSet by vmScaleSetName.
func (client *VirtualMachineScaleSetsClientMock) Get(ctx context.Context, resourceGroupName string, vmScaleSetName string) (result compute.VirtualMachineScaleSet, err error) { func (client *VirtualMachineScaleSetsClientMock) Get(ctx context.Context, resourceGroupName string, vmScaleSetName string) (result compute.VirtualMachineScaleSet, err error) {
capacity := int64(2) capacity := int64(2)
name := "Standard_D8_V3" // typo to test case-insensitive lookup
location := "switzerlandwest"
properties := compute.VirtualMachineScaleSetProperties{} properties := compute.VirtualMachineScaleSetProperties{}
return compute.VirtualMachineScaleSet{ return compute.VirtualMachineScaleSet{
Name: &vmScaleSetName, Name: &vmScaleSetName,
Sku: &compute.Sku{ Sku: &compute.Sku{
Capacity: &capacity, Capacity: &capacity,
Name: &name,
}, },
Location: &location,
VirtualMachineScaleSetProperties: &properties, VirtualMachineScaleSetProperties: &properties,
}, nil }, nil
} }
......
...@@ -383,7 +383,13 @@ func (scaleSet *ScaleSet) buildNodeFromTemplate(template compute.VirtualMachineS ...@@ -383,7 +383,13 @@ func (scaleSet *ScaleSet) buildNodeFromTemplate(template compute.VirtualMachineS
Capacity: apiv1.ResourceList{}, Capacity: apiv1.ResourceList{},
} }
vmssType := InstanceTypes[*template.Sku.Name] var vmssType *instanceType
for k := range InstanceTypes {
if strings.EqualFold(k, *template.Sku.Name) {
vmssType = InstanceTypes[k]
break
}
}
if vmssType == nil { if vmssType == nil {
return nil, fmt.Errorf("instance type %q not supported", *template.Sku.Name) return nil, fmt.Errorf("instance type %q not supported", *template.Sku.Name)
} }
......
...@@ -187,3 +187,23 @@ func TestScaleSetNodes(t *testing.T) { ...@@ -187,3 +187,23 @@ func TestScaleSetNodes(t *testing.T) {
assert.Equal(t, len(instances), 1) assert.Equal(t, len(instances), 1)
assert.Equal(t, instances[0], fakeProviderID) assert.Equal(t, instances[0], fakeProviderID)
} }
func TestTemplateNodeInfo(t *testing.T) {
provider := newTestProvider(t)
registered := provider.azureManager.RegisterAsg(
newTestScaleSet(provider.azureManager, "test-asg"))
assert.True(t, registered)
assert.Equal(t, len(provider.NodeGroups()), 1)
asg := ScaleSet{
manager: newTestAzureManager(t),
minSize: 1,
maxSize: 5,
}
asg.Name = "test-scale-set"
nodeInfo, err := asg.TemplateNodeInfo()
assert.NoError(t, err)
assert.NotNil(t, nodeInfo)
assert.NotEmpty(t, nodeInfo.Pods())
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment