diff --git a/fix_cloud.sh b/fix_cloud.sh index fb38431..44b7115 100755 --- a/fix_cloud.sh +++ b/fix_cloud.sh @@ -9,12 +9,13 @@ check_juju_version() { juju_version=$(juju version | cut -d'-' -f1 | cut -d'.' -f1) + juju_run="juju run" - juju_run_action="juju run-action" + juju_run_action="juju run-action --wait" if [[ ${juju_version} -ge 3 ]] ; then juju_run="juju exec" - juju_run_action="juju run" + juju_run_action="juju run --wait" fi } @@ -135,7 +136,7 @@ if [[ -n "${percona_cluster}" ]] ; then if [[ -n ${bootstrap_unit} ]] then - ${juju_run_action} --wait "${bootstrap_unit}" bootstrap-pxc + ${juju_run_action} "${bootstrap_unit}" bootstrap-pxc ${juju_run} -a mysql "hooks/update-status" until [[ $(check_unit_status mysql "Unit waiting for cluster bootstrap") -eq 1 ]] do @@ -144,12 +145,12 @@ if [[ -n "${percona_cluster}" ]] ; then if [[ "${bootstrap_unit}" == "${mysql_lead}" ]] ; then for unit in ${mysql_units}; do if [[ "${unit}" != "${mysql_lead}" ]] ; then - ${juju_run_action} --wait "${unit}" notify-bootstrapped + ${juju_run_action} "${unit}" notify-bootstrapped break fi done else - ${juju_run_action} --wait "${mysql_lead}" notify-bootstrapped + ${juju_run_action} "${mysql_lead}" notify-bootstrapped fi ${juju_run} -a mysql "hooks/update-status" until [[ $(check_unit_status mysql "Unit is ready") -eq 1 ]] @@ -162,7 +163,7 @@ if [[ -n "${percona_cluster}" ]] ; then juju ssh "${bootstrap_unit}" -- sudo reboot fi - juju exec -a nova-cloud-controller -- sudo systemctl restart nova-api-os-compute nova-conductor nova-consoleauth & + ${juju_run} -a nova-cloud-controller -- sudo systemctl restart nova-api-os-compute nova-conductor nova-consoleauth & fi if [[ -n "${mysql_innodb_cluster}" ]] ; then @@ -172,7 +173,7 @@ if [[ -n "${mysql_innodb_cluster}" ]] ; then is_ready=$(echo "$mysql_status" | jq -rc . | grep "Mode: R/W, Cluster is ONLINE" | jq -r .sub) if [[ -z "${is_ready}" ]] ; then - reboot_status=$(${juju_run_action} mysql-innodb-cluster/leader reboot-cluster-from-complete-outage --wait --format json) + reboot_status=$(${juju_run_action} mysql-innodb-cluster/leader reboot-cluster-from-complete-outage --format json) outcome=$(echo "$reboot_status" | jq .[].results.outcome) @@ -184,7 +185,7 @@ if [[ -n "${mysql_innodb_cluster}" ]] ; then bootstrap_unit=$(jq -r ".applications.\"mysql-innodb-cluster\".units | to_entries[] | select(.value.\"public-address\" == \"${mysql_ip}\") | .key" "${juju_status}") - ${juju_run_action} "${bootstrap_unit}" reboot-cluster-from-complete-outage --wait + ${juju_run_action} "${bootstrap_unit}" reboot-cluster-from-complete-outage fi