From 2b05d9670e6b05326a8515688128c1e60de72a8d Mon Sep 17 00:00:00 2001 From: Hansuk Hong Date: Mon, 17 Feb 2025 08:02:21 +0900 Subject: [PATCH] ci: fix flaky test for stale instance type drift (#1990) Signed-off-by: flavono123 --- Makefile | 6 +++--- pkg/controllers/nodeclaim/disruption/drift_test.go | 7 +++++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 52b0ad2be5..3029f80f63 100644 --- a/Makefile +++ b/Makefile @@ -22,14 +22,14 @@ uninstall-kwok: ## Uninstall kwok provider build-with-kind: # build with kind assumes the image will be uploaded directly onto the kind control plane, without an image repository $(eval CONTROLLER_IMG=$(shell $(WITH_GOFLAGS) KO_DOCKER_REPO="$(KWOK_REPO)" ko build sigs.k8s.io/karpenter/kwok)) $(eval IMG_REPOSITORY=$(shell echo $(CONTROLLER_IMG) | cut -d ":" -f 1)) - $(eval IMG_TAG=latest) + $(eval IMG_TAG=latest) build: ## Build the Karpenter KWOK controller images using ko build $(eval CONTROLLER_IMG=$(shell $(WITH_GOFLAGS) KO_DOCKER_REPO="$(KWOK_REPO)" ko build -B sigs.k8s.io/karpenter/kwok)) $(eval IMG_REPOSITORY=$(shell echo $(CONTROLLER_IMG) | cut -d "@" -f 1 | cut -d ":" -f 1)) $(eval IMG_TAG=$(shell echo $(CONTROLLER_IMG) | cut -d "@" -f 1 | cut -d ":" -f 2 -s)) $(eval IMG_DIGEST=$(shell echo $(CONTROLLER_IMG) | cut -d "@" -f 2)) - + apply-with-kind: verify build-with-kind ## Deploy the kwok controller from the current state of your git repository into your ~/.kube/config cluster kubectl apply -f kwok/charts/crds helm upgrade --install karpenter kwok/charts --namespace $(KARPENTER_NAMESPACE) --skip-crds \ @@ -38,7 +38,7 @@ apply-with-kind: verify build-with-kind ## Deploy the kwok controller from the c --set controller.image.tag=$(IMG_TAG) \ --set serviceMonitor.enabled=true \ --set-string controller.env[0].name=ENABLE_PROFILING \ - --set-string controller.env[0].value=true + --set-string controller.env[0].value=true e2etests: ## Run the e2e suite against your local cluster cd test && go test \ diff --git a/pkg/controllers/nodeclaim/disruption/drift_test.go b/pkg/controllers/nodeclaim/disruption/drift_test.go index 7ba3dd13f0..08c7f02fb2 100644 --- a/pkg/controllers/nodeclaim/disruption/drift_test.go +++ b/pkg/controllers/nodeclaim/disruption/drift_test.go @@ -112,8 +112,11 @@ var _ = Describe("Drift", func() { It("should detect stale instance type drift if the instance type offerings aren't compatible with the nodeclaim", func() { cp.InstanceTypes = lo.Map(cp.InstanceTypes, func(it *cloudprovider.InstanceType, _ int) *cloudprovider.InstanceType { if it.Name == nodeClaim.Labels[corev1.LabelInstanceTypeStable] { - newLabels := lo.Keys(nodeClaim.Labels) - it.Requirements = scheduling.NewLabelRequirements(map[string]string{newLabels[0]: test.RandomName()}) + for i := range it.Offerings { + it.Offerings[i].Requirements = scheduling.NewLabelRequirements(map[string]string{ + corev1.LabelTopologyZone: test.RandomName(), + }) + } } return it })