From addfbfd3c2e9eaaee1e2c6c0557d88458e358de7 Mon Sep 17 00:00:00 2001 From: terencecho <3916587+terencecho@users.noreply.github.com> Date: Tue, 7 Feb 2023 09:19:04 -0800 Subject: [PATCH] Fix naming of functions for pod sweeper (#22374) * Fix naming of functions for pod sweeper * Fix naming of functions for pod sweeper --- charts/airbyte-pod-sweeper/templates/configmap.yaml | 10 +++++----- kube/resources/pod-sweeper.yaml | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/charts/airbyte-pod-sweeper/templates/configmap.yaml b/charts/airbyte-pod-sweeper/templates/configmap.yaml index f6f3d2917e40..9b77ba17ba3b 100644 --- a/charts/airbyte-pod-sweeper/templates/configmap.yaml +++ b/charts/airbyte-pod-sweeper/templates/configmap.yaml @@ -11,12 +11,12 @@ metadata: data: sweep-pod.sh: | #!/bin/bash - get_worker_pods () { + get_job_pods () { kubectl -n ${KUBE_NAMESPACE} -L airbyte -l airbyte=job-pod \ --field-selector status.phase!=Running get pods \ -o=jsonpath='{range .items[*]} {.metadata.name} {.status.phase} {.status.conditions[0].lastTransitionTime} {.status.startTime}{"\n"}{end}' } - delete_worker_pod() { + delete_pod() { printf "From status '%s' since '%s', " $2 $3 echo "$1" | grep -v "STATUS" | awk '{print $1}' | xargs --no-run-if-empty kubectl -n ${KUBE_NAMESPACE} delete pod } @@ -30,7 +30,7 @@ data: NON_SUCCESS_DATE=`date -d $NON_SUCCESS_DATE_STR +%s` ( IFS=$'\n' - for POD in `get_worker_pods`; do + for POD in `get_job_pods`; do IFS=' ' POD_NAME=`echo $POD | cut -d " " -f 1` POD_STATUS=`echo $POD | cut -d " " -f 2` @@ -39,11 +39,11 @@ data: POD_DATE=`date -d ${POD_DATE_STR:-$POD_START_DATE_STR} '+%s'` if [ "$POD_STATUS" = "Succeeded" ]; then if [ "$POD_DATE" -lt "$SUCCESS_DATE" ]; then - delete_worker_pod "$POD_NAME" "$POD_STATUS" "$POD_DATE_STR" + delete_pod "$POD_NAME" "$POD_STATUS" "$POD_DATE_STR" fi else if [ "$POD_DATE" -lt "$NON_SUCCESS_DATE" ]; then - delete_worker_pod "$POD_NAME" "$POD_STATUS" "$POD_DATE_STR" + delete_pod "$POD_NAME" "$POD_STATUS" "$POD_DATE_STR" fi fi done diff --git a/kube/resources/pod-sweeper.yaml b/kube/resources/pod-sweeper.yaml index 3f20cc23a7a7..a3ba6f468e57 100644 --- a/kube/resources/pod-sweeper.yaml +++ b/kube/resources/pod-sweeper.yaml @@ -6,13 +6,13 @@ data: sweep-pod.sh: | #!/bin/bash - get_worker_pods () { + get_job_pods () { kubectl -n ${KUBE_NAMESPACE} -L airbyte -l airbyte=job-pod \ --field-selector status.phase!=Running get pods \ -o=jsonpath='{range .items[*]} {.metadata.name} {.status.phase} {.status.conditions[0].lastTransitionTime} {.status.startTime}{"\n"}{end}' } - delete_worker_pod() { + delete_pod() { printf "From status '%s' since '%s', " $2 $3 echo "$1" | grep -v "STATUS" | awk '{print $1}' | xargs --no-run-if-empty kubectl -n ${KUBE_NAMESPACE} delete pod } @@ -27,7 +27,7 @@ data: NON_SUCCESS_DATE=`date -d $NON_SUCCESS_DATE_STR +%s` ( IFS=$'\n' - for POD in `get_worker_pods`; do + for POD in `get_job_pods`; do IFS=' ' POD_NAME=`echo $POD | cut -d " " -f 1` POD_STATUS=`echo $POD | cut -d " " -f 2` @@ -36,11 +36,11 @@ data: POD_DATE=`date -d ${POD_DATE_STR:-$POD_START_DATE_STR} '+%s'` if [ "$POD_STATUS" = "Succeeded" ]; then if [ "$POD_DATE" -lt "$SUCCESS_DATE" ]; then - delete_worker_pod "$POD_NAME" "$POD_STATUS" "$POD_DATE_STR" + delete_pod "$POD_NAME" "$POD_STATUS" "$POD_DATE_STR" fi else if [ "$POD_DATE" -lt "$NON_SUCCESS_DATE" ]; then - delete_worker_pod "$POD_NAME" "$POD_STATUS" "$POD_DATE_STR" + delete_pod "$POD_NAME" "$POD_STATUS" "$POD_DATE_STR" fi fi done