Skip to content

Commit

Permalink
chore: Fix some misses in v1beta1 migration (#4605)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathan-innis committed Sep 11, 2023
1 parent 85c326a commit 065eb27
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
8 changes: 5 additions & 3 deletions pkg/cloudprovider/drift.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,12 @@ func (c *CloudProvider) isAMIDrifted(ctx context.Context, nodeClaim *corev1beta1
return "", nil
}

// Checks if the security groups are drifted, by comparing the NodeClass.Status.Subnets
// to the ec2 instance subnets
func (c *CloudProvider) isSubnetDrifted(instance *instance.Instance, nodeClass *v1beta1.NodeClass) (cloudprovider.DriftReason, error) {
// If the node template status does not have subnets, wait for the subnets to be populated before continuing
if len(nodeClass.Status.Subnets) == 0 {
return "", fmt.Errorf("AWSNodeTemplate has no subnets")
return "", fmt.Errorf("no subnets exist in status")
}
_, found := lo.Find(nodeClass.Status.Subnets, func(subnet v1beta1.Subnet) bool {
return subnet.ID == instance.SubnetID
Expand All @@ -107,7 +109,7 @@ func (c *CloudProvider) isSubnetDrifted(instance *instance.Instance, nodeClass *
return "", nil
}

// Checks if the security groups are drifted, by comparing the AWSNodeTemplate.Status.SecurityGroups
// Checks if the security groups are drifted, by comparing the NodeClass.Status.SecurityGroups
// to the ec2 instance security groups
func (c *CloudProvider) areSecurityGroupsDrifted(ec2Instance *instance.Instance, nodeClass *v1beta1.NodeClass) (cloudprovider.DriftReason, error) {
// nodeClass.Spec.SecurityGroupSelector can be nil if the user is using a launchTemplateName to define SecurityGroups
Expand All @@ -117,7 +119,7 @@ func (c *CloudProvider) areSecurityGroupsDrifted(ec2Instance *instance.Instance,
}
securityGroupIds := sets.New(lo.Map(nodeClass.Status.SecurityGroups, func(sg v1beta1.SecurityGroup, _ int) string { return sg.ID })...)
if len(securityGroupIds) == 0 {
return "", fmt.Errorf("no security groups exist in the AWSNodeTemplate Status")
return "", fmt.Errorf("no security groups exist in status")
}

if !securityGroupIds.Equal(sets.New(ec2Instance.SecurityGroupIDs...)) {
Expand Down
4 changes: 2 additions & 2 deletions pkg/providers/amifamily/bottlerocket.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,13 @@ func (b Bottlerocket) EphemeralBlockDevice() *string {

// PodsPerCoreEnabled is currently disabled for Bottlerocket AMIFamily because it does
// not currently support the podsPerCore parameter passed through the kubernetes settings TOML userData
// If a Provisioner sets the podsPerCore value when using the Bottlerocket AMIFamily in the provider,
// If a NodePool sets the podsPerCore value when using the Bottlerocket AMIFamily in the provider,
// podsPerCore will be ignored
// https://github.com/bottlerocket-os/bottlerocket/issues/1721

// EvictionSoftEnabled is currently disabled for Bottlerocket AMIFamily because it does
// not currently support the evictionSoft parameter passed through the kubernetes settings TOML userData
// If a Provisioner sets the evictionSoft value when using the Bottlerocket AMIFamily in the provider,
// If a NodePool sets the evictionSoft value when using the Bottlerocket AMIFamily in the provider,
// evictionSoft will be ignored
// https://github.com/bottlerocket-os/bottlerocket/issues/1445

Expand Down
2 changes: 1 addition & 1 deletion pkg/providers/instancetype/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func computeRequirements(ctx context.Context, info *ec2.InstanceTypeInfo, offeri
requirements.Get(lo.Ternary(nodeClass.IsNodeTemplate, v1alpha1.LabelInstanceSize, v1beta1.LabelInstanceSize)).Insert(instanceTypeParts[1])
}
if info.InstanceStorageInfo != nil && aws.StringValue(info.InstanceStorageInfo.NvmeSupport) != ec2.EphemeralNvmeSupportUnsupported {
requirements[v1alpha1.LabelInstanceLocalNVME].Insert(fmt.Sprint(aws.Int64Value(info.InstanceStorageInfo.TotalSizeInGB)))
requirements[lo.Ternary(nodeClass.IsNodeTemplate, v1alpha1.LabelInstanceLocalNVME, v1beta1.LabelInstanceLocalNVME)].Insert(fmt.Sprint(aws.Int64Value(info.InstanceStorageInfo.TotalSizeInGB)))
}
// Network bandwidth
if bandwidth, ok := InstanceTypeBandwidthMegabits[aws.StringValue(info.InstanceType)]; ok {
Expand Down

0 comments on commit 065eb27

Please sign in to comment.