From dc53d29eaa0e5f67335aef3db23fc11a17dc21b0 Mon Sep 17 00:00:00 2001 From: Mark Goddard Date: Wed, 19 May 2021 19:47:36 +0100 Subject: [PATCH] chrony: cleanup during overcloud host upgrade The Kolla Ansible chrony container is disabled by default in the Wallaby release. A new kolla-ansible chrony-cleanup command can be used to clean up the container. This change extends the 'kayobe overcloud host upgrade' command to cover cleaning up the chrony container (if disabled) and deploying a host chrony daemon. Depends-On: https://review.opendev.org/c/openstack/kolla-ansible/+/792119 Change-Id: I275102ec6b5bab6982577b52fd29654c874446ce --- kayobe/cli/commands.py | 12 +++++++++++- kayobe/tests/unit/cli/test_commands.py | 26 +++++++++++++++++++++++++- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/kayobe/cli/commands.py b/kayobe/cli/commands.py index 6b91b7881..ba1bca569 100644 --- a/kayobe/cli/commands.py +++ b/kayobe/cli/commands.py @@ -1044,7 +1044,8 @@ class OvercloudHostCommandRun(KayobeAnsibleMixin, VaultMixin, Command): extra_vars=extra_vars) -class OvercloudHostUpgrade(KayobeAnsibleMixin, VaultMixin, Command): +class OvercloudHostUpgrade(KollaAnsibleMixin, KayobeAnsibleMixin, VaultMixin, + Command): """Upgrade the overcloud host services. Performs the changes necessary to make the host services suitable for the @@ -1058,6 +1059,15 @@ class OvercloudHostUpgrade(KayobeAnsibleMixin, VaultMixin, Command): "overcloud-docker-sdk-upgrade", "overcloud-etc-hosts-fixup") self.run_kayobe_playbooks(parsed_args, playbooks, limit="overcloud") + # TODO(mgoddard): Remove this in Y cycle after Kolla Ansible chrony + # container has been dropped for a cycle. + # NOTE(mgoddard): Clean up the chrony container if it exists, and + # deploy a host chrony daemon. + self.generate_kolla_ansible_config(parsed_args, service_config=False) + self.run_kolla_ansible_overcloud(parsed_args, "chrony-cleanup") + playbooks = _build_playbook_list("time") + self.run_kayobe_playbooks(parsed_args, playbooks, limit="overcloud") + class OvercloudDatabaseBackup(KollaAnsibleMixin, KayobeAnsibleMixin, VaultMixin, Command): diff --git a/kayobe/tests/unit/cli/test_commands.py b/kayobe/tests/unit/cli/test_commands.py index 988bc2642..7d941c650 100644 --- a/kayobe/tests/unit/cli/test_commands.py +++ b/kayobe/tests/unit/cli/test_commands.py @@ -1192,7 +1192,9 @@ class TestCase(unittest.TestCase): @mock.patch.object(commands.KayobeAnsibleMixin, "run_kayobe_playbooks") - def test_overcloud_host_upgrade(self, mock_run): + @mock.patch.object(commands.KollaAnsibleMixin, + "run_kolla_ansible_overcloud") + def test_overcloud_host_upgrade(self, mock_kolla_run, mock_run): command = commands.OvercloudHostUpgrade(TestApp(), []) parser = command.get_parser("test") parsed_args = parser.parse_args([]) @@ -1215,9 +1217,31 @@ class TestCase(unittest.TestCase): ], limit="overcloud", ), + mock.call( + mock.ANY, + [utils.get_data_files_path("ansible", "kolla-ansible.yml")], + ignore_limit=True, + tags="config", + ), + mock.call( + mock.ANY, + [ + utils.get_data_files_path( + "ansible", "time.yml"), + ], + limit="overcloud", + ), ] self.assertEqual(expected_calls, mock_run.call_args_list) + expected_calls = [ + mock.call( + mock.ANY, + "chrony-cleanup", + ), + ] + self.assertEqual(expected_calls, mock_kolla_run.call_args_list) + @mock.patch.object(commands.KollaAnsibleMixin, "run_kolla_ansible_overcloud") def test_overcloud_database_backup(self, mock_run):