[Queen Only] Add force option to undercloud update.

When the overcloud is in a failed state we can't run the undercloud
upgrade command anymore. But we may need to inject code in mistral for
instance to get out of the overcloud failure.

The force option enables the user to get out of this loop.

Queen only as instack undercloud is removed from Rocky on.

Change-Id: I9e7fe8cfd96262938d463de0d6c45ccedc9989be
Closes-Bug: #1806683
Depends-On: https://review.openstack.org/622290
This commit is contained in:
Sofer Athlan-Guyot 2019-04-04 13:12:55 +02:00
parent dadea7bc02
commit 6ce2039d37
2 changed files with 42 additions and 4 deletions

View File

@ -98,8 +98,30 @@ class TestUndercloudUpgrade(TestPluginV1):
[
mock.call(['sudo', 'yum', 'update', '-y',
'instack-undercloud']),
mock.call('instack-pre-upgrade-undercloud'),
mock.call('instack-upgrade-undercloud'),
mock.call(['instack-pre-upgrade-undercloud']),
mock.call(['instack-upgrade-undercloud']),
mock.call(['sudo', 'systemctl', 'restart',
'openstack-nova-api'])
]
)
@mock.patch('subprocess.check_call', autospec=True)
def test_undercloud_upgrade_with_force(self, mock_subprocess):
arglist = ['--force']
verifylist = []
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
# DisplayCommandBase.take_action() returns two tuples
self.cmd.take_action(parsed_args)
mock_subprocess.assert_has_calls(
[
mock.call(['sudo', 'yum', 'update', '-y',
'instack-undercloud']),
mock.call(['instack-pre-upgrade-undercloud',
'TRIPLEO_FORCED_UPDATE']),
mock.call(['instack-upgrade-undercloud',
'TRIPLEO_FORCED_UPDATE']),
mock.call(['sudo', 'systemctl', 'restart',
'openstack-nova-api'])
]

View File

@ -74,6 +74,17 @@ class UpgradeUndercloud(InstallUndercloud):
auth_required = False
log = logging.getLogger(__name__ + ".UpgradeUndercloud")
def get_parser(self, prog_name):
parser = super(UpgradeUndercloud, self).get_parser(prog_name)
parser.add_argument('--force',
action='store_true',
default=False,
help=_('No to be used in normal update/upgrade! '
'This helps getting out of an error loop '
'when the overcloud is in error and '
'it needs new code to work again.'))
return parser
def take_action(self, parsed_args):
self.log.debug("take action(%s)" % parsed_args)
@ -88,8 +99,13 @@ class UpgradeUndercloud(InstallUndercloud):
else:
subprocess.check_call(['sudo', 'yum', 'update', '-y',
'instack-undercloud'])
subprocess.check_call("instack-pre-upgrade-undercloud")
subprocess.check_call("instack-upgrade-undercloud")
commands = ["instack-pre-upgrade-undercloud",
"instack-upgrade-undercloud"]
for cmd in commands:
final_cmd = [cmd]
if parsed_args.force:
final_cmd += ["TRIPLEO_FORCED_UPDATE"]
subprocess.check_call(final_cmd)
# restart nova-api
# https://bugzilla.redhat.com/show_bug.cgi?id=1315467
subprocess.check_call(['sudo', 'systemctl', 'restart',