From 83c3ce7f8feded782ea72c9f2d2d65cbc2d62deb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E8=92=8B=E8=88=AA?= <hang.jiang@daocloud.io>
Date: Tue, 21 Mar 2023 12:51:06 +0800
Subject: [PATCH] Add Retry for Checking calico exists (#9883)

Signed-off-by: hang.jiang <hang.jiang@daocloud.io>
---
 roles/network_plugin/calico/tasks/check.yml | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/roles/network_plugin/calico/tasks/check.yml b/roles/network_plugin/calico/tasks/check.yml
index c500f7434..0ea752418 100644
--- a/roles/network_plugin/calico/tasks/check.yml
+++ b/roles/network_plugin/calico/tasks/check.yml
@@ -50,10 +50,14 @@
   run_once: True
   delegate_to: "{{ groups['kube_control_plane'][0] }}"
 
-- name: Check if calico ClusterInformation exists
-  command: "{{ bin_dir }}/calicoctl.sh get ClusterInformation"
-  register: clusterinformation_exists
+- name: Check if calico ready
+  command: "{{ bin_dir }}/calicoctl.sh get ClusterInformation default"
+  register: calico_ready
   run_once: True
+  ignore_errors: True
+  retries: 5
+  delay: 10
+  until: calico_ready.rc == 0
   delegate_to: "{{ groups['kube_control_plane'][0] }}"
   when: calicoctl_sh_exists.stat.exists
 
@@ -76,7 +80,7 @@
           But current version is {{ calico_version_on_server.stdout }}.
   run_once: True
   delegate_to: "{{ groups['kube_control_plane'][0] }}"
-  when: calicoctl_sh_exists.stat.exists and clusterinformation_exists.rc == 0
+  when: calicoctl_sh_exists.stat.exists and calico_ready.rc == 0
 
 - name: "Check that cluster_id is set if calico_rr enabled"
   assert:
-- 
GitLab