Skip to content

Commit 179dfbf

Browse files
committed
<fix>[kvm]: prevent metadata deletion when DVD returns empty
When hypervisor metadata collection from DVD returns an empty list, the existing metadata was deleted before the empty check, causing all hosts to lose their hypervisor version metadata and matchState to become Unknown. 1. Why is this change necessary? saveHostOsCategoryList first deleted all existing metadata for the management node, then checked if the input was empty. When DVD collection returned empty, this wiped all metadata, causing matchTargetVersion to be null and matchState to become Unknown. 2. How does it address the problem? Move the empty-list check before the delete operation so that an empty input preserves existing metadata. A warning is logged to indicate the skip. 3. Are there any side effects? None. Non-empty input behavior is unchanged. # Summary of changes (by module): - kvm: move empty check before metadata delete in KvmHypervisorInfoManagerImpl.saveHostOsCategoryList() Related: ZSTAC-83682 Change-Id: I81f9baacac7fce9af2363a0ce5c960532d383890
1 parent 933931f commit 179dfbf

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

plugin/kvm/src/main/java/org/zstack/kvm/hypervisor/KvmHypervisorInfoManagerImpl.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -275,13 +275,15 @@ private boolean saveMetadataList(List<HypervisorMetadataDefinition> definitions)
275275

276276
@Transactional
277277
protected boolean saveHostOsCategoryList(List<HostOsCategoryVO> categoryVOS) {
278+
if (CollectionUtils.isEmpty(categoryVOS)) {
279+
logger.warn("no hypervisor metadata collected from DVD, skip refresh to preserve existing metadata");
280+
return false;
281+
}
282+
278283
// refresh all metadata with current management node
279284
SQL.New(KvmHostHypervisorMetadataVO.class)
280285
.eq(KvmHostHypervisorMetadataVO_.managementNodeUuid, Platform.getManagementServerId())
281286
.delete();
282-
if (CollectionUtils.isEmpty(categoryVOS)) {
283-
return false;
284-
}
285287

286288
Set<String> requestArchitectures = categoryVOS.stream()
287289
.map(HostOsCategoryVO::getArchitecture)

0 commit comments

Comments
 (0)