Skip to content

Commit 3935109

Browse files
authored
Merge branch 'apache:main' into Remove-Domain/IP-from-Password-Reset-Link-to-custom-Global-Setting
2 parents f66003a + f671461 commit 3935109

File tree

23 files changed

+327
-77
lines changed

23 files changed

+327
-77
lines changed

agent/conf/agent.properties

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,9 @@ hypervisor.type=kvm
213213
# If null (default), defaults to the VM's OS architecture
214214
#guest.cpu.arch=
215215

216-
# This param will require CPU features on the CPU section.
217-
# The features listed in this property must be separated by a blank space (e.g.: vmx vme)
216+
# Specifies required CPU features for end-user and system VMs.
217+
# These features must be present on the host CPU for VM deployment.
218+
# Multiple features should be separated by whitespace (e.g.: vmx vme).
218219
#guest.cpu.features=
219220

220221
# Disables memory ballooning on VM guests for overcommit.

agent/src/main/java/com/cloud/agent/properties/AgentProperties.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -425,8 +425,9 @@ public class AgentProperties{
425425
public static final Property<String> GUEST_CPU_ARCH = new Property<>("guest.cpu.arch", null, String.class);
426426

427427
/**
428-
* This param will require CPU features on the CPU section.<br>
429-
* The features listed in this property must be separated by a blank space (see example below).<br>
428+
* Specifies required CPU features for end-user and system VMs.<br>
429+
* These features must be present on the host CPU for VM deployment.<br>
430+
* Multiple features should be separated by whitespace (see example below).<br>
430431
* Possible values: vmx vme <br>
431432
* Data type: String.<br>
432433
* Default value: <code>null</code>

engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -579,14 +579,19 @@ public VolumeInfo createVolumeFromSnapshot(Volume volume, Snapshot snapshot, Use
579579
VolumeInfo vol = volFactory.getVolume(volume.getId());
580580
long zoneId = volume.getDataCenterId();
581581
DataStore store = dataStoreMgr.getDataStore(pool.getId(), DataStoreRole.Primary);
582-
DataStoreRole dataStoreRole = snapshotHelper.getDataStoreRole(snapshot, zoneId);
582+
DataStoreRole dataStoreRole = snapshotHelper.getDataStoreRole(snapshot);
583583
SnapshotInfo snapInfo = snapshotFactory.getSnapshotWithRoleAndZone(snapshot.getId(), dataStoreRole, zoneId);
584+
boolean kvmSnapshotOnlyInPrimaryStorage = snapshotHelper.isKvmSnapshotOnlyInPrimaryStorage(snapshot, dataStoreRole);
585+
logger.debug("Creating volume from snapshot, with dataStore role {} and on primary storage: {}", dataStoreRole, kvmSnapshotOnlyInPrimaryStorage);
584586

585-
boolean kvmSnapshotOnlyInPrimaryStorage = snapshotHelper.isKvmSnapshotOnlyInPrimaryStorage(snapshot, dataStoreRole, volume.getDataCenterId());
586587
boolean storageSupportSnapshotToTemplateEnabled = snapshotHelper.isStorageSupportSnapshotToTemplate(snapInfo);
587-
588588
try {
589-
if (!storageSupportSnapshotToTemplateEnabled) {
589+
if (storageSupportSnapshotToTemplateEnabled) { // true only for StorPool now [TODO: Update to check storage supports snapshot to volume (DataStoreCapabilities.CAN_CREATE_VOLUME_FROM_SNAPSHOT) - may impact other storages, or StorPool storage type only]
590+
dataStoreRole = snapshotHelper.getDataStoreRole(snapshot, zoneId);
591+
snapInfo = snapshotFactory.getSnapshotWithRoleAndZone(snapshot.getId(), dataStoreRole, zoneId);
592+
kvmSnapshotOnlyInPrimaryStorage = snapshotHelper.isKvmSnapshotOnlyInPrimaryStorage(snapshot, dataStoreRole, zoneId);
593+
logger.debug("Creating volume from snapshot for storage supporting snapshot to template, with dataStore role {} and on primary storage: {}", dataStoreRole, kvmSnapshotOnlyInPrimaryStorage);
594+
} else {
590595
snapInfo = snapshotHelper.backupSnapshotToSecondaryStorageIfNotExists(snapInfo, dataStoreRole, snapshot, kvmSnapshotOnlyInPrimaryStorage);
591596
}
592597
} catch (CloudRuntimeException e) {
@@ -600,7 +605,7 @@ public VolumeInfo createVolumeFromSnapshot(Volume volume, Snapshot snapshot, Use
600605
}
601606

602607
// don't try to perform a sync if the DataStoreRole of the snapshot is equal to DataStoreRole.Primary
603-
if (!DataStoreRole.Primary.equals(dataStoreRole) || !storageSupportSnapshotToTemplateEnabled) {
608+
if (!DataStoreRole.Primary.equals(dataStoreRole) || (kvmSnapshotOnlyInPrimaryStorage && !storageSupportSnapshotToTemplateEnabled)) {
604609
try {
605610
// sync snapshot to region store if necessary
606611
DataStore snapStore = snapInfo.getDataStore();

engine/schema/src/main/java/com/cloud/dc/dao/ClusterDao.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public interface ClusterDao extends GenericDao<ClusterVO, Long> {
3434

3535
List<HypervisorType> getAvailableHypervisorInZone(Long zoneId);
3636

37-
List<Pair<HypervisorType, CPU.CPUArch>> listDistinctHypervisorsArchAcrossClusters(Long zoneId);
37+
List<Pair<HypervisorType, CPU.CPUArch>> listDistinctHypervisorsAndArchExcludingExternalType(Long zoneId);
3838

3939
List<ClusterVO> listByDcHyType(long dcId, String hyType);
4040

engine/schema/src/main/java/com/cloud/dc/dao/ClusterDaoImpl.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,16 +168,26 @@ public List<HypervisorType> getAvailableHypervisorInZone(Long zoneId) {
168168
.collect(Collectors.toList());
169169
}
170170

171+
/**
172+
* Returns distinct (HypervisorType, CPUArch) pairs from clusters in the given zone,
173+
* excluding clusters with {@link HypervisorType#External}.
174+
*
175+
* @param zoneId the zone ID to filter by, or {@code null} to include all zones
176+
* @return list of unique hypervisor type and CPU architecture pairs
177+
*/
171178
@Override
172-
public List<Pair<HypervisorType, CPU.CPUArch>> listDistinctHypervisorsArchAcrossClusters(Long zoneId) {
179+
public List<Pair<HypervisorType, CPU.CPUArch>> listDistinctHypervisorsAndArchExcludingExternalType(Long zoneId) {
173180
SearchBuilder<ClusterVO> sb = createSearchBuilder();
174181
sb.select(null, Func.DISTINCT_PAIR, sb.entity().getHypervisorType(), sb.entity().getArch());
175182
sb.and("zoneId", sb.entity().getDataCenterId(), SearchCriteria.Op.EQ);
183+
sb.and("hypervisorType", sb.entity().getHypervisorType(), SearchCriteria.Op.NEQ);
176184
sb.done();
177185
SearchCriteria<ClusterVO> sc = sb.create();
178186
if (zoneId != null) {
179187
sc.setParameters("zoneId", zoneId);
180188
}
189+
sc.setParameters("hypervisorType", HypervisorType.External);
190+
181191
final List<ClusterVO> clusters = search(sc, null);
182192
return clusters.stream()
183193
.map(c -> new Pair<>(c.getHypervisorType(), c.getArch()))

engine/schema/src/main/java/com/cloud/upgrade/SystemVmTemplateRegistration.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -917,7 +917,7 @@ protected void registerTemplatesForZone(long zoneId, String filePath) {
917917
String nfsVersion = getNfsVersion(storeUrlAndId.second());
918918
mountStore(storeUrlAndId.first(), filePath, nfsVersion);
919919
List<Pair<Hypervisor.HypervisorType, CPU.CPUArch>> hypervisorArchList =
920-
clusterDao.listDistinctHypervisorsArchAcrossClusters(zoneId);
920+
clusterDao.listDistinctHypervisorsAndArchExcludingExternalType(zoneId);
921921
for (Pair<Hypervisor.HypervisorType, CPU.CPUArch> hypervisorArch : hypervisorArchList) {
922922
Hypervisor.HypervisorType hypervisorType = hypervisorArch.first();
923923
MetadataTemplateDetails templateDetails = getMetadataTemplateDetails(hypervisorType,
@@ -1065,7 +1065,7 @@ public void updateSystemVmTemplates(final Connection conn) {
10651065
public void doInTransactionWithoutResult(final TransactionStatus status) {
10661066
List<Pair<Hypervisor.HypervisorType, CPU.CPUArch>> hypervisorsInUse;
10671067
try {
1068-
hypervisorsInUse = clusterDao.listDistinctHypervisorsArchAcrossClusters(null);
1068+
hypervisorsInUse = clusterDao.listDistinctHypervisorsAndArchExcludingExternalType(null);
10691069
} catch (final Exception e) {
10701070
throw new CloudRuntimeException("Exception while getting hypervisor types from clusters", e);
10711071
}

engine/schema/src/main/resources/META-INF/db/schema-42010to42100.sql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -754,3 +754,6 @@ SET `cs`.`domain_id` = (
754754
FROM `cloud`.`account` `acc`
755755
WHERE `acc`.`id` = `cs`.`account_id`
756756
);
757+
758+
-- Re-apply VPC: update default network offering for vpc tier to conserve_mode=1 (#8309)
759+
UPDATE `cloud`.`network_offerings` SET conserve_mode = 1 WHERE name = 'DefaultIsolatedNetworkOfferingForVpcNetworks';

engine/schema/src/test/java/com/cloud/dc/dao/ClusterDaoImplTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public void listDistinctHypervisorsArchAcrossClusters_WithZone() {
9292
when(cluster2.getArch()).thenReturn(CPU.CPUArch.arm64);
9393
List<ClusterVO> dummyHosts = Arrays.asList(cluster1, cluster2);
9494
doReturn(dummyHosts).when(clusterDao).search(any(SearchCriteria.class), isNull());
95-
List<Pair<Hypervisor.HypervisorType, CPU.CPUArch>> result = clusterDao.listDistinctHypervisorsArchAcrossClusters(zoneId);
95+
List<Pair<Hypervisor.HypervisorType, CPU.CPUArch>> result = clusterDao.listDistinctHypervisorsAndArchExcludingExternalType(zoneId);
9696
assertNotNull(result);
9797
assertEquals(2, result.size());
9898
assertEquals(Hypervisor.HypervisorType.XenServer, result.get(0).first());
@@ -109,7 +109,7 @@ public void listDistinctHypervisorsArchAcrossClusters_WithoutZone() {
109109
when(cluster.getArch()).thenReturn(CPU.CPUArch.amd64);
110110
List<ClusterVO> dummyHosts = Collections.singletonList(cluster);
111111
doReturn(dummyHosts).when(clusterDao).search(any(SearchCriteria.class), isNull());
112-
List<Pair<Hypervisor.HypervisorType, CPU.CPUArch>> result = clusterDao.listDistinctHypervisorsArchAcrossClusters(zoneId);
112+
List<Pair<Hypervisor.HypervisorType, CPU.CPUArch>> result = clusterDao.listDistinctHypervisorsAndArchExcludingExternalType(zoneId);
113113
assertNotNull(result);
114114
assertEquals(1, result.size());
115115
assertEquals(Hypervisor.HypervisorType.VMware, result.get(0).first());

engine/schema/src/test/java/com/cloud/upgrade/SystemVmTemplateRegistrationTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ public void testRegisterTemplatesForZone() {
404404
Hypervisor.HypervisorType hypervisorType = Hypervisor.HypervisorType.KVM;
405405
CPU.CPUArch arch = CPU.CPUArch.getDefault();
406406
hypervisorArchList.add(new Pair<>(hypervisorType, arch));
407-
doReturn(hypervisorArchList).when(clusterDao).listDistinctHypervisorsArchAcrossClusters(zoneId);
407+
doReturn(hypervisorArchList).when(clusterDao).listDistinctHypervisorsAndArchExcludingExternalType(zoneId);
408408
SystemVmTemplateRegistration.MetadataTemplateDetails details =
409409
Mockito.mock(SystemVmTemplateRegistration.MetadataTemplateDetails.class);
410410
String name = "existing";

engine/storage/snapshot/src/main/java/org/apache/cloudstack/storage/snapshot/SnapshotObject.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,10 +202,15 @@ public boolean isRevertable() {
202202
@Override
203203
public long getPhysicalSize() {
204204
long physicalSize = 0;
205-
SnapshotDataStoreVO snapshotStore = snapshotStoreDao.findByStoreSnapshot(DataStoreRole.Image, store.getId(), snapshot.getId());
206-
if (snapshotStore != null) {
207-
physicalSize = snapshotStore.getPhysicalSize();
205+
for (DataStoreRole role : List.of(DataStoreRole.Image, DataStoreRole.Primary)) {
206+
logger.trace("Retrieving snapshot [{}] size from {} storage.", snapshot.getUuid(), role);
207+
SnapshotDataStoreVO snapshotStore = snapshotStoreDao.findByStoreSnapshot(role, store.getId(), snapshot.getId());
208+
if (snapshotStore != null) {
209+
return snapshotStore.getPhysicalSize();
210+
}
211+
logger.trace("Snapshot [{}] size not found on {} storage.", snapshot.getUuid(), role);
208212
}
213+
logger.warn("Snapshot [{}] reference not found in any storage. There may be an inconsistency on the database.", snapshot.getUuid());
209214
return physicalSize;
210215
}
211216

0 commit comments

Comments
 (0)