Skip to content

Commit

Permalink
Merge pull request #4044 from LiilyZhang/zhangl/Issue4043
Browse files Browse the repository at this point in the history
Issue #4043 - Bug: agent-uninstall.sh stucked when deleti…
  • Loading branch information
LiilyZhang authored Apr 24, 2024
2 parents fe0f772 + aa3c515 commit 32fddec
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions agent-install/agent-uninstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,13 @@ function deleteAgentResources() {
$KUBECTL delete deployment $DEPLOYMENT_NAME -n $AGENT_NAMESPACE --force=true --grace-period=0
fi

log_info "Deleting auto-upgrade cronjob..."
if $KUBECTL get cronjob ${CRONJOB_AUTO_UPGRADE_NAME} -n ${AGENT_NAMESPACE} 2>/dev/null; then
$KUBECTL delete cronjob $CRONJOB_AUTO_UPGRADE_NAME -n $AGENT_NAMESPACE
else
log_info "cronjob ${CRONJOB_AUTO_UPGRADE_NAME} does not exist, skip deleting cronjob"
fi

# give pods sometime to terminate by themselves
sleep 10

Expand Down Expand Up @@ -380,21 +387,13 @@ function deleteAgentResources() {
$KUBECTL delete secret $IMAGE_REGISTRY_SECRET_NAME -n $AGENT_NAMESPACE
$KUBECTL delete secret $IMAGE_PULL_SECRET_NAME -n $AGENT_NAMESPACE
$KUBECTL delete secret ${SECRET_NAME}-backup -n $AGENT_NAMESPACE
set -e

log_info "Deleting auto-upgrade cronjob..."
if $KUBECTL get cronjob ${CRONJOB_AUTO_UPGRADE_NAME} -n ${AGENT_NAMESPACE} 2>/dev/null; then
$KUBECTL delete cronjob $CRONJOB_AUTO_UPGRADE_NAME -n $AGENT_NAMESPACE
else
log_info "cronjob ${CRONJOB_AUTO_UPGRADE_NAME} does not exist, skip deleting cronjob"
fi

set +e
$KUBECTL delete clusterrolebinding ${AGENT_NAMESPACE}-${CLUSTER_ROLE_BINDING_NAME}

log_info "Deleting persistent volume..."
$KUBECTL delete pvc $PVC_NAME -n $AGENT_NAMESPACE

log_info "Deleting clusterrolebinding..."
$KUBECTL delete clusterrolebinding ${AGENT_NAMESPACE}-${CLUSTER_ROLE_BINDING_NAME}

log_info "Deleting serviceaccount..."
$KUBECTL delete serviceaccount $SERVICE_ACCOUNT_NAME -n $AGENT_NAMESPACE

Expand Down

0 comments on commit 32fddec

Please sign in to comment.