diff --git a/dbm-ui/backend/db_meta/api/cluster/tendbcluster/remotedb_node_migrate.py b/dbm-ui/backend/db_meta/api/cluster/tendbcluster/remotedb_node_migrate.py index 54d76dc451..a7d1c524f2 100644 --- a/dbm-ui/backend/db_meta/api/cluster/tendbcluster/remotedb_node_migrate.py +++ b/dbm-ui/backend/db_meta/api/cluster/tendbcluster/remotedb_node_migrate.py @@ -14,7 +14,7 @@ from backend.db_meta import api, request_validator from backend.db_meta.api import common from backend.db_meta.enums import ClusterType, InstanceRole, InstanceStatus, MachineType -from backend.db_meta.models import Cluster, StorageInstance, StorageInstanceTuple, TenDBClusterStorageSet +from backend.db_meta.models import Cluster, Machine, StorageInstance, StorageInstanceTuple, TenDBClusterStorageSet from backend.db_package.models import Package from backend.flow.consts import MediumEnum from backend.flow.engine.bamboo.scene.common.get_real_version import get_mysql_real_version @@ -44,7 +44,9 @@ def storage_create( mysql_pkg = Package.get_latest_package(version=mysql_version, pkg_type=MediumEnum.MySQL, db_type=DBType.MySQL) machines = [] storages = [] + machine_ips = [] if master_ip is not None: + machine_ips.append(master_ip) machines.append( { "ip": master_ip, @@ -65,6 +67,7 @@ def storage_create( }, ) if slave_ip is not None: + machine_ips.append(slave_ip) machines.append( { "ip": slave_ip, @@ -86,6 +89,8 @@ def storage_create( ) api.machine.create(machines=machines, creator=creator, bk_cloud_id=bk_cloud_id) + machine_objs = Machine.objects.filter(bk_cloud_id=bk_cloud_id, ip__in=machine_ips) + machine_objs.update(db_module_id=cluster.db_module_id) api.storage_instance.create( instances=storages, creator=creator, time_zone=time_zone, status=InstanceStatus.RESTORING ) diff --git a/dbm-ui/backend/flow/utils/mysql/mysql_db_meta.py b/dbm-ui/backend/flow/utils/mysql/mysql_db_meta.py index 27fe96ad1d..e8ae300f37 100644 --- a/dbm-ui/backend/flow/utils/mysql/mysql_db_meta.py +++ b/dbm-ui/backend/flow/utils/mysql/mysql_db_meta.py @@ -728,6 +728,10 @@ def slave_recover_add_instance(self): bk_cloud_id=int(self.ticket_data["bk_cloud_id"]), creator=self.ticket_data["created_by"], ) + machine_objs = Machine.objects.filter( + bk_cloud_id=self.ticket_data["bk_cloud_id"], ip=self.cluster["install_ip"] + ) + machine_objs.update(db_module_id=self.ticket_data["db_module_id"]) storage_objs = api.storage_instance.create( instances=storage_instances, creator=self.ticket_data["created_by"], @@ -939,6 +943,11 @@ def migrate_cluster_add_instance(self): api.machine.create( bk_cloud_id=self.ticket_data["bk_cloud_id"], machines=machines, creator=self.ticket_data["created_by"] ) + machines_objs = Machine.objects.filter( + bk_cloud_id=self.ticket_data["bk_cloud_id"], + ip__in=[self.cluster["new_slave_ip"], self.cluster["new_master_ip"]], + ) + machines_objs.update(db_module_id=self.ticket_data["db_module_id"]) storage_objs = api.storage_instance.create( instances=storage_instances, creator=self.ticket_data["created_by"],