Make hypervisor stats check a validation
Moves the hypervisor stats check to be a proper validation. There is a change in behavior with this move in that previously an exception was raised and the deployment terminated when the check failed. Moving it to a validation makes the check non-fatal by default, however it can be made fatal again by specifying --validation-errors-fatal on the cli. Change-Id: I87eebcb8603de8620610cbbc8ca1f5c7d3aed992
This commit is contained in:
parent
02fd96fdfb
commit
ea22c2bd20
@ -45,6 +45,8 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
|
|||||||
# mock validations for all deploy tests
|
# mock validations for all deploy tests
|
||||||
# for validator tests, see test_overcloud_deploy_validators.py
|
# for validator tests, see test_overcloud_deploy_validators.py
|
||||||
validator_mock = mock.Mock(return_value=(0, 0))
|
validator_mock = mock.Mock(return_value=(0, 0))
|
||||||
|
self.real_predeploy_verify_capabilities = \
|
||||||
|
self.cmd._predeploy_verify_capabilities
|
||||||
self.cmd._predeploy_verify_capabilities = validator_mock
|
self.cmd._predeploy_verify_capabilities = validator_mock
|
||||||
|
|
||||||
self._get_passwords = generate_overcloud_passwords_mock
|
self._get_passwords = generate_overcloud_passwords_mock
|
||||||
@ -481,9 +483,7 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
|
|||||||
|
|
||||||
@mock.patch('tripleoclient.v1.overcloud_deploy.DeployOvercloud.'
|
@mock.patch('tripleoclient.v1.overcloud_deploy.DeployOvercloud.'
|
||||||
'_deploy_tripleo_heat_templates', autospec=True)
|
'_deploy_tripleo_heat_templates', autospec=True)
|
||||||
@mock.patch('tripleoclient.v1.overcloud_deploy.DeployOvercloud.'
|
def test_missing_sat_url(self, mock_deploy_tht):
|
||||||
'_pre_heat_deploy', autospec=True)
|
|
||||||
def test_missing_sat_url(self, mock_pre_deploy, mock_deploy_tht):
|
|
||||||
|
|
||||||
arglist = ['--templates', '--rhel-reg',
|
arglist = ['--templates', '--rhel-reg',
|
||||||
'--reg-method', 'satellite', '--reg-org', '123456789',
|
'--reg-method', 'satellite', '--reg-org', '123456789',
|
||||||
@ -511,11 +511,9 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
|
|||||||
'_deploy_postconfig', autospec=True)
|
'_deploy_postconfig', autospec=True)
|
||||||
@mock.patch('tripleoclient.v1.overcloud_deploy.DeployOvercloud.'
|
@mock.patch('tripleoclient.v1.overcloud_deploy.DeployOvercloud.'
|
||||||
'_update_parameters', autospec=True)
|
'_update_parameters', autospec=True)
|
||||||
@mock.patch('tripleoclient.v1.overcloud_deploy.DeployOvercloud.'
|
|
||||||
'_pre_heat_deploy', autospec=True)
|
|
||||||
@mock.patch('tripleoclient.v1.overcloud_deploy.DeployOvercloud.'
|
@mock.patch('tripleoclient.v1.overcloud_deploy.DeployOvercloud.'
|
||||||
'_heat_deploy', autospec=True)
|
'_heat_deploy', autospec=True)
|
||||||
def test_environment_dirs(self, mock_deploy_heat, mock_pre_heat,
|
def test_environment_dirs(self, mock_deploy_heat,
|
||||||
mock_update_parameters, mock_post_config,
|
mock_update_parameters, mock_post_config,
|
||||||
mock_utils_check_nodes, mock_utils_endpoint,
|
mock_utils_check_nodes, mock_utils_endpoint,
|
||||||
mock_utils_createrc, mock_utils_tempest):
|
mock_utils_createrc, mock_utils_tempest):
|
||||||
@ -556,11 +554,9 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
|
|||||||
'_deploy_postconfig', autospec=True)
|
'_deploy_postconfig', autospec=True)
|
||||||
@mock.patch('tripleoclient.v1.overcloud_deploy.DeployOvercloud.'
|
@mock.patch('tripleoclient.v1.overcloud_deploy.DeployOvercloud.'
|
||||||
'_update_parameters', autospec=True)
|
'_update_parameters', autospec=True)
|
||||||
@mock.patch('tripleoclient.v1.overcloud_deploy.DeployOvercloud.'
|
|
||||||
'_pre_heat_deploy', autospec=True)
|
|
||||||
@mock.patch('tripleoclient.v1.overcloud_deploy.DeployOvercloud.'
|
@mock.patch('tripleoclient.v1.overcloud_deploy.DeployOvercloud.'
|
||||||
'_heat_deploy', autospec=True)
|
'_heat_deploy', autospec=True)
|
||||||
def test_environment_dirs_env(self, mock_deploy_heat, mock_pre_heat,
|
def test_environment_dirs_env(self, mock_deploy_heat,
|
||||||
mock_update_parameters, mock_post_config,
|
mock_update_parameters, mock_post_config,
|
||||||
mock_utils_check_nodes, mock_utils_endpoint,
|
mock_utils_check_nodes, mock_utils_endpoint,
|
||||||
mock_utils_createrc, mock_utils_tempest):
|
mock_utils_createrc, mock_utils_tempest):
|
||||||
@ -598,9 +594,7 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
|
|||||||
@mock.patch('tripleoclient.utils.get_overcloud_endpoint', autospec=True)
|
@mock.patch('tripleoclient.utils.get_overcloud_endpoint', autospec=True)
|
||||||
@mock.patch('tripleoclient.v1.overcloud_deploy.DeployOvercloud.'
|
@mock.patch('tripleoclient.v1.overcloud_deploy.DeployOvercloud.'
|
||||||
'_deploy_tripleo_heat_templates', autospec=True)
|
'_deploy_tripleo_heat_templates', autospec=True)
|
||||||
@mock.patch('tripleoclient.v1.overcloud_deploy.DeployOvercloud.'
|
def test_rhel_reg_params_provided(self, mock_deploy_tht,
|
||||||
'_pre_heat_deploy', autospec=True)
|
|
||||||
def test_rhel_reg_params_provided(self, mock_pre_deploy, mock_deploy_tht,
|
|
||||||
mock_oc_endpoint,
|
mock_oc_endpoint,
|
||||||
mock_create_ocrc,
|
mock_create_ocrc,
|
||||||
mock_create_tempest_deployer_input):
|
mock_create_tempest_deployer_input):
|
||||||
@ -832,22 +826,6 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
|
|||||||
self.cmd._validate_args,
|
self.cmd._validate_args,
|
||||||
parsed_args)
|
parsed_args)
|
||||||
|
|
||||||
@mock.patch('tripleoclient.utils.check_hypervisor_stats',
|
|
||||||
autospec=True)
|
|
||||||
def test_pre_heat_deploy_failed(self, mock_check_hypervisor_stats):
|
|
||||||
clients = self.app.client_manager
|
|
||||||
orchestration_client = clients.tripleoclient.orchestration
|
|
||||||
orchestration_client.stacks.get.return_value = None
|
|
||||||
mock_check_hypervisor_stats.return_value = None
|
|
||||||
arglist = ['--templates']
|
|
||||||
verifylist = [
|
|
||||||
('templates', '/usr/share/openstack-tripleo-heat-templates/')
|
|
||||||
]
|
|
||||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
|
||||||
self.assertRaises(exceptions.DeploymentError,
|
|
||||||
self.cmd.take_action,
|
|
||||||
parsed_args)
|
|
||||||
|
|
||||||
@mock.patch('tripleoclient.v1.overcloud_deploy.DeployOvercloud.'
|
@mock.patch('tripleoclient.v1.overcloud_deploy.DeployOvercloud.'
|
||||||
'_heat_deploy', autospec=True)
|
'_heat_deploy', autospec=True)
|
||||||
def test_try_overcloud_deploy_with_first_template_existing(
|
def test_try_overcloud_deploy_with_first_template_existing(
|
||||||
@ -897,9 +875,7 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
|
|||||||
@mock.patch('tripleoclient.utils.get_overcloud_endpoint', autospec=True)
|
@mock.patch('tripleoclient.utils.get_overcloud_endpoint', autospec=True)
|
||||||
@mock.patch('tripleoclient.v1.overcloud_deploy.DeployOvercloud.'
|
@mock.patch('tripleoclient.v1.overcloud_deploy.DeployOvercloud.'
|
||||||
'_deploy_tripleo_heat_templates', autospec=True)
|
'_deploy_tripleo_heat_templates', autospec=True)
|
||||||
@mock.patch('tripleoclient.v1.overcloud_deploy.DeployOvercloud.'
|
def test_dry_run(self, mock_deploy_tht,
|
||||||
'_pre_heat_deploy', autospec=True)
|
|
||||||
def test_dry_run(self, mock_pre_deploy, mock_deploy_tht,
|
|
||||||
mock_oc_endpoint,
|
mock_oc_endpoint,
|
||||||
mock_create_ocrc,
|
mock_create_ocrc,
|
||||||
mock_create_tempest_deployer_input):
|
mock_create_tempest_deployer_input):
|
||||||
@ -927,10 +903,7 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
|
|||||||
'_heat_deploy', autospec=True)
|
'_heat_deploy', autospec=True)
|
||||||
@mock.patch('tripleoclient.v1.overcloud_deploy.DeployOvercloud.'
|
@mock.patch('tripleoclient.v1.overcloud_deploy.DeployOvercloud.'
|
||||||
'set_overcloud_passwords', autospec=True)
|
'set_overcloud_passwords', autospec=True)
|
||||||
@mock.patch('tripleoclient.v1.overcloud_deploy.DeployOvercloud.'
|
|
||||||
'_pre_heat_deploy', autospec=True)
|
|
||||||
def test_answers_file(self,
|
def test_answers_file(self,
|
||||||
mock_pre_deploy,
|
|
||||||
mock_set_overcloud_passwords,
|
mock_set_overcloud_passwords,
|
||||||
mock_heat_deploy,
|
mock_heat_deploy,
|
||||||
mock_oc_endpoint,
|
mock_oc_endpoint,
|
||||||
@ -1038,3 +1011,28 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
|
|||||||
args,
|
args,
|
||||||
stack)
|
stack)
|
||||||
self.assertTrue(mock_init.called)
|
self.assertTrue(mock_init.called)
|
||||||
|
|
||||||
|
@mock.patch('tripleoclient.utils.check_nodes_count')
|
||||||
|
@mock.patch('tripleoclient.utils.check_hypervisor_stats')
|
||||||
|
@mock.patch('tripleoclient.utils.assign_and_verify_profiles')
|
||||||
|
@mock.patch('tripleoclient.v1.overcloud_deploy.DeployOvercloud.'
|
||||||
|
'_check_ironic_boot_configuration')
|
||||||
|
@mock.patch('tripleoclient.v1.overcloud_deploy.DeployOvercloud.'
|
||||||
|
'_collect_flavors')
|
||||||
|
def test_predeploy_verify_capabilities_hypervisor_stats(
|
||||||
|
self, mock_collect_flavors,
|
||||||
|
mock_check_ironic_boot_configuration,
|
||||||
|
mock_assign_and_verify_profiles,
|
||||||
|
mock_check_hypervisor_stats,
|
||||||
|
mock_check_nodes_count):
|
||||||
|
self.cmd._predeploy_verify_capabilities = \
|
||||||
|
self.real_predeploy_verify_capabilities
|
||||||
|
|
||||||
|
parsed_args = mock.Mock()
|
||||||
|
mock_assign_and_verify_profiles.return_value = (0, 0)
|
||||||
|
mock_check_nodes_count.return_value = (True, 0, 0)
|
||||||
|
|
||||||
|
# A None return value here indicates an error
|
||||||
|
mock_check_hypervisor_stats.return_value = None
|
||||||
|
self.cmd._predeploy_verify_capabilities(parsed_args)
|
||||||
|
self.assertEqual(1, self.cmd.predeploy_errors)
|
||||||
|
@ -307,17 +307,6 @@ class DeployOvercloud(command.Command):
|
|||||||
else:
|
else:
|
||||||
raise exceptions.DeploymentError("Heat Stack update failed.")
|
raise exceptions.DeploymentError("Heat Stack update failed.")
|
||||||
|
|
||||||
def _pre_heat_deploy(self):
|
|
||||||
"""Setup before the Heat stack create or update has been done."""
|
|
||||||
clients = self.app.client_manager
|
|
||||||
compute_client = clients.compute
|
|
||||||
|
|
||||||
self.log.debug("Checking hypervisor stats")
|
|
||||||
if utils.check_hypervisor_stats(compute_client) is None:
|
|
||||||
raise exceptions.DeploymentError(
|
|
||||||
"Expected hypervisor stats not met")
|
|
||||||
return True
|
|
||||||
|
|
||||||
def _load_environment_directories(self, directories):
|
def _load_environment_directories(self, directories):
|
||||||
if os.environ.get('TRIPLEO_ENVIRONMENT_DIRECTORY'):
|
if os.environ.get('TRIPLEO_ENVIRONMENT_DIRECTORY'):
|
||||||
directories.append(os.environ.get('TRIPLEO_ENVIRONMENT_DIRECTORY'))
|
directories.append(os.environ.get('TRIPLEO_ENVIRONMENT_DIRECTORY'))
|
||||||
@ -622,6 +611,13 @@ class DeployOvercloud(command.Command):
|
|||||||
self.predeploy_errors += errors
|
self.predeploy_errors += errors
|
||||||
self.predeploy_warnings += warnings
|
self.predeploy_warnings += warnings
|
||||||
|
|
||||||
|
compute_client = self.app.client_manager.compute
|
||||||
|
|
||||||
|
self.log.debug("Checking hypervisor stats")
|
||||||
|
if utils.check_hypervisor_stats(compute_client) is None:
|
||||||
|
self.log.error("Expected hypervisor stats not met")
|
||||||
|
self.predeploy_errors += 1
|
||||||
|
|
||||||
return self.predeploy_errors, self.predeploy_warnings
|
return self.predeploy_errors, self.predeploy_warnings
|
||||||
|
|
||||||
__kernel_id = None
|
__kernel_id = None
|
||||||
@ -952,8 +948,6 @@ class DeployOvercloud(command.Command):
|
|||||||
else:
|
else:
|
||||||
self.log.info("Stack found, will be doing a stack update")
|
self.log.info("Stack found, will be doing a stack update")
|
||||||
|
|
||||||
self._pre_heat_deploy()
|
|
||||||
|
|
||||||
if parsed_args.rhel_reg:
|
if parsed_args.rhel_reg:
|
||||||
if parsed_args.reg_method == 'satellite':
|
if parsed_args.reg_method == 'satellite':
|
||||||
sat_required_args = (parsed_args.reg_org and
|
sat_required_args = (parsed_args.reg_org and
|
||||||
|
Loading…
Reference in New Issue
Block a user