From 065eb27243b2978b6d5fe5cca53bc29bc6421ab4 Mon Sep 17 00:00:00 2001 From: Jonathan Innis Date: Mon, 11 Sep 2023 09:38:56 -0700 Subject: [PATCH] chore: Fix some misses in v1beta1 migration (#4605) --- pkg/cloudprovider/drift.go | 8 +++++--- pkg/providers/amifamily/bottlerocket.go | 4 ++-- pkg/providers/instancetype/types.go | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/pkg/cloudprovider/drift.go b/pkg/cloudprovider/drift.go index 9ca6d71a13b4..ab83a8f5319e 100644 --- a/pkg/cloudprovider/drift.go +++ b/pkg/cloudprovider/drift.go @@ -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 @@ -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 @@ -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...)) { diff --git a/pkg/providers/amifamily/bottlerocket.go b/pkg/providers/amifamily/bottlerocket.go index 54dcc126acd9..4a5704a9434f 100644 --- a/pkg/providers/amifamily/bottlerocket.go +++ b/pkg/providers/amifamily/bottlerocket.go @@ -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 diff --git a/pkg/providers/instancetype/types.go b/pkg/providers/instancetype/types.go index 61924a434588..e408ce81e794 100644 --- a/pkg/providers/instancetype/types.go +++ b/pkg/providers/instancetype/types.go @@ -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 {