From 32e1826ed6eecb631c91c9db3eac9ed297093f7d Mon Sep 17 00:00:00 2001 From: "yingzhe.hu" Date: Thu, 28 May 2026 15:43:20 +0800 Subject: [PATCH] [ha]: fallback pre-fence peer to dest Allow HA pre-fence pending tags to record accessiblePeerHostUuid as none when the checker cannot provide a peer. The late KVM pre-fence extension resolves that marker after host allocation. Resolves: ZSTAC-83890 Change-Id: I36426b3386f1080ddeae8396ea9c4f7a81e25711 --- .../main/java/org/zstack/compute/vm/VmInstanceBase.java | 9 ++++++--- .../main/java/org/zstack/compute/vm/VmSystemTags.java | 1 + 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/compute/src/main/java/org/zstack/compute/vm/VmInstanceBase.java b/compute/src/main/java/org/zstack/compute/vm/VmInstanceBase.java index e4a581eac2f..7f2b556fa27 100755 --- a/compute/src/main/java/org/zstack/compute/vm/VmInstanceBase.java +++ b/compute/src/main/java/org/zstack/compute/vm/VmInstanceBase.java @@ -1059,11 +1059,14 @@ private void createPreFencePendingTag(HaStartVmInstanceMsg msg) { String suspectHostUuid = StringUtils.trimToNull(CollectionUtils.isEmpty(msg.getSoftAvoidHostUuids()) ? self.getLastHostUuid() : msg.getSoftAvoidHostUuids().get(0)); String peerHostUuid = StringUtils.trimToNull(msg.getAccessiblePeerHostUuid()); - if (suspectHostUuid == null || peerHostUuid == null) { - logger.debug(String.format("HA-start vm[%s]: skip creating pre-fence tag because suspect host[%s] or peer host[%s] is absent", - self.getUuid(), suspectHostUuid, peerHostUuid)); + if (suspectHostUuid == null) { + logger.debug(String.format("HA-start vm[%s]: skip creating pre-fence tag because suspect host is absent", + self.getUuid())); return; } + if (peerHostUuid == null) { + peerHostUuid = VmSystemTags.HA_PRE_FENCE_ACCESSIBLE_PEER_HOST_UUID_NONE; + } Map tokens = new HashMap<>(); tokens.put(VmSystemTags.HA_PRE_FENCE_SUSPECT_HOST_UUID_TOKEN, suspectHostUuid); diff --git a/compute/src/main/java/org/zstack/compute/vm/VmSystemTags.java b/compute/src/main/java/org/zstack/compute/vm/VmSystemTags.java index 606462ac9ba..4d766070a2a 100755 --- a/compute/src/main/java/org/zstack/compute/vm/VmSystemTags.java +++ b/compute/src/main/java/org/zstack/compute/vm/VmSystemTags.java @@ -321,6 +321,7 @@ public String desensitizeTag(SystemTag systemTag, String tag) { public static String HA_PRE_FENCE_SUSPECT_HOST_UUID_TOKEN = "suspectHostUuid"; public static String HA_PRE_FENCE_ACCESSIBLE_PEER_HOST_UUID_TOKEN = "accessiblePeerHostUuid"; + public static String HA_PRE_FENCE_ACCESSIBLE_PEER_HOST_UUID_NONE = "none"; public static PatternedSystemTag HA_PRE_FENCE_PENDING = new PatternedSystemTag(String.format("haPreFencePending::{%s}::{%s}", HA_PRE_FENCE_SUSPECT_HOST_UUID_TOKEN,