Remove the require_audit_flag while checking remote SPG status

This commit removes the require_audit_flag from the peer group
audit conditional, preventing local subclouds from being
incorrectly set to secondary status when a non-primary site
comes online.

Additionally, it removes the "subcloud migrate" API, as the
"subcloud-peer-group migrate" can be re-executed to migrate a
single subcloud that failed to migrate in a previous attempt.

Test Plan:
PASS - Power off the primary site and migrate the subclouds to
       the non-primary site. Power on the primary site after the
       migration is complete, checking the subclouds' status on
       both sites. On the primary site, the subclouds should be
       secondary, and on the non-primary site, they should be
       managed and online.
PASS - With both the primary site and non-primary site online,
       migrate the subclouds away and back, verifying that
       the operation completes successfully.

Closes-Bug: 2049336
Depends-On: I793bee7d680d59a4d29a585c88c8c1689976ee1b

Change-Id: Ib702fcf318d01bd7bfa8a19ec2aee516f6089cb0
Signed-off-by: Zhang Rong(Jon) <rong.zhang@windriver.com>
This commit is contained in:
Zhang Rong(Jon) 2024-01-15 13:12:10 +08:00 committed by Gustavo Herzmann
parent 072f2f45f0
commit 827799658c
8 changed files with 9 additions and 176 deletions

View File

@ -611,73 +611,6 @@ Response Example
.. literalinclude:: samples/subclouds/subcloud-patch-update_status-response.json
:language: json
*****************************************
Migrate a specific subcloud
*****************************************
.. rest_method:: PATCH /v1.0/subclouds/{subcloud}/migrate
**Normal response codes**
200
**Error response codes**
badRequest (400), unauthorized (401), forbidden (403), badMethod (405),
HTTPUnprocessableEntity (422), internalServerError (500),
serviceUnavailable (503)
**Request parameters**
.. rest_parameters:: parameters.yaml
- subcloud: subcloud_uri
- sysadmin_password: sysadmin_password
Request Example
----------------
.. literalinclude:: samples/subclouds/subcloud-patch-migrate-request.json
:language: json
**Response parameters**
.. rest_parameters:: parameters.yaml
- id: subcloud_id
- group_id: group_id
- name: subcloud_name
- description: subcloud_description
- location: subcloud_location
- software-version: software_version
- availability-status: availability_status
- error-description: error_description
- deploy-status: deploy_status
- backup-status: backup_status
- backup-datetime: backup_datetime
- openstack-installed: openstack_installed
- management-state: management_state
- systemcontroller-gateway-ip: systemcontroller_gateway_ip
- management-start-ip: management_start_ip
- management-end-ip: management_end_ip
- management-subnet: management_subnet
- management-gateway-ip: management_gateway_ip
- rehome_data: rehome_data
- created-at: created_at
- updated-at: updated_at
- data_install: data_install
- data_upgrade: data_upgrade
- endpoint_sync_status: endpoint_sync_status
- sync_status: sync_status
- endpoint_type: sync_status_type
Response Example
----------------
.. literalinclude:: samples/subclouds/subcloud-patch-migrate-response.json
:language: json
*****************************
Deletes a specific subcloud
*****************************

View File

@ -1,3 +0,0 @@
{
"sysadmin_password": "XXXXXXX"
}

View File

@ -1,26 +0,0 @@
{
"id": 20,
"name": "testsub",
"description": "des",
"location": "CA",
"software-version": "23.09",
"management-state": "unmanaged",
"availability-status": "offline",
"deploy-status": "secondary",
"backup-status": null,
"backup-datetime": null,
"error-description": "No errors present",
"management-subnet": "192.168.97.0/24",
"management-start-ip": "192.168.97.2",
"management-end-ip": "192.168.97.200",
"management-gateway-ip": "192.168.97.1",
"openstack-installed": false,
"systemcontroller-gateway-ip": "192.168.10.1",
"data_install": null,
"data_upgrade": null,
"created-at": "2023-08-01 05:44:07.722249",
"updated-at": "2023-08-01 05:47:32.950772",
"group_id": 1,
"peer_group_id": "123",
"rehome_data": "{\"saved_payload\": {\"system_mode\": \"simplex\", \"name\": \"testsub\", \"description\": \"dddd\", \"location\": \"PEK SE Lab\", \"external_oam_subnet\": \"128.224.119.0/24\", \"external_oam_gateway_address\": \"128.224.119.1\", \"external_oam_floating_address\": \"128.224.119.55\", \"management_subnet\": \"192.168.97.0/24\", \"management_start_address\": \"192.168.97.2\", \"management_end_address\": \"192.168.97.200\", \"management_gateway_address\": \"192.168.97.1\", \"systemcontroller_gateway_address\": \"192.168.10.1\", \"docker_http_proxy\": \"http://147.11.252.42:9090\", \"docker_https_proxy\": \"http://147.11.252.42:9090\", \"docker_no_proxy\": [], \"bootstrap-address\": \"128.224.119.56\", \"software_version\": \"23.09\"}}"
}

View File

@ -1,5 +1,5 @@
# Copyright (c) 2017 Ericsson AB.
# Copyright (c) 2017-2023 Wind River Systems, Inc.
# Copyright (c) 2017-2024 Wind River Systems, Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
@ -288,38 +288,6 @@ class SubcloudsController(object):
else dccommon_consts.DEPLOY_CONFIG_UP_TO_DATE
return sync_status
def _validate_migrate(self, payload, subcloud):
# Verify rehome data
if not subcloud.rehome_data:
LOG.exception("Unable to migrate subcloud %s, "
"required rehoming data is missing" % subcloud.name)
pecan.abort(500, _("Unable to migrate subcloud %s, "
"required rehoming data is missing" % subcloud.name))
rehome_data = json.loads(subcloud.rehome_data)
if 'saved_payload' not in rehome_data:
LOG.exception("Unable to migrate subcloud %s, "
"saved_payload is missing in rehoming data" % subcloud.name)
pecan.abort(500, _("Unable to migrate subcloud %s, "
"saved_payload is missing in rehoming data" % subcloud.name))
saved_payload = rehome_data['saved_payload']
# Validate saved_payload
if len(saved_payload) == 0:
LOG.exception("Unable to migrate subcloud %s, "
"saved_payload is empty" % subcloud.name)
pecan.abort(500, _("Unable to migrate subcloud %s, "
"saved_payload is empty" % subcloud.name))
if 'bootstrap-address' not in saved_payload:
LOG.exception("Unable to migrate subcloud %s, "
"bootstrap-address is missing in rehoming data" % subcloud.name)
pecan.abort(500, _("Unable to migrate subcloud %s, "
"bootstrap-address is missing in rehoming data" % subcloud.name))
# Validate sysadmin_password is in payload
if 'sysadmin_password' not in payload:
LOG.exception("Unable to migrate subcloud %s, "
"need sysadmin_password" % subcloud.name)
pecan.abort(500, _("Unable to migrate subcloud %s, "
"need sysadmin_password" % subcloud.name))
def _validate_rehome_pending(self, subcloud, management_state):
unmanaged = dccommon_consts.MANAGEMENT_UNMANAGED
error_msg = None
@ -909,29 +877,6 @@ class SubcloudsController(object):
except Exception:
LOG.exception("Unable to prestage subcloud %s" % subcloud.name)
pecan.abort(500, _('Unable to prestage subcloud'))
elif verb == 'migrate':
try:
# Reject if not in secondary/rehome-failed/rehome-prep-failed state
if subcloud.deploy_status not in [consts.DEPLOY_STATE_SECONDARY,
consts.DEPLOY_STATE_REHOME_FAILED,
consts.DEPLOY_STATE_REHOME_PREP_FAILED]:
LOG.exception("Unable to migrate subcloud %s, "
"must be in secondary or rehome failure state" % subcloud.name)
pecan.abort(400, _("Unable to migrate subcloud %s, "
"must be in secondary or rehome failure state" %
subcloud.name))
payload = json.loads(request.body)
self._validate_migrate(payload, subcloud)
# Call migrate
self.dcmanager_rpc_client.migrate_subcloud(context, subcloud.id, payload)
return db_api.subcloud_db_model_to_dict(subcloud)
except RemoteError as e:
pecan.abort(422, e.value)
except Exception:
LOG.exception(
"Unable to migrate subcloud %s" % subcloud.name)
pecan.abort(500, _('Unable to migrate subcloud'))
@utils.synchronized(LOCK_NAME)
@index.when(method='delete', template='json')

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 2022 Wind River Systems, Inc.
# Copyright (c) 2022-2024 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
@ -84,10 +84,6 @@ subclouds_rules = [
{
'method': 'PATCH',
'path': '/v1.0/subclouds/{subcloud}/update_status'
},
{
'method': 'PATCH',
'path': '/v1.0/subclouds/{subcloud}/migrate'
}
]
)

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 2023 Wind River Systems, Inc.
# Copyright (c) 2023-2024 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
@ -156,12 +156,11 @@ class PeerGroupAuditManager(manager.Manager):
raise e
self.require_audit_flag = False
# if remote subcloud peer group's migration_status is 'complete'
# or self.require_audit_flag is True, get remote subclouds.
# For 'managed+online' subclouds, set 'unmanaged+secondary' to
# local on same subclouds
# if remote subcloud peer group's migration_status is 'complete',
# get remote subclouds. For 'managed+online' subclouds,
# set 'unmanaged+secondary' to local on same subclouds
elif remote_peer_group.get("migration_status") == \
consts.PEER_GROUP_MIGRATION_COMPLETE or self.require_audit_flag:
consts.PEER_GROUP_MIGRATION_COMPLETE:
remote_subclouds = \
self._get_subclouds_by_peer_group_from_system_peer(
system_peer,

View File

@ -1,4 +1,4 @@
# Copyright (c) 2017-2023 Wind River Systems, Inc.
# Copyright (c) 2017-2024 Wind River Systems, Inc.
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
@ -295,12 +295,6 @@ class DCManagerService(service.Service):
subcloud_id,
deploy_status)
@request_context
def migrate_subcloud(self, context, subcloud_ref, payload):
LOG.info("Handling migrate_subcloud request for: %s",
subcloud_ref)
return self.subcloud_manager.migrate_subcloud(context, subcloud_ref, payload)
@run_in_thread
@request_context
def subcloud_deploy_resume(self, context, subcloud_id, subcloud_name,

View File

@ -1,4 +1,4 @@
# Copyright (c) 2017-2023 Wind River Systems, Inc.
# Copyright (c) 2017-2024 Wind River Systems, Inc.
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
@ -248,11 +248,6 @@ class ManagerClient(RPCClient):
payload=payload,
deploy_states_to_run=deploy_states_to_run))
def migrate_subcloud(self, ctxt, subcloud_ref, payload):
return self.cast(ctxt, self.make_msg('migrate_subcloud',
subcloud_ref=subcloud_ref,
payload=payload))
def get_subcloud_name_by_region_name(self, ctxt, subcloud_region):
return self.call(ctxt, self.make_msg('get_subcloud_name_by_region_name',
subcloud_region=subcloud_region))