diff --git a/tools/rabbitmq-quorum-migration.sh b/tools/rabbitmq-quorum-migration.sh index b24e0d446..9bd4d79d2 100755 --- a/tools/rabbitmq-quorum-migration.sh +++ b/tools/rabbitmq-quorum-migration.sh @@ -13,7 +13,7 @@ fi if [[ ! "$1" = "--skip-checks" ]]; then # Fail if clocks are not synced - if ! kayobe overcloud host command run -l controllers -b --command "timedatectl status | grep 'synchronized: yes'"; then + if ! ( kayobe overcloud host command run -l controllers -b --command "timedatectl status | grep 'synchronized: yes'" ); then echo "Failed precheck: Time not synced on controllers" echo "Use 'timedatectl status' to check sync state" echo "Either wait for sync or use 'chronyc makestep'" @@ -21,7 +21,7 @@ if [[ ! "$1" = "--skip-checks" ]]; then fi kayobe overcloud service configuration generate --node-config-dir /tmp/rabbit-migration --kolla-tags none # Fail if HA is set or quorum is not - if ! grep 'om_enable_rabbitmq_quorum_queues: true' $KOLLA_CONFIG_PATH/globals.yml || grep 'om_enable_rabbitmq_high_availability: true' $KOLLA_CONFIG_PATH/globals.yml; then + if ! ( grep 'om_enable_rabbitmq_quorum_queues: true' $KOLLA_CONFIG_PATH/globals.yml || grep 'om_enable_rabbitmq_high_availability: true' $KOLLA_CONFIG_PATH/globals.yml ); then echo "Failed precheck: om_enable_rabbitmq_quorum_queues must be enabled, om_enable_rabbitmq_high_availability must be disabled" exit 1 fi @@ -35,12 +35,12 @@ kayobe kolla ansible run rabbitmq-reset-state if [[ ! "$1" = "--skip-checks" ]]; then # Fail if any queues still exist sleep 20 - if kayobe overcloud host command run -l controllers -b --command "docker exec $RABBITMQ_CONTAINER_NAME rabbitmqctl list_queues name --silent | grep -v '^$'"; then + if ( kayobe overcloud host command run -l controllers -b --command "docker exec $RABBITMQ_CONTAINER_NAME rabbitmqctl list_queues name --silent | grep -v '^$'" ); then echo "Failed check: RabbitMQ has not stopped properly, queues still exist" exit 1 fi # Fail if any exchanges still exist (excluding those starting with 'amq.') - if kayobe overcloud host command run -l controllers -b --command "docker exec $RABBITMQ_CONTAINER_NAME rabbitmqctl list_exchanges name --silent | grep -v '^$' | grep -v '^amq.'"; then + if ( kayobe overcloud host command run -l controllers -b --command "docker exec $RABBITMQ_CONTAINER_NAME rabbitmqctl list_exchanges name --silent | grep -v '^$' | grep -v '^amq.'" ); then echo "Failed check: RabbitMQ has not stopped properly, exchanges still exist" exit 1 fi @@ -52,7 +52,7 @@ kayobe kolla ansible run deploy-containers -kt $RABBITMQ_SERVICES_TO_RESTART if [[ ! "$1" = "--skip-checks" ]]; then sleep 20 # Assert that at least one quorum queue exists on each controller - if kayobe overcloud host command run -l controllers -b --command "docker exec $RABBITMQ_CONTAINER_NAME rabbitmqctl list_queues type | grep quorum"; then + if ( kayobe overcloud host command run -l controllers -b --command "docker exec $RABBITMQ_CONTAINER_NAME rabbitmqctl list_queues type | grep quorum" ); then echo "Queues migrated successfully" else echo "Failed post-check: A controller does not have any quorum queues" diff --git a/tools/upgrade-prerequisites.sh b/tools/upgrade-prerequisites.sh index aa66708c3..24cd9bbee 100755 --- a/tools/upgrade-prerequisites.sh +++ b/tools/upgrade-prerequisites.sh @@ -31,15 +31,19 @@ function rabbit_upgrade() { function rabbit_migration() { if ! kayobe overcloud host command run -l controllers -b --command "docker exec rabbitmq rabbitmqctl list_queues type | grep quorum"; then # Set quorum flag, execute RabbitMQ queue migration script, unset quorum flag (to avoid git conflicts) + KOLLA_GLOBALS_PATH=$KAYOBE_CONFIG_PATH/kolla/globals.yml + if [[ $KAYOBE_ENVIRONMENT ]]; then + KOLLA_GLOBALS_PATH=$KAYOBE_CONFIG_PATH/environments/$KAYOBE_ENVIRONMENT/kolla/globals.yml + fi sed -i -e 's/om_enable_rabbitmq_high_availability: true/om_enable_rabbitmq_high_availability: false/' \ -e 's/om_enable_rabbitmq_quorum_queues: false/om_enable_rabbitmq_quorum_queues: true/' \ - $KAYOBE_CONFIG_PATH/environments/$KAYOBE_ENVIRONMENT/kolla/globals.yml + $KOLLA_GLOBALS_PATH - $KAYOBE_CONFIG_ROOT/tools/rabbitmq-quorum-migration.sh + $KAYOBE_CONFIG_PATH/../../tools/rabbitmq-quorum-migration.sh sed -i -e 's/om_enable_rabbitmq_high_availability: false/om_enable_rabbitmq_high_availability: true/' \ -e 's/om_enable_rabbitmq_quorum_queues: true/om_enable_rabbitmq_quorum_queues: false/' \ - $KAYOBE_CONFIG_PATH/environments/$KAYOBE_ENVIRONMENT/kolla/globals.yml + $KOLLA_GLOBALS_PATH fi }