Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Force delete CI clusters, don't wait for pod eviction #1472

Merged
merged 1 commit into from
Oct 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 2 additions & 15 deletions .github/actions/janitor/cluster-sweeper/script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,11 @@ function cluster_is_eligible_for_deletion() {
local CREATED_AT_ISO8601=$(aws eks describe-cluster --name $CLUSTER_NAME --query 'cluster.createdAt' --output text)
iso8601_is_eligible_for_deletion "$CREATED_AT_ISO8601"
}
function nodegroup_is_eligible_for_deletion() {
local CLUSTER_NAME="$1"
local NODEGROUP_NAME="$2"
local CREATED_AT_ISO8601=$(aws eks describe-nodegroup --cluster-name "$CLUSTER_NAME" --nodegroup-name $NODEGROUP_NAME --query 'nodegroup.createdAt' --output text)
iso8601_is_eligible_for_deletion "$CREATED_AT_ISO8601"
}
wget --no-verbose -O eksctl.tar.gz "https://github.com/weaveworks/eksctl/releases/latest/download/eksctl_Linux_amd64.tar.gz"
tar xf eksctl.tar.gz && chmod +x ./eksctl
for CLUSTER in $(aws eks list-clusters --query 'clusters[]' --output text); do
for NODEGROUP in $(aws eks list-nodegroups --cluster-name $CLUSTER --query 'nodegroups[]' --output text); do
if nodegroup_is_eligible_for_deletion $CLUSTER $NODEGROUP; then
./eksctl delete nodegroup --cluster $CLUSTER --name $NODEGROUP
fi
done
if [ "$(aws eks list-nodegroups --cluster-name $CLUSTER --output json | jq '.nodegroups | length')" -gt 0 ]; then
echo "Skipping cluster $CLUSTER"
elif cluster_is_eligible_for_deletion $CLUSTER; then
if cluster_is_eligible_for_deletion $CLUSTER; then
echo "Deleting cluster $CLUSTER"
./eksctl delete cluster --name "$CLUSTER"
./eksctl delete cluster --name "$CLUSTER" --force --disable-nodegroup-eviction
fi
done