tripleo-upgrade/templates/overcloud_prepare_containers.sh.j2
Bogdan Dobrelya 9ceca92d20 Fix --yes evaluation from the help CLI
Sometimes, CLI may return error earlier than grep catches up
its query results. With bash pipefail set, this ends up with grep --yes
omitted and the wrong command executed (without --yes).

Set pipefail only after the --yes argument evaluated by grep.

Change-Id: I22a998e0cf3b04ef51a51478fc6576324a931dcb
Co-Authored-By: Sergii Golovatouk <sgolovat@redhat.com>
Signed-off-by: Bogdan Dobrelya <bdobreli@redhat.com>
2020-07-16 17:16:21 +02:00

25 lines
754 B
Django/Jinja

#!/bin/env bash
#
# Prepare conatainer images for overcloud update/upgrade
#
{% if overcloud_update|bool or update_noop|bool -%}
{% set operation_type = 'update' -%}
{% elif overcloud_upgrade|bool or upgrade_noop|bool or ffu_overcloud_upgrade|bool or ffu_noop|bool -%}
{% set operation_type = 'upgrade' -%}
{% endif -%}
set -eu
source {{undercloud_rc }}
EXTERNAL_ANSWER=""
if openstack overcloud external-{{ operation_type }} run --help | grep -qe "--yes"; then
EXTERNAL_ANSWER="--yes"
fi
set -o pipefail
echo "[$(date)] Start preparing container images for overcloud {{ operation_type }}"
openstack overcloud external-{{ operation_type }} run ${EXTERNAL_ANSWER} \
--stack {{ overcloud_stack_name }} \
--tags container_image_prepare 2>&1