From 499b487c51aa91e5b035e9fadcb2e148ad4e8508 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Jeanneret?= Date: Thu, 15 Aug 2019 11:44:32 +0200 Subject: [PATCH] (squash) Clean backport of inflight-validations for UC/OC/standalone Adds new "--no-inflight-validations" option to deploy CLI This provides an independant way to activate or not the in-flight validations within a deploy. The default is to have them running, and this option allows to deactivate the in-flight ones. Change-Id: I81e934e2978cad4e2713d54e19a57c84a6ac0b52 (cherry picked from commit bf48dbc84405208dd86ae3dd4879fc7735b99838) Disable inflight validations by default The inflight validations caused timeouts in the TripleO CI. They should not be enabled by default. New features should not be enabled by default in general, they should be optional. So this patch changes the option to be --inflight-validations, and make sure the inflights are disabled by default everywhere it's called. Change-Id: I082628a9480686d6a7801056c3b4bf332b4e3d95 Related-Bug: #1844446 (cherry picked from commit 89be0d17c5d380777070e8f3dd6369289697d2a9) Introduce --inflight-validations for standalone / undercloud Like we do for the overcloud, add the --inflight-validations option, disabled by default. Disable by default, we'll skip the "opendev-validations" Ansible tags when running the playbooks. Related-Bug: #1844446 Change-Id: Ia37b3d4cc657d994b6a63412d5792930d54a14dd (cherry picked from commit 64af3ae1fb9adda02efcfd93d99cf5deca1104cb) --- ...ht-validation-option-9e3f70b5bcb8dea9.yaml | 6 +++ .../tests/v1/tripleo/test_tripleo_deploy.py | 3 +- tripleoclient/v1/overcloud_deploy.py | 15 +++++-- tripleoclient/v1/tripleo_deploy.py | 39 ++++++++++++++----- tripleoclient/v1/undercloud_config.py | 3 +- tripleoclient/workflows/deployment.py | 2 +- 6 files changed, 50 insertions(+), 18 deletions(-) create mode 100644 releasenotes/notes/inflight-validation-option-9e3f70b5bcb8dea9.yaml diff --git a/releasenotes/notes/inflight-validation-option-9e3f70b5bcb8dea9.yaml b/releasenotes/notes/inflight-validation-option-9e3f70b5bcb8dea9.yaml new file mode 100644 index 000000000..8dcadaf19 --- /dev/null +++ b/releasenotes/notes/inflight-validation-option-9e3f70b5bcb8dea9.yaml @@ -0,0 +1,6 @@ +--- +features: + - | + Introduce new "--inflight-validations" option in order to activate + those validations. It defaults to "False", since we don't want them by + default. diff --git a/tripleoclient/tests/v1/tripleo/test_tripleo_deploy.py b/tripleoclient/tests/v1/tripleo/test_tripleo_deploy.py index df113b4eb..af49a6c37 100644 --- a/tripleoclient/tests/v1/tripleo/test_tripleo_deploy.py +++ b/tripleoclient/tests/v1/tripleo/test_tripleo_deploy.py @@ -853,8 +853,7 @@ class TestDeployUndercloud(TestPluginV1): @mock.patch('os.execvp') def test_launch_ansible_with_args(self, mock_execvp, mock_chdir, mock_run): - args = ['deploy_steps_playbook.yaml', '--skip-tags', - 'validation'] + args = ['--skip-tags', 'validation'] self.cmd._launch_ansible('/tmp', args, operation='deploy') mock_chdir.assert_called_once() mock_run.assert_called_once_with(self.cmd.log, [ diff --git a/tripleoclient/v1/overcloud_deploy.py b/tripleoclient/v1/overcloud_deploy.py index 2805bca4d..4f65d2ad4 100644 --- a/tripleoclient/v1/overcloud_deploy.py +++ b/tripleoclient/v1/overcloud_deploy.py @@ -730,6 +730,16 @@ class DeployOvercloud(command.Command): 'use the --run-validations flag. These validations are ' 'now run via the external validations in ' 'tripleo-validations.')) + parser.add_argument( + '--inflight-validations', + action='store_true', + default=False, + dest='inflight', + help=_('Activate in-flight validations during the deploy. ' + 'In-flight validations provide a robust way to ensure ' + 'deployed services are running right after their ' + 'activation. Defaults to False.') + ) parser.add_argument( '--dry-run', action='store_true', @@ -974,9 +984,6 @@ class DeployOvercloud(command.Command): deployment_options['ansible_python_interpreter'] = \ parsed_args.deployment_python_interpreter - disabled_val = parsed_args.disable_validations - enable_val = parsed_args.run_validations - deployment.config_download( self.log, self.clients, stack, parsed_args.templates, parsed_args.overcloud_ssh_user, @@ -987,7 +994,7 @@ class DeployOvercloud(command.Command): timeout, verbosity=self.app_args.verbose_level, deployment_options=deployment_options, - in_flight_validations=(enable_val or not disabled_val)) + in_flight_validations=parsed_args.inflight) except Exception: deployment.set_deployment_status( self.clients, 'failed', diff --git a/tripleoclient/v1/tripleo_deploy.py b/tripleoclient/v1/tripleo_deploy.py index 2ee4409ff..ff886985d 100644 --- a/tripleoclient/v1/tripleo_deploy.py +++ b/tripleoclient/v1/tripleo_deploy.py @@ -859,14 +859,17 @@ class Deploy(command.Command): return self.tmp_ansible_dir # Never returns, calls exec() - def _launch_ansible(self, ansible_dir, list_args=None, operation="deploy"): + def _launch_ansible(self, ansible_dir, extra_args=None, + operation="deploy"): - if list_args is None: - if operation not in constants.DEPLOY_ANSIBLE_ACTIONS.keys(): - self.log.error(_('Operation %s is not allowed') % operation) - raise exceptions.DeploymentError('Invalid operation to run in ' - 'ansible.') - list_args = constants.DEPLOY_ANSIBLE_ACTIONS[operation].split() + if operation not in constants.DEPLOY_ANSIBLE_ACTIONS.keys(): + self.log.error(_('Operation %s is not allowed') % operation) + raise exceptions.DeploymentError('Invalid operation to run in ' + 'ansible.') + list_args = constants.DEPLOY_ANSIBLE_ACTIONS[operation].split() + + if extra_args: + list_args.extend(extra_args) self.log.warning(_('** Running ansible %s tasks **') % operation) os.chdir(ansible_dir) @@ -1049,6 +1052,16 @@ class Deploy(command.Command): 'openstack stack list\n ' 'where 8006 is the port specified by --heat-api-port.') ) + parser.add_argument( + '--inflight-validations', + action='store_true', + default=False, + dest='inflight', + help=_('Activate in-flight validations during the deploy. ' + 'In-flight validations provide a robust way to ensure ' + 'deployed services are running right after their ' + 'activation. Defaults to False.') + ) stack_action_group = parser.add_mutually_exclusive_group() @@ -1241,6 +1254,9 @@ class Deploy(command.Command): _('Using the existing %s for deployment') % ansible_config) shutil.copy(ansible_config, self.ansible_dir) + extra_args = [] + if not parsed_args.inflight: + extra_args = ['--skip-tags', 'opendev-validation'] # Kill heat, we're done with it now. if not parsed_args.keep_running: self._kill_heat(parsed_args) @@ -1248,7 +1264,8 @@ class Deploy(command.Command): if parsed_args.upgrade: # Run Upgrade tasks before the deployment rc = self._launch_ansible(self.ansible_dir, - operation='upgrade') + operation='upgrade', + extra_args=extra_args) if rc != 0: raise exceptions.DeploymentError('Upgrade failed') rc = self._launch_ansible(self.ansible_dir) @@ -1257,12 +1274,14 @@ class Deploy(command.Command): if parsed_args.upgrade: # Run Post Upgrade tasks after the deployment rc = self._launch_ansible(self.ansible_dir, - operation='post-upgrade') + operation='post-upgrade', + extra_args=extra_args) if rc != 0: raise exceptions.DeploymentError('Post Upgrade failed') # Run Online Upgrade tasks after the deployment rc = self._launch_ansible(self.ansible_dir, - operation='online-upgrade') + operation='online-upgrade', + extra_args=extra_args) if rc != 0: raise exceptions.DeploymentError( 'Online Upgrade failed') diff --git a/tripleoclient/v1/undercloud_config.py b/tripleoclient/v1/undercloud_config.py index 8cdb37085..fc413c067 100644 --- a/tripleoclient/v1/undercloud_config.py +++ b/tripleoclient/v1/undercloud_config.py @@ -742,7 +742,8 @@ def prepare_undercloud_deploy(upgrade=False, no_validations=False, utils.ansible_symlink() undercloud_preflight.check(verbose_level, upgrade) deploy_args += ['-e', os.path.join( - tht_templates, "environments/tripleo-validations.yaml")] + tht_templates, "environments/tripleo-validations.yaml"), + '--inflight-validations'] if CONF.get('custom_env_files'): for custom_file in CONF['custom_env_files']: diff --git a/tripleoclient/workflows/deployment.py b/tripleoclient/workflows/deployment.py index a2c682c8e..01ac138fe 100644 --- a/tripleoclient/workflows/deployment.py +++ b/tripleoclient/workflows/deployment.py @@ -313,7 +313,7 @@ def config_download(log, clients, stack, templates, ssh_user, ssh_key, ssh_network, output_dir, override_ansible_cfg, timeout, verbosity=1, deployment_options={}, - in_flight_validations=True): + in_flight_validations=False): workflow_client = clients.workflow_engine tripleoclients = clients.tripleoclient