Skip to content

Commit

Permalink
Fix naming of functions for pod sweeper (airbytehq#22374)
Browse files Browse the repository at this point in the history
* Fix naming of functions for pod sweeper

* Fix naming of functions for pod sweeper
  • Loading branch information
terencecho authored and danidelvalle-frontiers committed Feb 9, 2023
1 parent 31133aa commit addfbfd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions charts/airbyte-pod-sweeper/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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`
Expand All @@ -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
Expand Down
10 changes: 5 additions & 5 deletions kube/resources/pod-sweeper.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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`
Expand All @@ -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
Expand Down

0 comments on commit addfbfd

Please sign in to comment.