diff --git a/pkg/providers/pricing/controller.go b/pkg/providers/pricing/controller.go index 130cff0334eb..3e24cd9ba1e3 100644 --- a/pkg/providers/pricing/controller.go +++ b/pkg/providers/pricing/controller.go @@ -16,9 +16,10 @@ package pricing import ( "context" - "github.com/aws/karpenter-provider-aws/pkg/operator/options" "time" + "github.com/aws/karpenter-provider-aws/pkg/operator/options" + lop "github.com/samber/lo/parallel" "go.uber.org/multierr" "sigs.k8s.io/controller-runtime/pkg/manager" diff --git a/pkg/providers/pricing/suite_test.go b/pkg/providers/pricing/suite_test.go index 46d6a59cfc9a..7eb81bc5b2c3 100644 --- a/pkg/providers/pricing/suite_test.go +++ b/pkg/providers/pricing/suite_test.go @@ -263,23 +263,6 @@ var _ = Describe("Pricing", func() { To(ContainElements("Linux/UNIX", "Linux/UNIX (Amazon VPC)")) }) It("should return static on-demand data when in isolated-vpc", func() { - ctx = options.ToContext(ctx, test.Options(test.OptionsFields{ - IsolatedVPC: lo.ToPtr(true), - })) - awsEnv.PricingAPI.GetProductsOutput.Set(&awspricing.GetProductsOutput{ - PriceList: []aws.JSONValue{ - fake.NewOnDemandPrice("c98.large", 1.20), - fake.NewOnDemandPrice("c99.large", 1.23), - }, - }) - // this should fail as we are not providing spot pricing info which will be - // called even when isolated-vpc is set - ExpectReconcileFailed(ctx, controller, types.NamespacedName{}) - price, ok := awsEnv.PricingProvider.OnDemandPrice("c5.large") - Expect(ok).To(BeTrue()) - Expect(price).To(BeNumerically(">", 0)) - }) - It("should return spot pricing data when in isolated-vpc", func() { ctx = options.ToContext(ctx, test.Options(test.OptionsFields{ IsolatedVPC: lo.ToPtr(true), })) @@ -300,15 +283,19 @@ var _ = Describe("Pricing", func() { }, }, }) + awsEnv.PricingAPI.GetProductsOutput.Set(&awspricing.GetProductsOutput{ PriceList: []aws.JSONValue{ fake.NewOnDemandPrice("c98.large", 1.20), + fake.NewOnDemandPrice("c99.large", 1.23), }, }) - ExpectReconcileSucceeded(ctx, controller, types.NamespacedName{}) + price, ok := awsEnv.PricingProvider.OnDemandPrice("c5.large") + Expect(ok).To(BeTrue()) + Expect(price).To(BeNumerically(">", 0)) - price, ok := awsEnv.PricingProvider.SpotPrice("c98.large", "test-zone-1b") + price, ok = awsEnv.PricingProvider.SpotPrice("c98.large", "test-zone-1b") Expect(ok).To(BeTrue()) Expect(price).To(BeNumerically("==", 1.10)) Expect(getPricingEstimateMetricValue("c98.large", ec2.UsageClassTypeSpot, "test-zone-1b")).To(BeNumerically("==", 1.10))