Enable override of overcloud status check for undercloud update.

We need to migrate heat to a new engine during pike to queen upgrade
and that requires an overcloud in a sane state.

The problem is that during undercloud update (from queen to latest
queen) we may need to update the undercloud even if the overcloud is
in a failed state.  For instance if we need a fix in a mistral
workbook to make an overcloud action successful.

This patch offers the possibility to by-pass the overcloud check in
such case.

A simple environment variable setting is used to communicate with the
python script triggered by instack-pre-upgrade-undercloud et
instack-upgrade-undercloud. It looks cleaner that mangling with the
python -c line in the scripts.

So if the environment variable TRIPLEO_FORCED_UPDATE is set to
non-empty string or if TRIPLEO_FORCED_UPDATE is passed as an argument
of the two scripts mentioned above then we trigger the no-check heat
stack status mode.

Change-Id: I43a1b4892f25bb649ee34d39b5fa462a302834aa
Partial-Bug: #1806683
This commit is contained in:
Sofer Athlan-Guyot 2018-12-04 13:15:17 +01:00
parent bbe2840e09
commit a96812f88a
3 changed files with 27 additions and 16 deletions

View File

@ -2087,7 +2087,7 @@ def _post_config(instack_env, upgrade):
# NOTE(bnemec): We are turning on the convergence engine in Queens, so we
# need to migrate all existing stacks on upgrade. This functionality can
# be removed in Rocky as all stacks should have been migrated by then.
if upgrade:
if upgrade and not os.getenv("TRIPLEO_FORCED_UPDATE", False):
heat = os_client_config.make_client('orchestration',
auth_url=auth_url,
username=user,
@ -2455,21 +2455,24 @@ def pre_upgrade():
_stackrc_upgrade_to_v3()
# Don't upgrade undercloud unless overcloud is in *_COMPLETE.
# As we're migrating overcloud stack to convergence in post_config,
# which would fail otherwise. It's better to fail fast.
user, password, project, auth_url = _get_auth_values()
heat = os_client_config.make_client('orchestration',
auth_url=auth_url,
username=user,
password=password,
project_name=project,
project_domain_name='Default',
user_domain_name='Default')
for stack in heat.stacks.list():
if stack.status != 'COMPLETE':
LOG.error('Can not upgrade undercloud with FAILED overcloud')
sys.exit(1)
# We want to be able to override this check for undercloud update.
if not os.getenv("TRIPLEO_FORCED_UPDATE", False):
LOG.info('Check the stack status to be able to migrate heat data.')
# Don't upgrade undercloud unless overcloud is in *_COMPLETE.
# As we're migrating overcloud stack to convergence in post_config,
# which would fail otherwise. It's better to fail fast.
user, password, project, auth_url = _get_auth_values()
heat = os_client_config.make_client('orchestration',
auth_url=auth_url,
username=user,
password=password,
project_name=project,
project_domain_name='Default',
user_domain_name='Default')
for stack in heat.stacks.list():
if stack.status != 'COMPLETE':
LOG.error('Can not upgrade undercloud with FAILED overcloud')
sys.exit(1)
args = ['sudo', 'systemctl', 'stop', 'openstack-*', 'neutron-*',
'openvswitch', 'httpd']

View File

@ -1,3 +1,7 @@
#!/bin/bash
if [ "$1" = "TRIPLEO_FORCED_UPDATE" ]; then
export TRIPLEO_FORCED_UPDATE="true"
fi
python -c "from instack_undercloud import undercloud; undercloud.pre_upgrade()"

View File

@ -1,3 +1,7 @@
#!/bin/bash
if [ "$1" = "TRIPLEO_FORCED_UPDATE" ]; then
export TRIPLEO_FORCED_UPDATE="true"
fi
python -c "from instack_undercloud import undercloud; undercloud.install('$(dirname $0)/..', upgrade=True)"