+function emcoctl_apply {
+ # Workaround known issue with emcoctl resource instantation by retrying
+ # until a 2xx is received.
+ try=0
+ until [[ $(/opt/kud/multi-cluster/${CLUSTER_NAME}/artifacts/emcoctl.sh apply -f $@ -v values.yaml |
+ awk '/Response Code:/ {code=$3} END{print code}') =~ 2.. ]]; do
+ if [[ $try -lt 10 ]]; then
+ echo "Waiting for KUD addons to instantiate"
+ sleep 1s
+ else
+ return 1
+ fi
+ try=$((try + 1))
+ done
+ return 0
+}
+
+function emcoctl_delete {
+ # Workaround known issue with emcoctl resource deletion by retrying
+ # until a 404 is received.
+ until [[ $(/opt/kud/multi-cluster/${CLUSTER_NAME}/artifacts/emcoctl.sh delete -f $@ -v values.yaml |
+ awk '/Response Code:/ {code=$3} END{print code}') =~ 404 ]]; do
+ echo "Waiting for KUD addons to terminate"
+ sleep 1s
+ done
+}
+
+function wait_for_addons_ready {
+ #Wait for addons to be ready
+ # The deployment intent group status reports instantiated before all
+ # Pods are ready, so wait for the instance label (.spec.version) of
+ # the deployment intent group instead.
+ status="Pending"
+ for try in {0..9}; do
+ printf "Waiting for KUD addons to be ready\n"
+ sleep 30s
+ if KUBECONFIG=${CLUSTER_KUBECONFIG} kubectl -n ${ADDONS_NAMESPACE} wait pod -l app.kubernetes.io/instance=r1 --for=condition=Ready --timeout=0s 2>/dev/null >/dev/null; then
+ status="Ready"
+ break
+ fi
+ done
+ [[ $status == "Ready" ]]
+}
+