Merge "Check CephClusterFSID against proposed env files"
This commit is contained in:
commit
10c2931ea8
|
@ -505,6 +505,49 @@ class TestWaitForStackUtil(TestCase):
|
|||
with self.assertRaises(exceptions.InvalidConfiguration):
|
||||
utils.check_stack_network_matches_env_files(mock_stack, env)
|
||||
|
||||
def test_check_ceph_fsid_matches_env_files(self):
|
||||
stack_params = {
|
||||
'CephClusterFSID': 'ceph_fsid_val',
|
||||
'key1': 'val1',
|
||||
'key2': 'val2',
|
||||
}
|
||||
mock_stack = mock.MagicMock()
|
||||
mock_stack.environment = mock.MagicMock()
|
||||
mock_stack.environment.return_value = {
|
||||
'parameter_defaults': stack_params
|
||||
}
|
||||
provided_env = {
|
||||
'parameter_defaults': {
|
||||
'CephClusterFSID': mock_stack.environment()
|
||||
.get('parameter_defaults', {})
|
||||
.get('CephClusterFSID', False),
|
||||
'key1': 'val1',
|
||||
'key2': 'val2',
|
||||
}
|
||||
}
|
||||
utils.check_ceph_fsid_matches_env_files(mock_stack, provided_env)
|
||||
|
||||
def test_check_ceph_fsid_matches_env_files_fail(self):
|
||||
stack_params = {
|
||||
'CephClusterFSID': 'ceph_fsid_val',
|
||||
'key1': 'val1',
|
||||
'key2': 'val2',
|
||||
}
|
||||
provided_env = {
|
||||
'parameter_defaults': {
|
||||
'CephClusterFSID': 'new_or_wrong_fsid_val',
|
||||
'key1': 'val1',
|
||||
'key2': 'val2',
|
||||
}
|
||||
}
|
||||
mock_stack = mock.MagicMock()
|
||||
mock_stack.environment = mock.MagicMock()
|
||||
mock_stack.environment.return_value = {
|
||||
'parameter_defaults': stack_params
|
||||
}
|
||||
with self.assertRaises(exceptions.InvalidConfiguration):
|
||||
utils.check_ceph_fsid_matches_env_files(mock_stack, provided_env)
|
||||
|
||||
@mock.patch('subprocess.check_call')
|
||||
@mock.patch('os.path.exists')
|
||||
def test_remove_known_hosts(self, mock_exists, mock_check_call):
|
||||
|
|
|
@ -178,6 +178,7 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
|
|||
'_get_undercloud_host_entry', autospec=True,
|
||||
return_value='192.168.0.1 uc.ctlplane.localhost uc.ctlplane')
|
||||
@mock.patch('tripleoclient.utils.check_stack_network_matches_env_files')
|
||||
@mock.patch('tripleoclient.utils.check_ceph_fsid_matches_env_files')
|
||||
@mock.patch("heatclient.common.event_utils.get_events")
|
||||
@mock.patch('tripleo_common.update.add_breakpoints_cleanup_into_env',
|
||||
autospec=True)
|
||||
|
@ -192,6 +193,7 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
|
|||
mock_create_parameters_env,
|
||||
mock_breakpoints_cleanup,
|
||||
mock_events, mock_stack_network_check,
|
||||
mock_ceph_fsid,
|
||||
mock_get_undercloud_host_entry, mock_copy,
|
||||
mock_get_ctlplane_attrs):
|
||||
fixture = deployment.DeploymentWorkflowFixture()
|
||||
|
@ -394,6 +396,7 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
|
|||
'_get_undercloud_host_entry', autospec=True,
|
||||
return_value='192.168.0.1 uc.ctlplane.localhost uc.ctlplane')
|
||||
@mock.patch('tripleoclient.utils.check_stack_network_matches_env_files')
|
||||
@mock.patch('tripleoclient.utils.check_ceph_fsid_matches_env_files')
|
||||
@mock.patch('shutil.rmtree', autospec=True)
|
||||
@mock.patch('tripleoclient.utils.get_overcloud_endpoint', autospec=True)
|
||||
@mock.patch('tripleoclient.v1.overcloud_deploy.DeployOvercloud.'
|
||||
|
@ -419,7 +422,7 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
|
|||
mock_breakpoints_cleanup,
|
||||
mock_postconfig, mock_shutil_rmtree,
|
||||
mock_invoke_plan_env_wf,
|
||||
mock_stack_network_check,
|
||||
mock_stack_network_check, mock_ceph_fsid,
|
||||
mock_get_undercloud_host_entry, mock_copy, mock_chdir,
|
||||
mock_get_ctlplane_attrs):
|
||||
fixture = deployment.DeploymentWorkflowFixture()
|
||||
|
@ -531,6 +534,7 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
|
|||
'_get_undercloud_host_entry', autospec=True,
|
||||
return_value='192.168.0.1 uc.ctlplane.localhost uc.ctlplane')
|
||||
@mock.patch('tripleoclient.utils.check_stack_network_matches_env_files')
|
||||
@mock.patch('tripleoclient.utils.check_ceph_fsid_matches_env_files')
|
||||
@mock.patch('tripleoclient.workflows.parameters.'
|
||||
'check_deprecated_parameters', autospec=True)
|
||||
@mock.patch('tripleoclient.v1.overcloud_deploy.DeployOvercloud.'
|
||||
|
@ -551,7 +555,7 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
|
|||
mock_create_parameters_env, mock_validate_args,
|
||||
mock_breakpoints_cleanup,
|
||||
mock_postconfig, mock_deprecated_params, mock_stack_network_check,
|
||||
mock_get_undercloud_host_entry, mock_copy,
|
||||
mock_ceph_fsid, mock_get_undercloud_host_entry, mock_copy,
|
||||
mock_chdir, mock_overcloudrc):
|
||||
fixture = deployment.DeploymentWorkflowFixture()
|
||||
self.useFixture(fixture)
|
||||
|
@ -606,6 +610,7 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
|
|||
'_get_undercloud_host_entry', autospec=True,
|
||||
return_value='192.168.0.1 uc.ctlplane.localhost uc.ctlplane')
|
||||
@mock.patch('tripleoclient.utils.check_stack_network_matches_env_files')
|
||||
@mock.patch('tripleoclient.utils.check_ceph_fsid_matches_env_files')
|
||||
@mock.patch("heatclient.common.event_utils.get_events", autospec=True)
|
||||
@mock.patch('tripleo_common.update.add_breakpoints_cleanup_into_env',
|
||||
autospec=True)
|
||||
|
@ -620,6 +625,7 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
|
|||
mock_deploy_postconfig,
|
||||
mock_breakpoints_cleanup,
|
||||
mock_events, mock_stack_network_check,
|
||||
mock_ceph_fsid,
|
||||
mock_get_undercloud_host_entry,
|
||||
mock_copy):
|
||||
fixture = deployment.DeploymentWorkflowFixture()
|
||||
|
@ -691,6 +697,7 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
|
|||
|
||||
@mock.patch('tripleoclient.utils.copy_clouds_yaml')
|
||||
@mock.patch('tripleoclient.utils.check_stack_network_matches_env_files')
|
||||
@mock.patch('tripleoclient.utils.check_ceph_fsid_matches_env_files')
|
||||
@mock.patch('tripleoclient.v1.overcloud_deploy.DeployOvercloud.'
|
||||
'_deploy_postconfig', autospec=True)
|
||||
@mock.patch('tripleoclient.v1.overcloud_deploy.DeployOvercloud.'
|
||||
|
@ -699,7 +706,8 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
|
|||
'_heat_deploy', autospec=True)
|
||||
def test_environment_dirs(self, mock_deploy_heat,
|
||||
mock_update_parameters, mock_post_config,
|
||||
mock_stack_network_check, mock_copy):
|
||||
mock_stack_network_check, mock_ceph_fsid,
|
||||
mock_copy):
|
||||
fixture = deployment.DeploymentWorkflowFixture()
|
||||
self.useFixture(fixture)
|
||||
plane_management_fixture = deployment.PlanManagementFixture()
|
||||
|
@ -756,6 +764,7 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
|
|||
'overcloud', headers={'x-container-meta-usage-tripleo': 'plan'})
|
||||
|
||||
@mock.patch('tripleoclient.utils.check_stack_network_matches_env_files')
|
||||
@mock.patch('tripleoclient.utils.check_ceph_fsid_matches_env_files')
|
||||
@mock.patch('tripleoclient.utils.get_stack', autospec=True)
|
||||
@mock.patch('tripleoclient.v1.overcloud_deploy.DeployOvercloud.'
|
||||
'_deploy_postconfig', autospec=True)
|
||||
|
@ -766,7 +775,8 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
|
|||
def test_environment_dirs_env(self, mock_deploy_heat,
|
||||
mock_update_parameters, mock_post_config,
|
||||
mock_utils_get_stack,
|
||||
mock_stack_network_check):
|
||||
mock_stack_network_check,
|
||||
mock_ceph_fsid):
|
||||
|
||||
plane_management_fixture = deployment.PlanManagementFixture()
|
||||
self.useFixture(plane_management_fixture)
|
||||
|
@ -997,13 +1007,15 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
|
|||
'_get_undercloud_host_entry', autospec=True,
|
||||
return_value='192.168.0.1 uc.ctlplane.localhost uc.ctlplane')
|
||||
@mock.patch('tripleoclient.utils.check_stack_network_matches_env_files')
|
||||
@mock.patch('tripleoclient.utils.check_ceph_fsid_matches_env_files')
|
||||
@mock.patch('tripleoclient.v1.overcloud_deploy.DeployOvercloud.'
|
||||
'_heat_deploy', autospec=True)
|
||||
@mock.patch('tempfile.mkdtemp', autospec=True)
|
||||
@mock.patch('shutil.rmtree', autospec=True)
|
||||
def test_answers_file(self, mock_rmtree, mock_tmpdir,
|
||||
mock_heat_deploy, mock_stack_network_check,
|
||||
mock_get_undercloud_host_entry, mock_copy):
|
||||
mock_ceph_fsid, mock_get_undercloud_host_entry,
|
||||
mock_copy):
|
||||
fixture = deployment.DeploymentWorkflowFixture()
|
||||
self.useFixture(fixture)
|
||||
clients = self.app.client_manager
|
||||
|
@ -1082,6 +1094,7 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
|
|||
'_get_undercloud_host_entry', autospec=True,
|
||||
return_value='192.168.0.1 uc.ctlplane.localhost uc.ctlplane')
|
||||
@mock.patch('tripleoclient.utils.check_stack_network_matches_env_files')
|
||||
@mock.patch('tripleoclient.utils.check_ceph_fsid_matches_env_files')
|
||||
@mock.patch('tripleoclient.v1.overcloud_deploy.DeployOvercloud.'
|
||||
'_create_parameters_env', autospec=True)
|
||||
@mock.patch('heatclient.common.template_utils.'
|
||||
|
@ -1092,6 +1105,7 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
|
|||
mock_process_env,
|
||||
mock_create_parameters_env,
|
||||
mock_stack_network_check,
|
||||
mock_ceph_fsid,
|
||||
mock_get_undercloud_host_entry):
|
||||
plane_management_fixture = deployment.PlanManagementFixture()
|
||||
self.useFixture(plane_management_fixture)
|
||||
|
@ -1138,6 +1152,7 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
|
|||
'_get_undercloud_host_entry', autospec=True,
|
||||
return_value='192.168.0.1 uc.ctlplane.localhost uc.ctlplane')
|
||||
@mock.patch('tripleoclient.utils.check_stack_network_matches_env_files')
|
||||
@mock.patch('tripleoclient.utils.check_ceph_fsid_matches_env_files')
|
||||
@mock.patch('tripleoclient.v1.overcloud_deploy.DeployOvercloud.'
|
||||
'_deploy_postconfig', autospec=True)
|
||||
@mock.patch('tripleo_common.update.add_breakpoints_cleanup_into_env')
|
||||
|
@ -1159,6 +1174,7 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
|
|||
mock_breakpoints_cleanup,
|
||||
mock_deploy_post_config,
|
||||
mock_stack_network_check,
|
||||
mock_ceph_fsid,
|
||||
mock_get_undercloud_host_entry, mock_copy,
|
||||
mock_get_ctlplane_attrs):
|
||||
fixture = deployment.DeploymentWorkflowFixture()
|
||||
|
@ -1502,12 +1518,14 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
|
|||
@mock.patch('tripleoclient.v1.overcloud_deploy.DeployOvercloud.'
|
||||
'_heat_deploy', autospec=True)
|
||||
@mock.patch('tripleoclient.utils.check_stack_network_matches_env_files')
|
||||
@mock.patch('tripleoclient.utils.check_ceph_fsid_matches_env_files')
|
||||
@mock.patch('heatclient.common.template_utils.deep_update', autospec=True)
|
||||
@mock.patch('tripleoclient.workflows.plan_management.'
|
||||
'create_plan_from_templates', autospec=True)
|
||||
def test_config_download_timeout(
|
||||
self, mock_plan_man, mock_hc, mock_stack_network_check, mock_hd,
|
||||
mock_overcloudrc, mock_get_undercloud_host_entry, mock_copy,
|
||||
self, mock_plan_man, mock_hc, mock_stack_network_check,
|
||||
mock_ceph_fsid, mock_hd, mock_overcloudrc,
|
||||
mock_get_undercloud_host_entry, mock_copy,
|
||||
mock_get_ctlplane_attrs):
|
||||
fixture = deployment.DeploymentWorkflowFixture()
|
||||
self.useFixture(fixture)
|
||||
|
|
|
@ -1030,6 +1030,33 @@ def get_stack(orchestration_client, stack_name):
|
|||
pass
|
||||
|
||||
|
||||
def check_ceph_fsid_matches_env_files(stack, environment):
|
||||
"""Check CephClusterFSID against proposed env files
|
||||
|
||||
There have been cases where operators inadvertenly changed the
|
||||
CephClusterFSID on a stack update, which is unsupported by both
|
||||
Ceph and openstack.
|
||||
For this reason we need to check that the existing deployed Ceph
|
||||
cluster ID present in the stack is consistent with the value of
|
||||
the environment, raising an exception if they are different.
|
||||
"""
|
||||
env_ceph_fsid = environment.get('parameter_defaults',
|
||||
{}).get('CephClusterFSID', False)
|
||||
stack_ceph_fsid = stack.environment().get('parameter_defaults',
|
||||
{}).get('CephClusterFSID', False)
|
||||
|
||||
if bool(env_ceph_fsid) and env_ceph_fsid != stack_ceph_fsid:
|
||||
raise exceptions.InvalidConfiguration('The CephFSID environment value '
|
||||
' ({}) does not match the stack '
|
||||
' configuration value ({}).'
|
||||
' Ensure the CephClusterFSID '
|
||||
' param is properly configured '
|
||||
' in the storage environment '
|
||||
' files.'
|
||||
.format(env_ceph_fsid,
|
||||
stack_ceph_fsid))
|
||||
|
||||
|
||||
def check_stack_network_matches_env_files(stack, environment):
|
||||
"""Check stack against proposed env files to ensure non-breaking change
|
||||
|
||||
|
|
|
@ -515,6 +515,16 @@ class DeployOvercloud(command.Command):
|
|||
if not parsed_args.disable_validations:
|
||||
# note(aschultz): network validation goes here before we deploy
|
||||
utils.check_stack_network_matches_env_files(stack, env)
|
||||
ceph_deployed = env.get('resource_registry', {}).get(
|
||||
'OS::TripleO::Services::CephMon', 'OS::Heat::None')
|
||||
ceph_external = env.get('resource_registry', {}).get(
|
||||
'OS::TripleO::Services::CephExternal', 'OS::Heat::None')
|
||||
# note (fpantano) if ceph is not TripleO deployed and no
|
||||
# external ceph cluster are present, there's no reason to
|
||||
# make this check and we can simply ignore it
|
||||
if (ceph_deployed != "OS::Heat::None"
|
||||
or ceph_external != "OS::Heat::None"):
|
||||
utils.check_ceph_fsid_matches_env_files(stack, env)
|
||||
bp_cleanup = self._create_breakpoint_cleanup_env(
|
||||
tht_root, parsed_args.stack)
|
||||
template_utils.deep_update(env, bp_cleanup)
|
||||
|
|
Loading…
Reference in New Issue