Skip to content

Commit

Permalink
Clean up error messages and return values
Browse files Browse the repository at this point in the history
Co-authored-by: Carter <[email protected]>
  • Loading branch information
mselim00 and cartermckinnon authored Dec 6, 2024
1 parent d59e57e commit ec36c56
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions kubetest2/internal/deployers/eksapi/nodegroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func (m *NodegroupManager) createManagedNodegroup(infra *Infrastructure, cluster
// this only supports 17 pods, which can cause some flakes in the k8s e2e suite
defaultInstanceTypes, err := m.getValidDefaultInstanceTypesByEKSAMIType(input.AmiType)
if err != nil {
return err
return fmt.Errorf("failed to get default instance types for AmiType: %s: %v", input.AmiType, err)
}
input.InstanceTypes = defaultInstanceTypes
}
Expand Down Expand Up @@ -537,15 +537,15 @@ func (m *NodegroupManager) getSubnetWithCapacity(infra *Infrastructure, opts *de
func (m *NodegroupManager) getValidDefaultInstanceTypesByEKSAMIType(amiType ekstypes.AMITypes) ([]string, error) {
defaults, ok := defaultInstanceTypesByEKSAMITypes[amiType]
if !ok {
return []string{}, fmt.Errorf("no default instance types known for AmiType: %v", amiType)
return nil, fmt.Errorf("no default instance types known for AmiType: %v", amiType)
}
return m.getValidInstanceTypesFromList(defaults)
}

func (m *NodegroupManager) getValidDefaultInstanceTypesByEC2Arch(arch ec2types.ArchitectureValues) ([]string, error) {
defaults, ok := defaultInstanceTypesByEC2ArchitectureValues[arch]
if !ok {
return []string{}, fmt.Errorf("no default instance types known for AMI architecture: %v", arch)
return nil, fmt.Errorf("no default instance types known for AMI architecture: %v", arch)
}
return m.getValidInstanceTypesFromList(defaults)
}
Expand All @@ -562,7 +562,7 @@ func (m *NodegroupManager) getValidInstanceTypesFromList(desiredInstanceTypes []
if errors.As(err, &apierr) && apierr.ErrorCode() == "InvalidInstanceType" {
klog.Infof("Eliminating instance type %s as an option", instanceType)
} else {
return []string{}, fmt.Errorf("could not determine invalid instance types, received error: %s", err)
return nil, fmt.Errorf("failed to describe instance type: %s: %v", instanceType, err)
}
} else {
validInstanceTypes = append(validInstanceTypes, instanceType)
Expand Down

0 comments on commit ec36c56

Please sign in to comment.