Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[rel-v0.16] Avoids panics when VM type isn't found during scale from zero #78

Merged
merged 1 commit into from May 11, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 16 additions & 5 deletions cluster-autoscaler/cloudprovider/mcm/mcm_manager.go
Expand Up @@ -628,7 +628,10 @@ func (m *McmManager) GetMachineDeploymentNodeTemplate(machinedeployment *Machine
if err != nil {
return nil, fmt.Errorf("Unable to fetch AWSMachineClass object %s, Error: %v", machineClass.Name, err)
}
awsInstance := aws.InstanceTypes[mc.Spec.MachineType]
awsInstance, exists := aws.InstanceTypes[mc.Spec.MachineType]
if !exists {
return nil, fmt.Errorf("Unable to fetch details for VM type %s", mc.Spec.MachineType)
}
instance = instanceType{
InstanceType: awsInstance.InstanceType,
VCPU: awsInstance.VCPU,
Expand All @@ -642,7 +645,10 @@ func (m *McmManager) GetMachineDeploymentNodeTemplate(machinedeployment *Machine
if err != nil {
return nil, fmt.Errorf("Unable to fetch AzureMachineClass object %s, Error: %v", machineClass.Name, err)
}
azureInstance := azure.InstanceTypes[mc.Spec.Properties.HardwareProfile.VMSize]
azureInstance, exists := azure.InstanceTypes[mc.Spec.Properties.HardwareProfile.VMSize]
if !exists {
return nil, fmt.Errorf("Unable to fetch details for VM type %s", mc.Spec.Properties.HardwareProfile.VMSize)
}
instance = instanceType{
InstanceType: azureInstance.InstanceType,
VCPU: azureInstance.VCPU,
Expand All @@ -666,7 +672,10 @@ func (m *McmManager) GetMachineDeploymentNodeTemplate(machinedeployment *Machine
return nil, fmt.Errorf("Unable to convert from %s to %s for %s, Error: %v", kindMachineClass, providerAWS, machinedeployment.Name, err)
}

awsInstance := aws.InstanceTypes[providerSpec.MachineType]
awsInstance, exists := aws.InstanceTypes[providerSpec.MachineType]
if !exists {
return nil, fmt.Errorf("Unable to fetch details for VM type %s", providerSpec.MachineType)
}
instance = instanceType{
InstanceType: awsInstance.InstanceType,
VCPU: awsInstance.VCPU,
Expand All @@ -681,8 +690,10 @@ func (m *McmManager) GetMachineDeploymentNodeTemplate(machinedeployment *Machine
if err != nil {
return nil, fmt.Errorf("Unable to convert from %s to %s for %s, Error: %v", kindMachineClass, providerAzure, machinedeployment.Name, err)
}

azureInstance := aws.InstanceTypes[providerSpec.Properties.HardwareProfile.VMSize]
azureInstance, exists := azure.InstanceTypes[providerSpec.Properties.HardwareProfile.VMSize]
if !exists {
return nil, fmt.Errorf("Unable to fetch details for VM type %s", providerSpec.Properties.HardwareProfile.VMSize)
}
instance = instanceType{
InstanceType: azureInstance.InstanceType,
VCPU: azureInstance.VCPU,
Expand Down