@@ -19,7 +19,6 @@ import (
1919 "testing"
2020
2121 ec2types "github.com/aws/aws-sdk-go-v2/service/ec2/types"
22- "github.com/samber/lo"
2322 karpv1 "sigs.k8s.io/karpenter/pkg/apis/v1"
2423
2524 . "github.com/onsi/ginkgo/v2"
@@ -50,58 +49,17 @@ var _ = Describe("Cache", func() {
5049 Expect (unavailableOfferingCache .IsUnavailable (ec2types .InstanceTypeM5Xlarge , "test-zone-1b" , karpv1 .CapacityTypeSpot )).To (BeFalse ())
5150
5251 // m5.large on-demand should return that it's unavailable when we mark it
53- unavailableOfferingCache .MarkUnavailable (ctx , "test" , ec2types .InstanceTypeM5Large , "test-zone-1a" , karpv1 .CapacityTypeOnDemand )
54- Expect (unavailableOfferingCache .IsUnavailable (ec2types .InstanceTypeM5Large , "test-zone-1a" , karpv1 .CapacityTypeOnDemand )).To (BeTrue ())
55- Expect (unavailableOfferingCache .IsUnavailable (ec2types .InstanceTypeM5Xlarge , "test-zone-1b" , karpv1 .CapacityTypeSpot )).To (BeFalse ())
56-
57- // m5.xlarge shouldn't return that it's unavailable when marking an unrelated instance type
58- unavailableOfferingCache .MarkUnavailable (ctx , "test" , ec2types .InstanceTypeM5Large , "test-zone-1b" , karpv1 .CapacityTypeOnDemand )
59- Expect (unavailableOfferingCache .IsUnavailable (ec2types .InstanceTypeM5Large , "test-zone-1a" , karpv1 .CapacityTypeOnDemand )).To (BeTrue ())
60- Expect (unavailableOfferingCache .IsUnavailable (ec2types .InstanceTypeM5Xlarge , "test-zone-1b" , karpv1 .CapacityTypeSpot )).To (BeFalse ())
61-
62- // m5.xlarge spot should return that it's unavailable when we mark it
63- unavailableOfferingCache .MarkUnavailable (ctx , "test" , ec2types .InstanceTypeM5Xlarge , "test-zone-1b" , karpv1 .CapacityTypeSpot )
64- Expect (unavailableOfferingCache .IsUnavailable (ec2types .InstanceTypeM5Large , "test-zone-1a" , karpv1 .CapacityTypeOnDemand )).To (BeTrue ())
65- Expect (unavailableOfferingCache .IsUnavailable (ec2types .InstanceTypeM5Xlarge , "test-zone-1b" , karpv1 .CapacityTypeSpot )).To (BeTrue ())
66- })
67- It ("should mark offerings as unavailable when calling MarkUnavailableForFleetErr" , func () {
68- // offerings should initially not be marked as unavailable
69- Expect (unavailableOfferingCache .IsUnavailable (ec2types .InstanceTypeM5Large , "test-zone-1a" , karpv1 .CapacityTypeOnDemand )).To (BeFalse ())
70- Expect (unavailableOfferingCache .IsUnavailable (ec2types .InstanceTypeM5Xlarge , "test-zone-1b" , karpv1 .CapacityTypeSpot )).To (BeFalse ())
71-
72- // m5.large on-demand should return that it's unavailable when we mark it
73- unavailableOfferingCache .MarkUnavailableForFleetErr (ctx , ec2types.CreateFleetError {
74- LaunchTemplateAndOverrides : & ec2types.LaunchTemplateAndOverridesResponse {
75- Overrides : & ec2types.FleetLaunchTemplateOverrides {
76- InstanceType : ec2types .InstanceTypeM5Large ,
77- AvailabilityZone : lo .ToPtr ("test-zone-1a" ),
78- },
79- },
80- }, karpv1 .CapacityTypeOnDemand )
52+ unavailableOfferingCache .MarkUnavailable (ctx , ec2types .InstanceTypeM5Large , "test-zone-1a" , karpv1 .CapacityTypeOnDemand )
8153 Expect (unavailableOfferingCache .IsUnavailable (ec2types .InstanceTypeM5Large , "test-zone-1a" , karpv1 .CapacityTypeOnDemand )).To (BeTrue ())
8254 Expect (unavailableOfferingCache .IsUnavailable (ec2types .InstanceTypeM5Xlarge , "test-zone-1b" , karpv1 .CapacityTypeSpot )).To (BeFalse ())
8355
8456 // m5.xlarge shouldn't return that it's unavailable when marking an unrelated instance type
85- unavailableOfferingCache .MarkUnavailableForFleetErr (ctx , ec2types.CreateFleetError {
86- LaunchTemplateAndOverrides : & ec2types.LaunchTemplateAndOverridesResponse {
87- Overrides : & ec2types.FleetLaunchTemplateOverrides {
88- InstanceType : ec2types .InstanceTypeM5Large ,
89- AvailabilityZone : lo .ToPtr ("test-zone-1b" ),
90- },
91- },
92- }, karpv1 .CapacityTypeOnDemand )
57+ unavailableOfferingCache .MarkUnavailable (ctx , ec2types .InstanceTypeM5Large , "test-zone-1b" , karpv1 .CapacityTypeOnDemand )
9358 Expect (unavailableOfferingCache .IsUnavailable (ec2types .InstanceTypeM5Large , "test-zone-1a" , karpv1 .CapacityTypeOnDemand )).To (BeTrue ())
9459 Expect (unavailableOfferingCache .IsUnavailable (ec2types .InstanceTypeM5Xlarge , "test-zone-1b" , karpv1 .CapacityTypeSpot )).To (BeFalse ())
9560
9661 // m5.xlarge spot should return that it's unavailable when we mark it
97- unavailableOfferingCache .MarkUnavailableForFleetErr (ctx , ec2types.CreateFleetError {
98- LaunchTemplateAndOverrides : & ec2types.LaunchTemplateAndOverridesResponse {
99- Overrides : & ec2types.FleetLaunchTemplateOverrides {
100- InstanceType : ec2types .InstanceTypeM5Xlarge ,
101- AvailabilityZone : lo .ToPtr ("test-zone-1b" ),
102- },
103- },
104- }, karpv1 .CapacityTypeSpot )
62+ unavailableOfferingCache .MarkUnavailable (ctx , ec2types .InstanceTypeM5Xlarge , "test-zone-1b" , karpv1 .CapacityTypeSpot )
10563 Expect (unavailableOfferingCache .IsUnavailable (ec2types .InstanceTypeM5Large , "test-zone-1a" , karpv1 .CapacityTypeOnDemand )).To (BeTrue ())
10664 Expect (unavailableOfferingCache .IsUnavailable (ec2types .InstanceTypeM5Xlarge , "test-zone-1b" , karpv1 .CapacityTypeSpot )).To (BeTrue ())
10765 })
0 commit comments