Support N-1 subcloud rehoming with N playbook

This commit updates the rehoming procedure to execute the ansible
playbook from the system's controller current version, stored in
/usr/share. This way, N-1 subclouds from a N system controller will use
the playbook from N release instead of the one from N-1.

Test plan:
1. PASS: Deploy and manage a N-1 subcloud in a N system controller.
2. PASS: Verify the subcloud's kubernetes and software endpoints are
   out-of-sync.
3. PASS: Rehome the N-1 subcloud to another N system controller.
5. PASS: Manage the N-1 subcloud in the new system controller.
6. PASS: Verify the kubernetes, kube-rootca and software endpoints are
   out-of-sync in the rehomed subcloud.
7. PASS: Prestage the N-1 subcloud for sw-deploy to the N release.
8. PASS: Upgrade the N-1 subcloud.
9. PASS: Orchestrate the kubernetes upgrade for the subcloud.
10. PASS: Orchestrate the kube-rootca update for the subcloud.
11. PASS: Verify the subcloud becomes in-sync.
12. PASS: After rehoming the N-1 subcloud, locally apply a patch using
    software upload and sw-manager.
13. PASS: Rehome a N subcloud in a N system controller and verify it
    uses the correct playbook.

Depends-On: https://review.opendev.org/c/starlingx/ansible-playbooks/+/959563
Closes-Bug: 2122331

Change-Id: I764c25386803982644ce05403810dedc3bb7ddcf
Signed-off-by: Raphael <Raphael.Lima@windriver.com>
This commit is contained in:
Raphael
2025-09-04 13:41:19 -03:00
parent 86d3e8632d
commit 1f07f9015b
2 changed files with 19 additions and 11 deletions

View File

@@ -241,8 +241,10 @@ class SubcloudManager(manager.Manager):
secret_name = SubcloudManager._get_subcloud_cert_secret_name(subcloud_region)
cert = {
"apiVersion": "%s/%s"
% (kubeoperator.CERT_MANAGER_GROUP, kubeoperator.CERT_MANAGER_VERSION),
"apiVersion": (
"%s/%s"
% (kubeoperator.CERT_MANAGER_GROUP, kubeoperator.CERT_MANAGER_VERSION)
),
"kind": "Certificate",
"metadata": {"namespace": CERT_NAMESPACE, "name": cert_name},
"spec": {
@@ -582,9 +584,7 @@ class SubcloudManager(manager.Manager):
rehome_command = [
"ansible-playbook",
utils.get_playbook_for_software_version(
ANSIBLE_SUBCLOUD_REHOME_PLAYBOOK, software_version
),
ANSIBLE_SUBCLOUD_REHOME_PLAYBOOK,
"-i",
ansible_subcloud_inventory_file,
"--limit",
@@ -592,6 +592,12 @@ class SubcloudManager(manager.Manager):
"--timeout",
REHOME_PLAYBOOK_TIMEOUT,
"-e",
(
"install_release_version=%s" % software_version
if software_version
else SW_VERSION
),
"-e",
extra_vars,
]
return rehome_command

View File

@@ -3013,9 +3013,7 @@ class TestSubcloudCompose(BaseTestSubcloudManager):
rehome_command,
[
"ansible-playbook",
cutils.get_playbook_for_software_version(
subcloud_manager.ANSIBLE_SUBCLOUD_REHOME_PLAYBOOK, SW_VERSION
),
subcloud_manager.ANSIBLE_SUBCLOUD_REHOME_PLAYBOOK,
"-i",
f"{ANS_PATH}/subcloud1_inventory.yml",
"--limit",
@@ -3023,6 +3021,8 @@ class TestSubcloudCompose(BaseTestSubcloudManager):
"--timeout",
subcloud_manager.REHOME_PLAYBOOK_TIMEOUT,
"-e",
f"install_release_version={SW_VERSION}",
"-e",
str("override_files_dir='%s' region_name=%s")
% (ANS_PATH, subcloud_region),
],
@@ -4332,9 +4332,11 @@ class TestSubcloudMigrate(BaseTestSubcloudManager):
)
self.saved_payload = {
"deploy_status": consts.DEPLOY_STATE_DONE,
"rehome_data": '{"saved_payload": {"system_mode": "simplex",\
"name": "testsub", "bootstrap-address": "128.224.119.56",\
"admin_password": "TGk2OW51eA=="}}',
"rehome_data": (
'{"saved_payload": {"system_mode": "simplex",\
"name": "testsub", "bootstrap-address": "128.224.119.56",\
"admin_password": "TGk2OW51eA=="}}'
),
}
@mock.patch.object(subcloud_manager, "db_api", side_effect=db_api)