From ef3e74311380253652256fc630816d249f0ede91 Mon Sep 17 00:00:00 2001 From: Ian Cordasco Date: Thu, 30 Jul 2015 21:03:23 -0500 Subject: [PATCH] Properly parse and quote arguments in upgrade script This patch fixes the following: 1. Properly quote arguments to run_lock function 2. Properly parse out the playbook filename in run_lock Specifically the upgrade steps where we were using "-e 'rabbitmq_upgrade=true' setup-infrastructure.yml" "/tmp/fix_container_interfaces.yml || true" Were causing issues and this patch resolves them. Closes-bug: 1479916 Change-Id: I809085d6da493f7f7d545547a0d984c0e7b1bf45 (cherry picked from commit 560fbbdb077c0f8d6f8bfa9b48e967ccef86664a) --- scripts/run-upgrade.sh | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/scripts/run-upgrade.sh b/scripts/run-upgrade.sh index e874e8e0bb..7bf869d7ed 100755 --- a/scripts/run-upgrade.sh +++ b/scripts/run-upgrade.sh @@ -59,11 +59,28 @@ function remove_inv_items(){ function run_lock() { set +e run_item="${RUN_TASKS[$1]}" - upgrade_marker_file=$(basename $run_item .yml) + file_part="${run_item}" + + # NOTE(sigmavirus24): This handles tasks like: + # "-e 'rabbitmq_upgrade=true' setup-infrastructure.yml" + # "/tmp/fix_container_interfaces.yml || true" + # So we can get the appropriate basename for the upgrade_marker + for part in $run_item; do + if [[ "$part" == *.yml ]];then + file_part="$part" + break + fi + done + + upgrade_marker_file=$(basename ${file_part} .yml) upgrade_marker="/etc/openstack_deploy/upgrade-juno/$upgrade_marker_file.complete" if [ ! -f "$upgrade_marker" ];then - openstack-ansible "$2" + # NOTE(sigmavirus24): Use eval so that we properly turn strings like + # "/tmp/fix_container_interfaces.yml || true" + # Into a command, otherwise we'll get an error that there's no playbook + # named || + eval "openstack-ansible $2" echo "ran $run_item" if [ "$?" == "0" ];then @@ -631,6 +648,6 @@ pushd playbooks # Run the tasks in order for item in ${!RUN_TASKS[@]}; do - run_lock $item ${RUN_TASKS[$item]} + run_lock $item "${RUN_TASKS[$item]}" done popd