Merge pull request #3323 from jwcesign/fix-cli

Fix potential failure in CLI workflow.
This commit is contained in:
karmada-bot 2023-03-29 11:20:54 +08:00 committed by GitHub
commit 4ca1097c3a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 2 deletions

View File

@ -38,11 +38,16 @@ hack/create-cluster.sh ${MEMBER_CLUSTER_2_NAME} ${KUBECONFIG_PATH}/${MEMBER_CLUS
# wait cluster ready
echo "Wait clusters ready..."
util::wait_file_exist ${KUBECONFIG_PATH}/${HOST_CLUSTER_NAME}.config 300
util::wait_file_exist ${KUBECONFIG_PATH}/${MEMBER_CLUSTER_1_NAME}.config 300
util::wait_file_exist ${KUBECONFIG_PATH}/${MEMBER_CLUSTER_2_NAME}.config 300
kubectl wait --for=condition=Ready nodes --all --timeout=800s --kubeconfig=${KUBECONFIG_PATH}/${HOST_CLUSTER_NAME}.config
util::wait_nodes_taint_disappear 800 ${KUBECONFIG_PATH}/${HOST_CLUSTER_NAME}.config
util::wait_file_exist ${KUBECONFIG_PATH}/${MEMBER_CLUSTER_1_NAME}.config 300
kubectl wait --for=condition=Ready nodes --all --timeout=800s --kubeconfig=${KUBECONFIG_PATH}/${MEMBER_CLUSTER_1_NAME}.config
util::wait_nodes_taint_disappear 800 ${KUBECONFIG_PATH}/${MEMBER_CLUSTER_1_NAME}.config
util::wait_file_exist ${KUBECONFIG_PATH}/${MEMBER_CLUSTER_2_NAME}.config 300
kubectl wait --for=condition=Ready nodes --all --timeout=800s --kubeconfig=${KUBECONFIG_PATH}/${MEMBER_CLUSTER_2_NAME}.config
util::wait_nodes_taint_disappear 800 ${KUBECONFIG_PATH}/${MEMBER_CLUSTER_2_NAME}.config
# init Karmada control plane
echo "Start init karmada control plane..."

View File

@ -693,3 +693,25 @@ RUN echo -e http://mirrors.ustc.edu.cn/alpine/v3.17/main/ > /etc/apk/repositorie
done
}
# util::wait_nodes_taint_disappear will wait for all the nodes' taint to disappear
# Parameters:
# - timeout: Timeout in seconds.
# - kubeconfig_path: The path of kubeconfig.
# Returns:
# 1 if the condition is not met before the timeout, else 0
function util::wait_nodes_taint_disappear() {
local timeout=${1}
local kubeconfig_path=${2}
timeout "${timeout}" bash <<EOF && return 0
while true
do
taints=\$(kubectl get nodes --kubeconfig=${kubeconfig_path} -o=jsonpath="{.items[*].spec.taints}")
if [ -z \$taints ]; then
exit
fi
done
EOF
echo "Timeout for nodes' taint to disappear"
return 1
}