Initially set rc to 0, not 1

With rc being set to 1 initially, it was never reset to 0 when using
--output-only. This meant when running tripleo deploy with
--output-only, it always exited 1, causing an exception.

This patch instead initially sets the value to 0. The only other place
where rc is used is to capture the return from running ansible, so if
that returns non-zero, rc will be updated accordingly so that the
deployment will fail.

blueprint tripleo-deploy-multinode
Change-Id: Ie116b4c600317d618a9e55b91a945d03e71fb780
Signed-off-by: James Slagle <jslagle@redhat.com>
This commit is contained in:
James Slagle 2020-05-06 09:46:12 -04:00 committed by Emilien Macchi
parent 8aa4f8810f
commit c8736dff0c
2 changed files with 64 additions and 1 deletions

View File

@ -1042,3 +1042,66 @@ class TestDeployUndercloud(TestPluginV1):
'--standalone',
'--force-stack-create',
'--force-stack-update'], [])
@mock.patch('os.path.exists', return_value=True)
@mock.patch('os.chdir')
@mock.patch('tripleoclient.utils.reset_cmdline')
@mock.patch('tripleoclient.utils.copy_clouds_yaml')
@mock.patch('tripleoclient.v1.tripleo_deploy.Deploy.'
'_download_stack_outputs')
@mock.patch('tripleo_common.actions.ansible.'
'write_default_ansible_cfg')
# TODO(cjeanner) drop once we have proper oslo.privsep
@mock.patch('os.chmod')
# TODO(cjeanner) drop once we have proper oslo.privsep
@mock.patch('os.mkdir')
@mock.patch('six.moves.builtins.open')
@mock.patch('tripleoclient.v1.tripleo_deploy.Deploy.'
'_populate_templates_dir')
@mock.patch('tripleoclient.v1.tripleo_deploy.Deploy.'
'_create_install_artifact', return_value='/tmp/foo.tar.bzip2')
@mock.patch('tripleoclient.v1.tripleo_deploy.Deploy.'
'_cleanup_working_dirs')
@mock.patch('tripleoclient.v1.tripleo_deploy.Deploy.'
'_create_working_dirs')
@mock.patch('tripleoclient.utils.wait_api_port_ready',
autospec=True)
@mock.patch('tripleoclient.v1.tripleo_deploy.Deploy.'
'_deploy_tripleo_heat_templates', autospec=True,
return_value='undercloud, 0')
@mock.patch('tripleoclient.v1.tripleo_deploy.Deploy.'
'_download_ansible_playbooks', autospec=True,
return_value='/foo')
@mock.patch('tripleoclient.v1.tripleo_deploy.Deploy.'
'_launch_heat')
@mock.patch('tripleoclient.v1.tripleo_deploy.Deploy.'
'_kill_heat')
@mock.patch('tripleoclient.v1.tripleo_deploy.Deploy.'
'_configure_puppet')
@mock.patch('os.geteuid', return_value=0)
@mock.patch('os.environ', return_value='CREATE_COMPLETE')
@mock.patch('tripleoclient.utils.wait_for_stack_ready', return_value=True)
@mock.patch('tripleoclient.v1.tripleo_deploy.Deploy.'
'_set_default_plan')
def test_standalone_deploy_rc_output_only(
self,
mock_def_plan, mock_poll,
mock_environ, mock_geteuid, mock_puppet,
mock_killheat, mock_launchheat,
mock_download, mock_tht,
mock_wait_for_port, mock_createdirs,
mock_cleanupdirs, mock_tarball,
mock_templates_dir, mock_open, mock_os,
mock_chmod, mock_ac,
mock_outputs, mock_copy, mock_cmdline,
mock_chdir, mock_file_exists):
parsed_args = self.check_parser(self.cmd,
['--local-ip', '127.0.0.1',
'--templates', '/tmp/thtroot',
'--stack', 'undercloud',
'--output-dir', '/my',
'--output-only',
'--standalone'], [])
rc = self.cmd.take_action(parsed_args)
self.assertEqual(None, rc)

View File

@ -1221,7 +1221,7 @@ class Deploy(command.Command):
# Set default plan if not specified by user
self._set_default_plan()
rc = 1
rc = 0
try:
# NOTE(bogdando): Look for the unique virtual update mark matching
# the heat stack name we are going to create below. If found the