From ec216d21656f956a38defcfc66c6dc0dbf6248ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E7=A5=96=E5=BB=BA?= Date: Wed, 18 Dec 2024 09:58:31 +0800 Subject: [PATCH] ci: wait for kubevirt crd to be created before creating CR (#4839) Signed-off-by: zhangzujian --- Makefile | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 8c5388c1c7a..86bda832670 100644 --- a/Makefile +++ b/Makefile @@ -331,13 +331,17 @@ define kind_load_kwok_image $(call kind_load_image,$(1),$(KWOK_IMAGE),1) endef -define kubectl_wait_exist_and_ready - @echo "Waiting for $(2) $(1)/$(3) to exist..." - @n=0; while ! kubectl -n $(1) get $(2) -o name | awk -F / '{print $$2}' | grep -q ^$(3)$$; do \ +define kubectl_wait_exist + @echo "Waiting for $(2) $(1)/$(3) to be created..." + @n=0; while ! kubectl -n "$(1)" get "$(2)" -o name | awk -F / '{print $$2}' | grep -q ^$(3)$$; do \ test $$n -eq 60 && exit 1; \ sleep 1; \ n=$$(($$n+1)); \ done +endef + +define kubectl_wait_exist_and_ready + $(call kubectl_wait_exist,$(1),$(2),$(3)) kubectl -n $(1) rollout status --timeout=60s $(2) $(3) endef @@ -814,11 +818,13 @@ kind-install-kubevirt: $(call kind_load_image,kube-ovn,$(KUBEVIRT_LAUNCHER_IMAGE),1) kubectl apply -f "$(KUBEVIRT_OPERATOR_YAML)" - kubectl apply -f "$(KUBEVIRT_CR_YAML)" kubectl -n kubevirt scale deploy virt-operator --replicas=1 + $(call kubectl_wait_exist_and_ready,kubevirt,deployment,virt-operator) + $(call kubectl_wait_exist,,crd,kubevirts.kubevirt.io) + + kubectl apply -f "$(KUBEVIRT_CR_YAML)" kubectl -n kubevirt patch kubevirt kubevirt --type=merge --patch \ '{"spec":{"configuration":{"developerConfiguration":{"useEmulation":true}},"infra":{"replicas":1}}}' - $(call kubectl_wait_exist_and_ready,kubevirt,deployment,virt-operator) $(call kubectl_wait_exist_and_ready,kubevirt,deployment,virt-api) $(call kubectl_wait_exist_and_ready,kubevirt,deployment,virt-controller) $(call kubectl_wait_exist_and_ready,kubevirt,daemonset,virt-handler)