Skip to content

Commit c86e28e

Browse files
fix: Fix pointer mutation causing incorrect maxPods values (aws#7020)
1 parent c894c32 commit c86e28e

File tree

4 files changed

+52
-40
lines changed

4 files changed

+52
-40
lines changed

charts/karpenter-crd/templates/karpenter.k8s.aws_ec2nodeclasses.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
33
kind: CustomResourceDefinition
44
metadata:
55
annotations:
6-
controller-gen.kubebuilder.io/version: v0.16.2
6+
controller-gen.kubebuilder.io/version: v0.16.3
77
name: ec2nodeclasses.karpenter.k8s.aws
88
spec:
99
group: karpenter.k8s.aws

pkg/apis/crds/karpenter.k8s.aws_ec2nodeclasses.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
33
kind: CustomResourceDefinition
44
metadata:
55
annotations:
6-
controller-gen.kubebuilder.io/version: v0.16.2
6+
controller-gen.kubebuilder.io/version: v0.16.3
77
name: ec2nodeclasses.karpenter.k8s.aws
88
spec:
99
group: karpenter.k8s.aws

pkg/providers/launchtemplate/suite_test.go

+40-36
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ var _ = Describe("LaunchTemplate Provider", func() {
289289
Expect(awsEnv.EC2API.CreateFleetBehavior.CalledWithInput.Len()).To(BeNumerically("==", 1))
290290
createFleetInput := awsEnv.EC2API.CreateFleetBehavior.CalledWithInput.Pop()
291291
Expect(len(createFleetInput.LaunchTemplateConfigs)).To(BeNumerically("==", awsEnv.EC2API.CalledWithCreateLaunchTemplateInput.Len()))
292-
Expect(awsEnv.EC2API.CalledWithCreateLaunchTemplateInput.Len()).To(BeNumerically(">=", 1))
292+
Expect(awsEnv.EC2API.CalledWithCreateLaunchTemplateInput.Len()).To(BeNumerically("==", 5))
293293
awsEnv.EC2API.CalledWithCreateLaunchTemplateInput.ForEach(func(ltInput *ec2.CreateLaunchTemplateInput) {
294294
launchTemplate, ok := lo.Find(createFleetInput.LaunchTemplateConfigs, func(ltConfig *ec2.FleetLaunchTemplateConfigRequest) bool {
295295
return *ltConfig.LaunchTemplateSpecification.LaunchTemplateName == *ltInput.LaunchTemplateName
@@ -315,7 +315,7 @@ var _ = Describe("LaunchTemplate Provider", func() {
315315
pod := coretest.UnschedulablePod()
316316
ExpectProvisioned(ctx, env.Client, cluster, cloudProvider, prov, pod)
317317
ExpectScheduled(ctx, env.Client, pod)
318-
Expect(awsEnv.EC2API.CalledWithCreateLaunchTemplateInput.Len()).To(BeNumerically(">=", 1))
318+
Expect(awsEnv.EC2API.CalledWithCreateLaunchTemplateInput.Len()).To(BeNumerically("==", 5))
319319
awsEnv.EC2API.CalledWithCreateLaunchTemplateInput.ForEach(func(ltInput *ec2.CreateLaunchTemplateInput) {
320320
Expect(*ltInput.LaunchTemplateData.IamInstanceProfile.Name).To(Equal("overridden-profile"))
321321
})
@@ -385,7 +385,7 @@ var _ = Describe("LaunchTemplate Provider", func() {
385385
pod := coretest.UnschedulablePod()
386386
ExpectProvisioned(ctx, env.Client, cluster, cloudProvider, prov, pod)
387387
ExpectScheduled(ctx, env.Client, pod)
388-
Expect(awsEnv.EC2API.CalledWithCreateLaunchTemplateInput.Len()).To(BeNumerically(">=", 1))
388+
Expect(awsEnv.EC2API.CalledWithCreateLaunchTemplateInput.Len()).To(BeNumerically("==", 2))
389389
awsEnv.EC2API.CalledWithCreateLaunchTemplateInput.ForEach(func(ltInput *ec2.CreateLaunchTemplateInput) {
390390
ltName := aws.StringValue(ltInput.LaunchTemplateName)
391391
lt, ok := awsEnv.LaunchTemplateCache.Get(ltName)
@@ -601,7 +601,7 @@ var _ = Describe("LaunchTemplate Provider", func() {
601601
pod := coretest.UnschedulablePod()
602602
ExpectProvisioned(ctx, env.Client, cluster, cloudProvider, prov, pod)
603603
ExpectScheduled(ctx, env.Client, pod)
604-
Expect(awsEnv.EC2API.CalledWithCreateLaunchTemplateInput.Len()).To(BeNumerically(">=", 1))
604+
Expect(awsEnv.EC2API.CalledWithCreateLaunchTemplateInput.Len()).To(BeNumerically("==", 5))
605605
awsEnv.EC2API.CalledWithCreateLaunchTemplateInput.ForEach(func(ltInput *ec2.CreateLaunchTemplateInput) {
606606
Expect(len(ltInput.LaunchTemplateData.BlockDeviceMappings)).To(Equal(1))
607607
Expect(*ltInput.LaunchTemplateData.BlockDeviceMappings[0].Ebs.VolumeSize).To(Equal(int64(20)))
@@ -617,7 +617,7 @@ var _ = Describe("LaunchTemplate Provider", func() {
617617
pod := coretest.UnschedulablePod()
618618
ExpectProvisioned(ctx, env.Client, cluster, cloudProvider, prov, pod)
619619
ExpectScheduled(ctx, env.Client, pod)
620-
Expect(awsEnv.EC2API.CalledWithCreateLaunchTemplateInput.Len()).To(BeNumerically(">=", 1))
620+
Expect(awsEnv.EC2API.CalledWithCreateLaunchTemplateInput.Len()).To(BeNumerically("==", 5))
621621
awsEnv.EC2API.CalledWithCreateLaunchTemplateInput.ForEach(func(ltInput *ec2.CreateLaunchTemplateInput) {
622622
Expect(len(ltInput.LaunchTemplateData.BlockDeviceMappings)).To(Equal(1))
623623
Expect(*ltInput.LaunchTemplateData.BlockDeviceMappings[0].Ebs.VolumeSize).To(Equal(int64(20)))
@@ -655,7 +655,7 @@ var _ = Describe("LaunchTemplate Provider", func() {
655655
pod := coretest.UnschedulablePod()
656656
ExpectProvisioned(ctx, env.Client, cluster, cloudProvider, prov, pod)
657657
ExpectScheduled(ctx, env.Client, pod)
658-
Expect(awsEnv.EC2API.CalledWithCreateLaunchTemplateInput.Len()).To(BeNumerically(">=", 1))
658+
Expect(awsEnv.EC2API.CalledWithCreateLaunchTemplateInput.Len()).To(BeNumerically("==", 5))
659659
awsEnv.EC2API.CalledWithCreateLaunchTemplateInput.ForEach(func(ltInput *ec2.CreateLaunchTemplateInput) {
660660
Expect(ltInput.LaunchTemplateData.BlockDeviceMappings[0].Ebs).To(Equal(&ec2.LaunchTemplateEbsBlockDeviceRequest{
661661
VolumeSize: aws.Int64(187),
@@ -705,7 +705,7 @@ var _ = Describe("LaunchTemplate Provider", func() {
705705
pod := coretest.UnschedulablePod()
706706
ExpectProvisioned(ctx, env.Client, cluster, cloudProvider, prov, pod)
707707
ExpectScheduled(ctx, env.Client, pod)
708-
Expect(awsEnv.EC2API.CalledWithCreateLaunchTemplateInput.Len()).To(BeNumerically(">=", 1))
708+
Expect(awsEnv.EC2API.CalledWithCreateLaunchTemplateInput.Len()).To(BeNumerically("==", 5))
709709
awsEnv.EC2API.CalledWithCreateLaunchTemplateInput.ForEach(func(ltInput *ec2.CreateLaunchTemplateInput) {
710710
// Both of these values are rounded up when converting to Gibibytes
711711
Expect(aws.Int64Value(ltInput.LaunchTemplateData.BlockDeviceMappings[0].Ebs.VolumeSize)).To(BeNumerically("==", 4))
@@ -718,7 +718,7 @@ var _ = Describe("LaunchTemplate Provider", func() {
718718
pod := coretest.UnschedulablePod()
719719
ExpectProvisioned(ctx, env.Client, cluster, cloudProvider, prov, pod)
720720
ExpectScheduled(ctx, env.Client, pod)
721-
Expect(awsEnv.EC2API.CalledWithCreateLaunchTemplateInput.Len()).To(BeNumerically(">=", 1))
721+
Expect(awsEnv.EC2API.CalledWithCreateLaunchTemplateInput.Len()).To(BeNumerically("==", 5))
722722
awsEnv.EC2API.CalledWithCreateLaunchTemplateInput.ForEach(func(ltInput *ec2.CreateLaunchTemplateInput) {
723723
Expect(len(ltInput.LaunchTemplateData.BlockDeviceMappings)).To(Equal(2))
724724
// Bottlerocket control volume
@@ -738,7 +738,7 @@ var _ = Describe("LaunchTemplate Provider", func() {
738738
pod := coretest.UnschedulablePod()
739739
ExpectProvisioned(ctx, env.Client, cluster, cloudProvider, prov, pod)
740740
ExpectScheduled(ctx, env.Client, pod)
741-
Expect(awsEnv.EC2API.CalledWithCreateLaunchTemplateInput.Len()).To(BeNumerically(">=", 1))
741+
Expect(awsEnv.EC2API.CalledWithCreateLaunchTemplateInput.Len()).To(BeNumerically("==", 2))
742742
awsEnv.EC2API.CalledWithCreateLaunchTemplateInput.ForEach(func(ltInput *ec2.CreateLaunchTemplateInput) {
743743
Expect(len(ltInput.LaunchTemplateData.BlockDeviceMappings)).To(Equal(0))
744744
})
@@ -763,7 +763,7 @@ var _ = Describe("LaunchTemplate Provider", func() {
763763
pod := coretest.UnschedulablePod()
764764
ExpectProvisioned(ctx, env.Client, cluster, cloudProvider, prov, pod)
765765
ExpectScheduled(ctx, env.Client, pod)
766-
Expect(awsEnv.EC2API.CalledWithCreateLaunchTemplateInput.Len()).To(BeNumerically(">=", 1))
766+
Expect(awsEnv.EC2API.CalledWithCreateLaunchTemplateInput.Len()).To(BeNumerically("==", 2))
767767
awsEnv.EC2API.CalledWithCreateLaunchTemplateInput.ForEach(func(ltInput *ec2.CreateLaunchTemplateInput) {
768768
Expect(len(ltInput.LaunchTemplateData.BlockDeviceMappings)).To(Equal(1))
769769
Expect(*ltInput.LaunchTemplateData.BlockDeviceMappings[0].Ebs.VolumeSize).To(Equal(int64(40)))
@@ -1127,6 +1127,19 @@ var _ = Describe("LaunchTemplate Provider", func() {
11271127
ExpectScheduled(ctx, env.Client, pod)
11281128
ExpectLaunchTemplatesCreatedWithUserDataContaining("--use-max-pods false", "--max-pods=10")
11291129
})
1130+
It("should generate different launch templates for different --max-pods values when specifying kubelet configuration", func() {
1131+
// We validate that we no longer combine instance types into the same launch template with the same --max-pods values
1132+
// that shouldn't have been combined but were combined due to a pointer error
1133+
nodeClass.Spec.Kubelet = &v1.KubeletConfiguration{
1134+
ClusterDNS: []string{"test"},
1135+
}
1136+
ExpectApplied(ctx, env.Client, nodePool, nodeClass)
1137+
pod := coretest.UnschedulablePod()
1138+
ExpectProvisioned(ctx, env.Client, cluster, cloudProvider, prov, pod)
1139+
ExpectScheduled(ctx, env.Client, pod)
1140+
// We expect to generate 5 launch templates for our image/max-pods combination where we were only generating 2 before
1141+
Expect(awsEnv.EC2API.CalledWithCreateLaunchTemplateInput.Len()).To(BeNumerically("==", 5))
1142+
})
11301143
It("should specify --system-reserved when overriding system reserved values", func() {
11311144
nodeClass.Spec.Kubelet = &v1.KubeletConfiguration{
11321145
SystemReserved: map[string]string{
@@ -1139,7 +1152,7 @@ var _ = Describe("LaunchTemplate Provider", func() {
11391152
pod := coretest.UnschedulablePod()
11401153
ExpectProvisioned(ctx, env.Client, cluster, cloudProvider, prov, pod)
11411154
ExpectScheduled(ctx, env.Client, pod)
1142-
Expect(awsEnv.EC2API.CalledWithCreateLaunchTemplateInput.Len()).To(BeNumerically(">=", 1))
1155+
Expect(awsEnv.EC2API.CalledWithCreateLaunchTemplateInput.Len()).To(BeNumerically("==", 5))
11431156
awsEnv.EC2API.CalledWithCreateLaunchTemplateInput.ForEach(func(ltInput *ec2.CreateLaunchTemplateInput) {
11441157
userData, err := base64.StdEncoding.DecodeString(*ltInput.LaunchTemplateData.UserData)
11451158
Expect(err).To(BeNil())
@@ -1166,7 +1179,7 @@ var _ = Describe("LaunchTemplate Provider", func() {
11661179
pod := coretest.UnschedulablePod()
11671180
ExpectProvisioned(ctx, env.Client, cluster, cloudProvider, prov, pod)
11681181
ExpectScheduled(ctx, env.Client, pod)
1169-
Expect(awsEnv.EC2API.CalledWithCreateLaunchTemplateInput.Len()).To(BeNumerically(">=", 1))
1182+
Expect(awsEnv.EC2API.CalledWithCreateLaunchTemplateInput.Len()).To(BeNumerically("==", 5))
11701183
awsEnv.EC2API.CalledWithCreateLaunchTemplateInput.ForEach(func(ltInput *ec2.CreateLaunchTemplateInput) {
11711184
userData, err := base64.StdEncoding.DecodeString(*ltInput.LaunchTemplateData.UserData)
11721185
Expect(err).To(BeNil())
@@ -1193,7 +1206,7 @@ var _ = Describe("LaunchTemplate Provider", func() {
11931206
pod := coretest.UnschedulablePod()
11941207
ExpectProvisioned(ctx, env.Client, cluster, cloudProvider, prov, pod)
11951208
ExpectScheduled(ctx, env.Client, pod)
1196-
Expect(awsEnv.EC2API.CalledWithCreateLaunchTemplateInput.Len()).To(BeNumerically(">=", 1))
1209+
Expect(awsEnv.EC2API.CalledWithCreateLaunchTemplateInput.Len()).To(BeNumerically("==", 5))
11971210
awsEnv.EC2API.CalledWithCreateLaunchTemplateInput.ForEach(func(ltInput *ec2.CreateLaunchTemplateInput) {
11981211
userData, err := base64.StdEncoding.DecodeString(*ltInput.LaunchTemplateData.UserData)
11991212
Expect(err).To(BeNil())
@@ -1225,7 +1238,7 @@ var _ = Describe("LaunchTemplate Provider", func() {
12251238
pod := coretest.UnschedulablePod()
12261239
ExpectProvisioned(ctx, env.Client, cluster, cloudProvider, prov, pod)
12271240
ExpectScheduled(ctx, env.Client, pod)
1228-
Expect(awsEnv.EC2API.CalledWithCreateLaunchTemplateInput.Len()).To(BeNumerically(">=", 1))
1241+
Expect(awsEnv.EC2API.CalledWithCreateLaunchTemplateInput.Len()).To(BeNumerically("==", 5))
12291242
awsEnv.EC2API.CalledWithCreateLaunchTemplateInput.ForEach(func(ltInput *ec2.CreateLaunchTemplateInput) {
12301243
userData, err := base64.StdEncoding.DecodeString(*ltInput.LaunchTemplateData.UserData)
12311244
Expect(err).To(BeNil())
@@ -1257,7 +1270,7 @@ var _ = Describe("LaunchTemplate Provider", func() {
12571270
pod := coretest.UnschedulablePod()
12581271
ExpectProvisioned(ctx, env.Client, cluster, cloudProvider, prov, pod)
12591272
ExpectScheduled(ctx, env.Client, pod)
1260-
Expect(awsEnv.EC2API.CalledWithCreateLaunchTemplateInput.Len()).To(BeNumerically(">=", 1))
1273+
Expect(awsEnv.EC2API.CalledWithCreateLaunchTemplateInput.Len()).To(BeNumerically("==", 5))
12611274
awsEnv.EC2API.CalledWithCreateLaunchTemplateInput.ForEach(func(ltInput *ec2.CreateLaunchTemplateInput) {
12621275
userData, err := base64.StdEncoding.DecodeString(*ltInput.LaunchTemplateData.UserData)
12631276
Expect(err).To(BeNil())
@@ -1437,7 +1450,7 @@ var _ = Describe("LaunchTemplate Provider", func() {
14371450
pod := coretest.UnschedulablePod()
14381451
ExpectProvisioned(ctx, env.Client, cluster, cloudProvider, prov, pod)
14391452
ExpectScheduled(ctx, env.Client, pod)
1440-
Expect(awsEnv.EC2API.CalledWithCreateLaunchTemplateInput.Len()).To(BeNumerically(">=", 1))
1453+
Expect(awsEnv.EC2API.CalledWithCreateLaunchTemplateInput.Len()).To(BeNumerically("==", 2))
14411454
awsEnv.EC2API.CalledWithCreateLaunchTemplateInput.ForEach(func(ltInput *ec2.CreateLaunchTemplateInput) {
14421455
userData, err := base64.StdEncoding.DecodeString(*ltInput.LaunchTemplateData.UserData)
14431456
Expect(err).To(BeNil())
@@ -1461,7 +1474,7 @@ var _ = Describe("LaunchTemplate Provider", func() {
14611474
pod := coretest.UnschedulablePod()
14621475
ExpectProvisioned(ctx, env.Client, cluster, cloudProvider, prov, pod)
14631476
ExpectScheduled(ctx, env.Client, pod)
1464-
Expect(awsEnv.EC2API.CalledWithCreateLaunchTemplateInput.Len()).To(BeNumerically(">=", 1))
1477+
Expect(awsEnv.EC2API.CalledWithCreateLaunchTemplateInput.Len()).To(BeNumerically("==", 5))
14651478
awsEnv.EC2API.CalledWithCreateLaunchTemplateInput.ForEach(func(ltInput *ec2.CreateLaunchTemplateInput) {
14661479
userData, err := base64.StdEncoding.DecodeString(*ltInput.LaunchTemplateData.UserData)
14671480
Expect(err).To(BeNil())
@@ -1485,7 +1498,7 @@ var _ = Describe("LaunchTemplate Provider", func() {
14851498
pod := coretest.UnschedulablePod()
14861499
ExpectProvisioned(ctx, env.Client, cluster, cloudProvider, prov, pod)
14871500
ExpectScheduled(ctx, env.Client, pod)
1488-
Expect(awsEnv.EC2API.CalledWithCreateLaunchTemplateInput.Len()).To(BeNumerically(">=", 1))
1501+
Expect(awsEnv.EC2API.CalledWithCreateLaunchTemplateInput.Len()).To(BeNumerically("==", 5))
14891502
awsEnv.EC2API.CalledWithCreateLaunchTemplateInput.ForEach(func(ltInput *ec2.CreateLaunchTemplateInput) {
14901503
userData, err := base64.StdEncoding.DecodeString(*ltInput.LaunchTemplateData.UserData)
14911504
Expect(err).To(BeNil())
@@ -1505,7 +1518,7 @@ var _ = Describe("LaunchTemplate Provider", func() {
15051518
pod := coretest.UnschedulablePod()
15061519
ExpectProvisioned(ctx, env.Client, cluster, cloudProvider, prov, pod)
15071520
ExpectScheduled(ctx, env.Client, pod)
1508-
Expect(awsEnv.EC2API.CalledWithCreateLaunchTemplateInput.Len()).To(BeNumerically(">=", 1))
1521+
Expect(awsEnv.EC2API.CalledWithCreateLaunchTemplateInput.Len()).To(BeNumerically("==", 2))
15091522
awsEnv.EC2API.CalledWithCreateLaunchTemplateInput.ForEach(func(ltInput *ec2.CreateLaunchTemplateInput) {
15101523
userData, err := base64.StdEncoding.DecodeString(*ltInput.LaunchTemplateData.UserData)
15111524
Expect(err).To(BeNil())
@@ -1523,7 +1536,7 @@ var _ = Describe("LaunchTemplate Provider", func() {
15231536
pod := coretest.UnschedulablePod()
15241537
ExpectProvisioned(ctx, env.Client, cluster, cloudProvider, prov, pod)
15251538
ExpectScheduled(ctx, env.Client, pod)
1526-
Expect(awsEnv.EC2API.CalledWithCreateLaunchTemplateInput.Len()).To(BeNumerically(">=", 1))
1539+
Expect(awsEnv.EC2API.CalledWithCreateLaunchTemplateInput.Len()).To(BeNumerically("==", 5))
15271540
awsEnv.EC2API.CalledWithCreateLaunchTemplateInput.ForEach(func(ltInput *ec2.CreateLaunchTemplateInput) {
15281541
userData, err := base64.StdEncoding.DecodeString(*ltInput.LaunchTemplateData.UserData)
15291542
Expect(err).To(BeNil())
@@ -1543,7 +1556,7 @@ var _ = Describe("LaunchTemplate Provider", func() {
15431556
pod := coretest.UnschedulablePod()
15441557
ExpectProvisioned(ctx, env.Client, cluster, cloudProvider, prov, pod)
15451558
ExpectScheduled(ctx, env.Client, pod)
1546-
Expect(awsEnv.EC2API.CalledWithCreateLaunchTemplateInput.Len()).To(BeNumerically(">=", 1))
1559+
Expect(awsEnv.EC2API.CalledWithCreateLaunchTemplateInput.Len()).To(BeNumerically("==", 5))
15471560
awsEnv.EC2API.CalledWithCreateLaunchTemplateInput.ForEach(func(ltInput *ec2.CreateLaunchTemplateInput) {
15481561
userData, err := base64.StdEncoding.DecodeString(*ltInput.LaunchTemplateData.UserData)
15491562
Expect(err).To(BeNil())
@@ -1560,7 +1573,7 @@ var _ = Describe("LaunchTemplate Provider", func() {
15601573
pod := coretest.UnschedulablePod()
15611574
ExpectProvisioned(ctx, env.Client, cluster, cloudProvider, prov, pod)
15621575
ExpectScheduled(ctx, env.Client, pod)
1563-
Expect(awsEnv.EC2API.CalledWithCreateLaunchTemplateInput.Len()).To(BeNumerically(">=", 1))
1576+
Expect(awsEnv.EC2API.CalledWithCreateLaunchTemplateInput.Len()).To(BeNumerically("==", 2))
15641577
awsEnv.EC2API.CalledWithCreateLaunchTemplateInput.ForEach(func(ltInput *ec2.CreateLaunchTemplateInput) {
15651578
userData, err := base64.StdEncoding.DecodeString(*ltInput.LaunchTemplateData.UserData)
15661579
Expect(err).To(BeNil())
@@ -1578,7 +1591,7 @@ var _ = Describe("LaunchTemplate Provider", func() {
15781591
pod := coretest.UnschedulablePod()
15791592
ExpectProvisioned(ctx, env.Client, cluster, cloudProvider, prov, pod)
15801593
ExpectScheduled(ctx, env.Client, pod)
1581-
Expect(awsEnv.EC2API.CalledWithCreateLaunchTemplateInput.Len()).To(BeNumerically(">=", 1))
1594+
Expect(awsEnv.EC2API.CalledWithCreateLaunchTemplateInput.Len()).To(BeNumerically("==", 5))
15821595
awsEnv.EC2API.CalledWithCreateLaunchTemplateInput.ForEach(func(ltInput *ec2.CreateLaunchTemplateInput) {
15831596
userData, err := base64.StdEncoding.DecodeString(*ltInput.LaunchTemplateData.UserData)
15841597
Expect(err).To(BeNil())
@@ -1861,7 +1874,7 @@ var _ = Describe("LaunchTemplate Provider", func() {
18611874
pod := coretest.UnschedulablePod()
18621875
ExpectProvisioned(ctx, env.Client, cluster, cloudProvider, prov, pod)
18631876
ExpectScheduled(ctx, env.Client, pod)
1864-
Expect(awsEnv.EC2API.CalledWithCreateLaunchTemplateInput.Len()).To(BeNumerically(">=", 1))
1877+
Expect(awsEnv.EC2API.CalledWithCreateLaunchTemplateInput.Len()).To(BeNumerically("==", 1))
18651878
awsEnv.EC2API.CalledWithCreateLaunchTemplateInput.ForEach(func(ltInput *ec2.CreateLaunchTemplateInput) {
18661879
Expect("ami-123").To(Equal(*ltInput.LaunchTemplateData.ImageId))
18671880
})
@@ -1988,7 +2001,7 @@ var _ = Describe("LaunchTemplate Provider", func() {
19882001
pod := coretest.UnschedulablePod()
19892002
ExpectProvisioned(ctx, env.Client, cluster, cloudProvider, prov, pod)
19902003
ExpectScheduled(ctx, env.Client, pod)
1991-
Expect(awsEnv.EC2API.CalledWithCreateLaunchTemplateInput.Len()).To(BeNumerically(">=", 1))
2004+
Expect(awsEnv.EC2API.CalledWithCreateLaunchTemplateInput.Len()).To(BeNumerically("==", 1))
19922005
awsEnv.EC2API.CalledWithCreateLaunchTemplateInput.ForEach(func(ltInput *ec2.CreateLaunchTemplateInput) {
19932006
Expect("ami-456").To(Equal(*ltInput.LaunchTemplateData.ImageId))
19942007
})
@@ -2127,7 +2140,7 @@ var _ = Describe("LaunchTemplate Provider", func() {
21272140
pod := coretest.UnschedulablePod()
21282141
ExpectProvisioned(ctx, env.Client, cluster, cloudProvider, prov, pod)
21292142
ExpectScheduled(ctx, env.Client, pod)
2130-
Expect(awsEnv.EC2API.CalledWithCreateLaunchTemplateInput.Len()).To(BeNumerically(">=", 1))
2143+
Expect(awsEnv.EC2API.CalledWithCreateLaunchTemplateInput.Len()).To(BeNumerically("==", 5))
21312144
awsEnv.EC2API.CalledWithCreateLaunchTemplateInput.ForEach(func(ltInput *ec2.CreateLaunchTemplateInput) {
21322145
Expect(aws.BoolValue(ltInput.LaunchTemplateData.Monitoring.Enabled)).To(BeFalse())
21332146
})
@@ -2139,7 +2152,7 @@ var _ = Describe("LaunchTemplate Provider", func() {
21392152
pod := coretest.UnschedulablePod()
21402153
ExpectProvisioned(ctx, env.Client, cluster, cloudProvider, prov, pod)
21412154
ExpectScheduled(ctx, env.Client, pod)
2142-
Expect(awsEnv.EC2API.CalledWithCreateLaunchTemplateInput.Len()).To(BeNumerically(">=", 1))
2155+
Expect(awsEnv.EC2API.CalledWithCreateLaunchTemplateInput.Len()).To(BeNumerically("==", 5))
21432156
awsEnv.EC2API.CalledWithCreateLaunchTemplateInput.ForEach(func(ltInput *ec2.CreateLaunchTemplateInput) {
21442157
Expect(aws.BoolValue(ltInput.LaunchTemplateData.Monitoring.Enabled)).To(BeTrue())
21452158
})
@@ -2158,15 +2171,6 @@ func ExpectTags(tags []*ec2.Tag, expected map[string]string) {
21582171
}
21592172
}
21602173

2161-
func ExpectTagsNotFound(tags []*ec2.Tag, expectNotFound map[string]string) {
2162-
GinkgoHelper()
2163-
existingTags := lo.SliceToMap(tags, func(t *ec2.Tag) (string, string) { return *t.Key, *t.Value })
2164-
for k, v := range expectNotFound {
2165-
elem, ok := existingTags[k]
2166-
Expect(!ok || v != elem).To(BeTrue())
2167-
}
2168-
}
2169-
21702174
func ExpectLaunchTemplatesCreatedWithUserDataContaining(substrings ...string) {
21712175
GinkgoHelper()
21722176
Expect(awsEnv.EC2API.CalledWithCreateLaunchTemplateInput.Len()).To(BeNumerically(">=", 1))

0 commit comments

Comments
 (0)