Skip to content

Commit

Permalink
Delete the container forcely (stolostron#1314)
Browse files Browse the repository at this point in the history
Signed-off-by: clyang82 <[email protected]>
  • Loading branch information
clyang82 authored Jan 7, 2025
1 parent 249849e commit 6b91f12
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
5 changes: 2 additions & 3 deletions test/script/e2e_setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,11 @@ start=$(date +%s)
# Init clusters
start_time=$(date +%s)

kind_cluster "$GH_NAME" 2>&1 &
kind_cluster "$GH_NAME"
for i in $(seq 1 "${MH_NUM}"); do
kind_cluster "hub$i" 2>&1 &
kind_cluster "hub$i"
done

wait
echo -e "${YELLOW} creating clusters:${NC} $(($(date +%s) - start_time)) seconds"

# service-ca
Expand Down
10 changes: 9 additions & 1 deletion test/script/util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,16 @@ kind_cluster() {
dir="${CONFIG_DIR:-$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)}"
local cluster_name="$1"
local kubeconfig="$dir/$cluster_name"
while [ ! -f "$kubeconfig" ] || ! kubectl config get-contexts -o name | grep -wq "$cluster_name"; do
local max_retries=5
local counter=0
while [ $counter -lt $max_retries ] && ( [ ! -f "$kubeconfig" ] || ! kubectl config get-contexts -o name | grep -wq "$cluster_name" ); do
ensure_cluster "$cluster_name" "$kubeconfig"
counter=$((counter + 1))
done
if [ $counter -eq $max_retries ]; then
echo "Failed to create cluster $cluster_name"
exit 1
fi
echo "kind clusters: $(kind get clusters)"
}

Expand All @@ -123,6 +130,7 @@ ensure_cluster() {

if kind get clusters | grep -q "^$cluster_name$"; then
kind delete cluster --name="$cluster_name"
docker rm -f "$cluster_name-control-plane"
fi

kind create cluster --name "$cluster_name" --image=kindest/node:v1.23.0 --wait 5m
Expand Down

0 comments on commit 6b91f12

Please sign in to comment.