From f42cb042f8f1236933a524d81582ec4408f2e756 Mon Sep 17 00:00:00 2001 From: shenjin Date: Tue, 19 Nov 2024 22:48:34 +0800 Subject: [PATCH] [compute]: set vm bind with current cluster uuid when vm migrate to other cluster, set vm bind with current cluster uuid, and remove the bind cluster uuid from system tag, and update system tag value Resolves: ZSTAC-66476 Change-Id: I617a776b726161746c686f696e68637565676c72 (cherry picked from commit 06af53558719e8833ca46dc811028aa69fc9b4bb) --- .../allocator/ResourceBindingAllocatorFlow.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/compute/src/main/java/org/zstack/compute/allocator/ResourceBindingAllocatorFlow.java b/compute/src/main/java/org/zstack/compute/allocator/ResourceBindingAllocatorFlow.java index d82e3e69b23..5cb565683f4 100644 --- a/compute/src/main/java/org/zstack/compute/allocator/ResourceBindingAllocatorFlow.java +++ b/compute/src/main/java/org/zstack/compute/allocator/ResourceBindingAllocatorFlow.java @@ -90,6 +90,17 @@ public void allocate() { // get bind resources from config ResourceBindingClusterCollector clusterCollector = new ResourceBindingClusterCollector(); if (!resourceConfig) { + //remove bind cluster uuid from system tag, use current cluster uuid from config + if (resources.containsKey(clusterCollector.getType())) { + List uuids = resources.get(clusterCollector.getType()); + if (!uuids.contains(spec.getVmInstance().getClusterUuid())) { + String tag = String.format("Cluster:%s", spec.getVmInstance().getClusterUuid()); + VmSystemTags.VM_RESOURCE_BINGDING.updateTagByToken(spec.getVmInstance().getUuid(), + VmSystemTags.VM_RESOURCE_BINGDING_TOKEN, tag); + } + resources.remove(clusterCollector.getType()); + } + resources.computeIfAbsent(clusterCollector.getType(), k -> new ArrayList<>()).add(spec.getVmInstance().getClusterUuid()); }