From a7a9bd26b9f96686ca45229a566d77115243e57e Mon Sep 17 00:00:00 2001 From: Sergiy Markin Date: Fri, 23 Aug 2024 15:50:31 +0000 Subject: [PATCH] Airflow upgrade fix This PS has airflow upgrade script that makes sure that the airflow-worker that is hosting currently running instance of the script will be deleted at last. This makes sure that all airflow-workers will be restarted to apply new config or image. Change-Id: Iacf6e63e0247ae836e7eb5b7ff24d0369d5e5191 --- images/airflow/script/upgrade_airflow_worker.sh | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/images/airflow/script/upgrade_airflow_worker.sh b/images/airflow/script/upgrade_airflow_worker.sh index 76fc26db..5fcb14c1 100755 --- a/images/airflow/script/upgrade_airflow_worker.sh +++ b/images/airflow/script/upgrade_airflow_worker.sh @@ -78,12 +78,21 @@ do echo -e "Proceeding to upgrade Airflow Worker..." >> /usr/local/airflow/upgrade_airflow_worker.log echo -e "Deleting Airflow Worker Pods..." >> /usr/local/airflow/upgrade_airflow_worker.log - for i in $(kubectl get pods -n ucp | grep -i airflow-worker | awk '{print $1}'); do - # Delete Airflow Worker pod so that they will respawn with the new - # configurations and/or images + # Delete Airflow Worker pod so that they will respawn with the new + # configurations and/or images + + # Get the name of the current pod + CURRENT_POD=$(hostname) + + # Loop through all pods matching the 'airflow-worker' pattern, excluding the current pod + for i in $(kubectl get pods -n ucp | grep -i airflow-worker | awk '{print $1}' | grep -v $CURRENT_POD); do kubectl delete pod $i -n ucp done + # Finally, delete the current pod + kubectl delete pod $CURRENT_POD -n ucp + + echo -e "Airflow Worker Pods Deleted!" >> /usr/local/airflow/upgrade_airflow_worker.log return 0