Fail the overcloud deploy is ceph-ansible.yaml is included

TripleO recently concluded the migration to the new ceph deployment
tool (cephadm). The ceph-ansible.yaml environment file, however, is
still relevant in an upgrade context, where ceph-ansible rolling
update playbook is executed.
For this reason, this patch introduces a new validation to make sure
this environment file and the related registry resources can be used
during the update/upgrade context but not when a regular overcloud
deploy or stack updates are executed.

Change-Id: Iec23801a9eec1830469a53ab5ffc641125b5d3ff
This commit is contained in:
Francesco Pantano 2021-06-24 12:04:07 +02:00
parent aaea7d50ef
commit c455a4142c
4 changed files with 69 additions and 4 deletions

View File

@ -871,6 +871,31 @@ class TestWaitForStackUtil(TestCase):
with self.assertRaises(exceptions.InvalidConfiguration):
utils.check_ceph_fsid_matches_env_files(mock_stack, provided_env)
def test_check_ceph_ansible(self):
res_reg = {
'resource_registry': {
'OS::Tripleo::Services::CephMon': '/path/to/ceph-ansible.yml',
}
}
utils.check_ceph_ansible(res_reg.get('resource_registry', {}),
'UpgradePrepare')
utils.check_ceph_ansible(res_reg.get('resource_registry', {}),
'UpgradeConverge')
def test_check_ceph_ansible_fail(self):
res_reg = {
'resource_registry': {
'OS::Tripleo::Services::CephMon': '/path/to/ceph-ansible.yml',
}
}
with self.assertRaises(exceptions.InvalidConfiguration):
utils.check_ceph_ansible(res_reg.get('resource_registry', {}),
'DeployOvercloud')
def test_check_swift_and_rgw(self):
stack_reg = {
'OS::TripleO::Services::SwiftProxy': 'OS::Heat::None',

View File

@ -153,6 +153,7 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
@mock.patch('tripleoclient.utils.check_stack_network_matches_env_files')
@mock.patch('tripleoclient.utils.check_ceph_fsid_matches_env_files')
@mock.patch('tripleoclient.utils.check_swift_and_rgw')
@mock.patch('tripleoclient.utils.check_ceph_ansible')
@mock.patch("heatclient.common.event_utils.get_events")
@mock.patch('tripleo_common.update.add_breakpoints_cleanup_into_env',
autospec=True)
@ -167,6 +168,7 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
mock_breakpoints_cleanup,
mock_events, mock_stack_network_check,
mock_ceph_fsid, mock_swift_rgw,
mock_ceph_ansible,
mock_get_undercloud_host_entry, mock_copy,
mock_get_ctlplane_attrs, mock_nic_ansiblei,
mock_process_env, mock_roles_data,
@ -379,6 +381,7 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
@mock.patch('tripleoclient.utils.check_stack_network_matches_env_files')
@mock.patch('tripleoclient.utils.check_ceph_fsid_matches_env_files')
@mock.patch('tripleoclient.utils.check_swift_and_rgw')
@mock.patch('tripleoclient.utils.check_ceph_ansible')
@mock.patch('tripleoclient.v1.overcloud_deploy.DeployOvercloud.'
'_deploy_postconfig', autospec=True)
@mock.patch('tripleo_common.update.add_breakpoints_cleanup_into_env',
@ -395,7 +398,7 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
mock_create_parameters_env, mock_validate_args,
mock_breakpoints_cleanup,
mock_postconfig, mock_stack_network_check,
mock_ceph_fsid, mock_swift_rgw,
mock_ceph_fsid, mock_swift_rgw, mock_ceph_ansible,
mock_get_undercloud_host_entry, mock_copy,
mock_chdir,
mock_process_env, mock_roles_data,
@ -473,6 +476,7 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
@mock.patch('tripleoclient.utils.check_stack_network_matches_env_files')
@mock.patch('tripleoclient.utils.check_ceph_fsid_matches_env_files')
@mock.patch('tripleoclient.utils.check_swift_and_rgw')
@mock.patch('tripleoclient.utils.check_ceph_ansible')
@mock.patch("heatclient.common.event_utils.get_events", autospec=True)
@mock.patch('tripleo_common.update.add_breakpoints_cleanup_into_env',
autospec=True)
@ -488,6 +492,7 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
mock_breakpoints_cleanup,
mock_events, mock_stack_network_check,
mock_ceph_fsid, mock_swift_rgw,
mock_ceph_ansible,
mock_get_undercloud_host_entry,
mock_copy, mock_nic_ansible,
mock_process_env,
@ -575,6 +580,7 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
@mock.patch('tripleoclient.utils.check_stack_network_matches_env_files')
@mock.patch('tripleoclient.utils.check_ceph_fsid_matches_env_files')
@mock.patch('tripleoclient.utils.check_swift_and_rgw')
@mock.patch('tripleoclient.utils.check_ceph_ansible')
@mock.patch('tripleoclient.v1.overcloud_deploy.DeployOvercloud.'
'_deploy_postconfig', autospec=True)
@mock.patch('tripleoclient.v1.overcloud_deploy.DeployOvercloud.'
@ -586,7 +592,8 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
def test_environment_dirs(self, mock_deploy_heat, mock_create_env,
mock_update_parameters, mock_post_config,
mock_stack_network_check, mock_ceph_fsid,
mock_swift_rgw, mock_copy, mock_nic_ansible,
mock_swift_rgw, mock_ceph_ansible,
mock_copy, mock_nic_ansible,
mock_process_env, mock_rc_params,
mock_check_service_vip_migr):
fixture = deployment.DeploymentWorkflowFixture()
@ -800,6 +807,7 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
@mock.patch('tripleoclient.utils.check_stack_network_matches_env_files')
@mock.patch('tripleoclient.utils.check_ceph_fsid_matches_env_files')
@mock.patch('tripleoclient.utils.check_swift_and_rgw')
@mock.patch('tripleoclient.utils.check_ceph_ansible')
@mock.patch('tripleoclient.v1.overcloud_deploy.DeployOvercloud.'
'_heat_deploy', autospec=True)
@mock.patch('tempfile.mkdtemp', autospec=True)
@ -807,6 +815,7 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
def test_answers_file(self, mock_rmtree, mock_tmpdir,
mock_heat_deploy, mock_stack_network_check,
mock_ceph_fsid, mock_swift_rgw,
mock_ceph_ansible,
mock_get_undercloud_host_entry,
mock_copy, mock_nic_ansible,
mock_roles_data, mock_image_prepare,
@ -915,6 +924,7 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
@mock.patch('tripleoclient.utils.check_stack_network_matches_env_files')
@mock.patch('tripleoclient.utils.check_ceph_fsid_matches_env_files')
@mock.patch('tripleoclient.utils.check_swift_and_rgw')
@mock.patch('tripleoclient.utils.check_ceph_ansible')
@mock.patch('tripleoclient.v1.overcloud_deploy.DeployOvercloud.'
'_deploy_postconfig', autospec=True)
@mock.patch('tripleo_common.update.add_breakpoints_cleanup_into_env')
@ -935,6 +945,7 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
mock_deploy_post_config,
mock_stack_network_check,
mock_ceph_fsid, mock_swift_rgw,
mock_ceph_ansible,
mock_get_undercloud_host_entry, mock_copy,
mock_get_ctlplane_attrs,
mock_roles_data,
@ -1329,11 +1340,12 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
@mock.patch('tripleoclient.utils.check_stack_network_matches_env_files')
@mock.patch('tripleoclient.utils.check_ceph_fsid_matches_env_files')
@mock.patch('tripleoclient.utils.check_swift_and_rgw')
@mock.patch('tripleoclient.utils.check_ceph_ansible')
@mock.patch('heatclient.common.template_utils.deep_update', autospec=True)
def test_config_download_timeout(
self, mock_hc, mock_stack_network_check,
mock_ceph_fsid, mock_swift_rgw, mock_hd,
mock_get_undercloud_host_entry, mock_copy,
mock_ceph_fsid, mock_swift_rgw, mock_ceph_ansible,
mock_hd, mock_get_undercloud_host_entry, mock_copy,
mock_get_ctlplane_attrs, mock_nic_ansible,
mock_process_env, mock_roles_data,
mock_container_prepare, mock_generate_password,

View File

@ -1051,6 +1051,31 @@ def get_rc_params(orchestration_client, stack_name):
return rc_params
def check_ceph_ansible(resource_registry, stage):
"""Fail if ceph-ansible is still passed
If any of the ceph-ansible related resources are part of the
Ceph services path, then the overcloud deploy (or the stack
update) should fail, unless they are included in the context
of Update/Upgrade/Converge, where these environments are still
relevant and required.
"""
if not resource_registry or stage not in "DeployOvercloud":
return
# for each Ceph related service, fail if ceph-ansible is part
# of the provided path
for name, path in resource_registry.items():
if 'Ceph' in name and 'ceph-ansible' in path:
raise exceptions.InvalidConfiguration('The Ceph deployment is not '
'available anymore using '
'ceph-ansible. If you want '
'to deploy Ceph, please add '
'the cephadm environment '
'file.')
def check_ceph_fsid_matches_env_files(stack, environment):
"""Check CephClusterFSID against proposed env files

View File

@ -367,6 +367,9 @@ class DeployOvercloud(command.Command):
# upgrades: check if swift is deployed
utils.check_swift_and_rgw(stack, env,
self.__class__.__name__)
# check if ceph-ansible env is present
utils.check_ceph_ansible(env.get('resource_registry', {}),
self.__class__.__name__)
# check migration to new nic config with ansible
utils.check_nic_config_with_ansible(stack, env)
# check migration to service vips managed by servce