Skip to content

Commit e3074f3

Browse files
committed
Merge pull request #795 from jschoiRR/diplo-2026
[Mold Diplo] 보안그룹(SG) 적용되 nic가 가상머신에서 제거 후 남아있는 매핑 데이터 제거, 이미지 업로드 시 읽기전용 2차스토리지에 업로드 되는 이슈 기능 수정(읽고/쓰기 2차스토리지만 업로드 되도록)
1 parent 130286a commit e3074f3

3 files changed

Lines changed: 34 additions & 4 deletions

File tree

engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4702,6 +4702,7 @@ private boolean orchestrateRemoveNicFromVm(final VirtualMachine vm, final Nic ni
47024702

47034703
_networkMgr.removeNic(vmProfile, nic);
47044704
_nicsDao.remove(nic.getId());
4705+
cleanupSecurityGroupMappingsIfNeeded(vmVO);
47054706
return true;
47064707
}
47074708

@@ -4777,13 +4778,26 @@ private boolean orchestrateRemoveVmFromNetwork(final VirtualMachine vm, final Ne
47774778
logger.debug("Successfully released nic {} for vm {}", nic, vm);
47784779

47794780
_networkMgr.removeNic(vmProfile, nic);
4781+
cleanupSecurityGroupMappingsIfNeeded(vmVO);
47804782
return true;
47814783
} finally {
47824784
_nicsDao.releaseFromLockTable(lock.getId());
47834785
logger.debug("Lock is released for nic {} as a part of remove vm {} from network {}", lock, vm, network);
47844786
}
47854787
}
47864788

4789+
private void cleanupSecurityGroupMappingsIfNeeded(final VMInstanceVO vm) {
4790+
if (vm == null || vm.getType() != VirtualMachine.Type.User || _securityGroupManager.isVmSecurityGroupEnabled(vm.getId())) {
4791+
return;
4792+
}
4793+
4794+
final UserVmVO userVm = _userVmDao.findById(vm.getId());
4795+
if (userVm != null) {
4796+
logger.debug("Removing stale security group mappings for VM {} after NIC removal left no security-group-enabled networks.", vm);
4797+
_securityGroupManager.removeInstanceFromGroups(userVm);
4798+
}
4799+
}
4800+
47874801
@Override
47884802
public void findHostAndMigrate(final String vmUuid, final Long newSvcOfferingId, final Map<String, String> customParameters, final ExcludeList excludes) throws InsufficientCapacityException, ConcurrentOperationException,
47894803
ResourceUnavailableException {

server/src/main/java/com/cloud/template/HypervisorTemplateAdapter.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,13 +300,29 @@ protected void createTemplateWithinZones(TemplateProfile profile, VMTemplateVO t
300300
}
301301

302302
protected List<DataStore> getImageStoresThrowsExceptionIfNotFound(long zoneId, TemplateProfile profile) {
303-
List<DataStore> imageStores = storeMgr.getImageStoresByZoneIds(zoneId);
303+
List<DataStore> imageStores = storeMgr.getImageStoresByScopeExcludingReadOnly(new ZoneScope(zoneId));
304304
if (imageStores == null || imageStores.size() == 0) {
305305
throw new CloudRuntimeException(String.format("Unable to find image store to download the template [%s].", profile.getTemplate()));
306306
}
307307
return imageStores;
308308
}
309309

310+
protected DataStore verifyHeuristicRulesForZone(VMTemplateVO template, Long zoneId) {
311+
HeuristicType heuristicType;
312+
if (ImageFormat.ISO.equals(template.getFormat())) {
313+
heuristicType = HeuristicType.ISO;
314+
} else {
315+
heuristicType = HeuristicType.TEMPLATE;
316+
}
317+
DataStore imageStore = heuristicRuleHelper.getImageStoreIfThereIsHeuristicRule(zoneId, heuristicType, template);
318+
if (imageStore == null || isWritableImageStore(imageStore, zoneId)) {
319+
return imageStore;
320+
}
321+
322+
logger.info("Heuristic rule selected readonly image store [{}] in zone [{}]; skipping it for template upload.", imageStore, zoneId);
323+
return null;
324+
}
325+
310326
protected void standardImageStoreAllocation(List<DataStore> imageStores, VMTemplateVO template) {
311327
Set<Long> zoneSet = new HashSet<Long>();
312328
Collections.shuffle(imageStores);

ui/public/locales/ko_KR.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1791,9 +1791,9 @@
17911791
"label.nfsserver": "NFS \uc11c\ubc84",
17921792
"label.nic": "NIC",
17931793
"label.nicadaptertype": "NIC \uc5b4\ub311\ud130 \uc720\ud615",
1794-
"label.nicmultiqueuenumber": "NIC multiqueue \ubc88\ud638",
1795-
"label.nicmultiqueuenumber.tooltip": "NIC multiqueue \ubc88\ud638\uc785\ub2c8\ub2e4. KVM\ub9cc \uc9c0\uc6d0\ud569\ub2c8\ub2e4. \"-1\" \uac12\uc740 NIC multiqueue \ubc88\ud638\uac00 \uc778\uc2a4\ud134\uc2a4\uc758 vCPU \ubc88\ud638\ub85c \uc124\uc815\ub428\uc744 \ub098\ud0c0\ub0c5\ub2c8\ub2e4.",
1796-
"label.nicpackedvirtqueuesenabled": "NIC \uc555\ucd95 virtqueues \ud65c\uc131\ud654\ub428",
1794+
"label.nicmultiqueuenumber": "NIC multiqueue \uc218",
1795+
"label.nicmultiqueuenumber.tooltip": "NIC multiqueue \uc218\uc785\ub2c8\ub2e4. KVM\ub9cc \uc9c0\uc6d0\ud569\ub2c8\ub2e4. \"-1\" \uac12\uc740 NIC multiqueue \uc218\ub294 \uc778\uc2a4\ud134\uc2a4\uc758 vCPU \uc218\ub85c \uc124\uc815\ub428\uc744 \ub098\ud0c0\ub0c5\ub2c8\ub2e4.",
1796+
"label.nicpackedvirtqueuesenabled": "NIC \uc555\ucd95 virtqueues \ud65c\uc131\ud654",
17971797
"label.nicpackedvirtqueuesenabled.tooltip": "NIC \uc555\ucd95 virtqueues \ud65c\uc131\ud654 \uc5ec\ubd80\uc785\ub2c8\ub2e4. QEMU >= 4.2.0 \ubc0f Libvirt >= 6.3.0\uc778 KVM\ub9cc \uc9c0\uc6d0\ud569\ub2c8\ub2e4.",
17981798
"label.nics": "NIC",
17991799
"label.no": "\uc544\ub2c8\uc624",

0 commit comments

Comments
 (0)