Skip to content

Commit a5a7c5a

Browse files
committed
Merge remote-tracking branch 'apache/main' into 4.20-routed-mode-improvement
2 parents d826b49 + f7b7339 commit a5a7c5a

File tree

71 files changed

+1376
-332
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+1376
-332
lines changed

api/src/main/java/com/cloud/user/AccountService.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@ User createUser(String userName, String password, String firstName, String lastN
116116

117117
void checkAccess(Account account, AccessType accessType, boolean sameOwner, String apiName, ControlledEntity... entities) throws PermissionDeniedException;
118118

119+
void validateAccountHasAccessToResource(Account account, AccessType accessType, Object resource);
120+
119121
Long finalyzeAccountId(String accountName, Long domainId, Long projectId, boolean enabledOnly);
120122

121123
/**

api/src/main/java/org/apache/cloudstack/api/command/user/backup/ListBackupScheduleCmd.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public void execute() throws ResourceUnavailableException, InsufficientCapacityE
8282
List<BackupSchedule> schedules = backupManager.listBackupSchedule(getVmId());
8383
ListResponse<BackupScheduleResponse> response = new ListResponse<>();
8484
List<BackupScheduleResponse> scheduleResponses = new ArrayList<>();
85-
if (CollectionUtils.isNullOrEmpty(schedules)) {
85+
if (!CollectionUtils.isNullOrEmpty(schedules)) {
8686
for (BackupSchedule schedule : schedules) {
8787
scheduleResponses.add(_responseGenerator.createBackupScheduleResponse(schedule));
8888
}

debian/control

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Section: libs
33
Priority: extra
44
Maintainer: Wido den Hollander <[email protected]>
55
Build-Depends: debhelper (>= 9), openjdk-17-jdk | java17-sdk | java17-jdk | zulu-17 | openjdk-11-jdk | java11-sdk | java11-jdk | zulu-11, genisoimage,
6-
python-mysql.connector | python3-mysql.connector, maven (>= 3) | maven3,
6+
python-mysql.connector | python3-mysql.connector | mysql-connector-python-py3, maven (>= 3) | maven3,
77
python (>= 2.7) | python2 (>= 2.7), python3 (>= 3), python-setuptools, python3-setuptools,
88
nodejs (>= 12), lsb-release, dh-systemd | debhelper (>= 13)
99
Standards-Version: 3.8.1
@@ -17,14 +17,14 @@ Description: A common package which contains files which are shared by several C
1717

1818
Package: cloudstack-management
1919
Architecture: all
20-
Depends: ${python3:Depends}, openjdk-17-jre-headless | java17-runtime-headless | java17-runtime | zulu-17, cloudstack-common (= ${source:Version}), net-tools, sudo, python3-mysql.connector, augeas-tools, mysql-client | mariadb-client, adduser, bzip2, ipmitool, file, gawk, iproute2, qemu-utils, rng-tools, python3-dnspython, lsb-release, init-system-helpers (>= 1.14~), python3-setuptools
20+
Depends: ${python3:Depends}, openjdk-17-jre-headless | java17-runtime-headless | java17-runtime | zulu-17, cloudstack-common (= ${source:Version}), net-tools, sudo, python3-mysql.connector | mysql-connector-python-py3, augeas-tools, mysql-client | mariadb-client, adduser, bzip2, ipmitool, file, gawk, iproute2, qemu-utils, rng-tools, python3-dnspython, lsb-release, init-system-helpers (>= 1.14~), python3-setuptools
2121
Conflicts: cloud-server, cloud-client, cloud-client-ui
2222
Description: CloudStack server library
2323
The CloudStack management server
2424

2525
Package: cloudstack-agent
2626
Architecture: all
27-
Depends: ${python:Depends}, ${python3:Depends}, openjdk-17-jre-headless | java17-runtime-headless | java17-runtime | zulu-17, cloudstack-common (= ${source:Version}), lsb-base (>= 9), openssh-client, qemu-kvm (>= 2.5) | qemu-system-x86 (>= 5.2), libvirt-bin (>= 1.3) | libvirt-daemon-system (>= 3.0), iproute2, ebtables, vlan, ipset, python3-libvirt, ethtool, iptables, cryptsetup, rng-tools, rsync, lsb-release, ufw, apparmor, cpu-checker
27+
Depends: ${python:Depends}, ${python3:Depends}, openjdk-17-jre-headless | java17-runtime-headless | java17-runtime | zulu-17, cloudstack-common (= ${source:Version}), lsb-base (>= 9), openssh-client, qemu-kvm (>= 2.5) | qemu-system-x86 (>= 5.2), libvirt-bin (>= 1.3) | libvirt-daemon-system (>= 3.0), iproute2, ebtables, vlan, ipset, python3-libvirt, ethtool, iptables, cryptsetup, rng-tools, rsync, lsb-release, ufw, apparmor, cpu-checker, libvirt-daemon-driver-storage-rbd
2828
Recommends: init-system-helpers
2929
Conflicts: cloud-agent, cloud-agent-libs, cloud-agent-deps, cloud-agent-scripts
3030
Description: CloudStack agent

engine/schema/src/main/java/com/cloud/storage/dao/VolumeStatsDaoImpl.java

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -126,14 +126,7 @@ public void removeAllByTimestampLessThan(Date limitDate, long limitPerQuery) {
126126

127127
logger.debug(String.format("Starting to remove all volume_stats rows older than [%s].", limitDate));
128128

129-
long totalRemoved = 0;
130-
long removed;
131-
132-
do {
133-
removed = expunge(sc, limitPerQuery);
134-
totalRemoved += removed;
135-
logger.trace(String.format("Removed [%s] volume_stats rows on the last update and a sum of [%s] volume_stats rows older than [%s] until now.", removed, totalRemoved, limitDate));
136-
} while (limitPerQuery > 0 && removed >= limitPerQuery);
129+
long totalRemoved = batchExpunge(sc, limitPerQuery);
137130

138131
logger.info(String.format("Removed a total of [%s] volume_stats rows older than [%s].", totalRemoved, limitDate));
139132
}

engine/schema/src/main/java/com/cloud/vm/dao/VmStatsDaoImpl.java

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -123,14 +123,7 @@ public void removeAllByTimestampLessThan(Date limitDate, long limitPerQuery) {
123123

124124
logger.debug(String.format("Starting to remove all vm_stats rows older than [%s].", limitDate));
125125

126-
long totalRemoved = 0;
127-
long removed;
128-
129-
do {
130-
removed = expunge(sc, limitPerQuery);
131-
totalRemoved += removed;
132-
logger.trace(String.format("Removed [%s] vm_stats rows on the last update and a sum of [%s] vm_stats rows older than [%s] until now.", removed, totalRemoved, limitDate));
133-
} while (limitPerQuery > 0 && removed >= limitPerQuery);
126+
long totalRemoved = batchExpunge(sc, limitPerQuery);
134127

135128
logger.info(String.format("Removed a total of [%s] vm_stats rows older than [%s].", totalRemoved, limitDate));
136129
}

engine/storage/datamotion/src/main/java/org/apache/cloudstack/storage/motion/StorageSystemDataMotionStrategy.java

Lines changed: 44 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1958,25 +1958,26 @@ protected MigrationOptions createFullCloneMigrationOptions(VolumeInfo srcVolumeI
19581958
* - Full clones (no backing file): Take snapshot of the VM prior disk creation
19591959
* Return this information
19601960
*/
1961-
protected void setVolumeMigrationOptions(VolumeInfo srcVolumeInfo, VolumeInfo destVolumeInfo,
1962-
VirtualMachineTO vmTO, Host srcHost, StoragePoolVO destStoragePool) {
1963-
if (!destStoragePool.isManaged()) {
1964-
String srcVolumeBackingFile = getVolumeBackingFile(srcVolumeInfo);
1965-
1966-
String srcPoolUuid = srcVolumeInfo.getDataStore().getUuid();
1967-
StoragePoolVO srcPool = _storagePoolDao.findById(srcVolumeInfo.getPoolId());
1968-
Storage.StoragePoolType srcPoolType = srcPool.getPoolType();
1969-
1970-
MigrationOptions migrationOptions;
1971-
if (StringUtils.isNotBlank(srcVolumeBackingFile)) {
1972-
migrationOptions = createLinkedCloneMigrationOptions(srcVolumeInfo, destVolumeInfo,
1973-
srcVolumeBackingFile, srcPoolUuid, srcPoolType);
1974-
} else {
1975-
migrationOptions = createFullCloneMigrationOptions(srcVolumeInfo, vmTO, srcHost, srcPoolUuid, srcPoolType);
1976-
}
1977-
migrationOptions.setTimeout(StorageManager.KvmStorageOnlineMigrationWait.value());
1978-
destVolumeInfo.setMigrationOptions(migrationOptions);
1961+
protected void setVolumeMigrationOptions(VolumeInfo srcVolumeInfo, VolumeInfo destVolumeInfo, VirtualMachineTO vmTO, Host srcHost, StoragePoolVO destStoragePool,
1962+
MigrationOptions.Type migrationType) {
1963+
if (destStoragePool.isManaged()) {
1964+
return;
1965+
}
1966+
1967+
String srcVolumeBackingFile = getVolumeBackingFile(srcVolumeInfo);
1968+
1969+
String srcPoolUuid = srcVolumeInfo.getDataStore().getUuid();
1970+
StoragePoolVO srcPool = _storagePoolDao.findById(srcVolumeInfo.getPoolId());
1971+
Storage.StoragePoolType srcPoolType = srcPool.getPoolType();
1972+
1973+
MigrationOptions migrationOptions;
1974+
if (MigrationOptions.Type.LinkedClone.equals(migrationType)) {
1975+
migrationOptions = createLinkedCloneMigrationOptions(srcVolumeInfo, destVolumeInfo, srcVolumeBackingFile, srcPoolUuid, srcPoolType);
1976+
} else {
1977+
migrationOptions = createFullCloneMigrationOptions(srcVolumeInfo, vmTO, srcHost, srcPoolUuid, srcPoolType);
19791978
}
1979+
migrationOptions.setTimeout(StorageManager.KvmStorageOnlineMigrationWait.value());
1980+
destVolumeInfo.setMigrationOptions(migrationOptions);
19801981
}
19811982

19821983
/**
@@ -2007,6 +2008,7 @@ public void copyAsync(Map<VolumeInfo, DataStore> volumeDataStoreMap, VirtualMach
20072008
Map<VolumeInfo, VolumeInfo> srcVolumeInfoToDestVolumeInfo = new HashMap<>();
20082009

20092010
boolean managedStorageDestination = false;
2011+
boolean migrateNonSharedInc = false;
20102012
for (Map.Entry<VolumeInfo, DataStore> entry : volumeDataStoreMap.entrySet()) {
20112013
VolumeInfo srcVolumeInfo = entry.getKey();
20122014
DataStore destDataStore = entry.getValue();
@@ -2024,15 +2026,8 @@ public void copyAsync(Map<VolumeInfo, DataStore> volumeDataStoreMap, VirtualMach
20242026
continue;
20252027
}
20262028

2027-
VMTemplateVO vmTemplate = _vmTemplateDao.findById(vmInstance.getTemplateId());
2028-
if (srcVolumeInfo.getTemplateId() != null &&
2029-
Objects.nonNull(vmTemplate) &&
2030-
!Arrays.asList(KVM_VM_IMPORT_DEFAULT_TEMPLATE_NAME, VM_IMPORT_DEFAULT_TEMPLATE_NAME).contains(vmTemplate.getName())) {
2031-
logger.debug(String.format("Copying template [%s] of volume [%s] from source storage pool [%s] to target storage pool [%s].", srcVolumeInfo.getTemplateId(), srcVolumeInfo.getId(), sourceStoragePool.getId(), destStoragePool.getId()));
2032-
copyTemplateToTargetFilesystemStorageIfNeeded(srcVolumeInfo, sourceStoragePool, destDataStore, destStoragePool, destHost);
2033-
} else {
2034-
logger.debug(String.format("Skipping copy template from source storage pool [%s] to target storage pool [%s] before migration due to volume [%s] does not have a template.", sourceStoragePool.getId(), destStoragePool.getId(), srcVolumeInfo.getId()));
2035-
}
2029+
MigrationOptions.Type migrationType = decideMigrationTypeAndCopyTemplateIfNeeded(destHost, vmInstance, srcVolumeInfo, sourceStoragePool, destStoragePool, destDataStore);
2030+
migrateNonSharedInc = migrateNonSharedInc || MigrationOptions.Type.LinkedClone.equals(migrationType);
20362031

20372032
VolumeVO destVolume = duplicateVolumeOnAnotherStorage(srcVolume, destStoragePool);
20382033
VolumeInfo destVolumeInfo = _volumeDataFactory.getVolume(destVolume.getId(), destDataStore);
@@ -2044,7 +2039,7 @@ public void copyAsync(Map<VolumeInfo, DataStore> volumeDataStoreMap, VirtualMach
20442039
// move the volume from Ready to Migrating
20452040
destVolumeInfo.processEvent(Event.MigrationRequested);
20462041

2047-
setVolumeMigrationOptions(srcVolumeInfo, destVolumeInfo, vmTO, srcHost, destStoragePool);
2042+
setVolumeMigrationOptions(srcVolumeInfo, destVolumeInfo, vmTO, srcHost, destStoragePool, migrationType);
20482043

20492044
// create a volume on the destination storage
20502045
destDataStore.getDriver().createAsync(destDataStore, destVolumeInfo, null);
@@ -2059,7 +2054,7 @@ public void copyAsync(Map<VolumeInfo, DataStore> volumeDataStoreMap, VirtualMach
20592054

20602055
_volumeDao.update(destVolume.getId(), destVolume);
20612056

2062-
postVolumeCreationActions(srcVolumeInfo, destVolumeInfo, vmTO, srcHost);
2057+
postVolumeCreationActions(srcVolumeInfo, destVolumeInfo);
20632058

20642059
destVolumeInfo = _volumeDataFactory.getVolume(destVolume.getId(), destDataStore);
20652060

@@ -2083,8 +2078,8 @@ public void copyAsync(Map<VolumeInfo, DataStore> volumeDataStoreMap, VirtualMach
20832078
migrateDiskInfo = configureMigrateDiskInfo(srcVolumeInfo, destPath, backingPath);
20842079
migrateDiskInfo.setSourceDiskOnStorageFileSystem(isStoragePoolTypeOfFile(sourceStoragePool));
20852080
migrateDiskInfoList.add(migrateDiskInfo);
2086-
prepareDiskWithSecretConsumerDetail(vmTO, srcVolumeInfo, destVolumeInfo.getPath());
20872081
}
2082+
prepareDiskWithSecretConsumerDetail(vmTO, srcVolumeInfo, destVolumeInfo.getPath());
20882083

20892084
migrateStorage.put(srcVolumeInfo.getPath(), migrateDiskInfo);
20902085

@@ -2110,8 +2105,6 @@ public void copyAsync(Map<VolumeInfo, DataStore> volumeDataStoreMap, VirtualMach
21102105
VMInstanceVO vm = _vmDao.findById(vmTO.getId());
21112106
boolean isWindows = _guestOsCategoryDao.findById(_guestOsDao.findById(vm.getGuestOSId()).getCategoryId()).getName().equalsIgnoreCase("Windows");
21122107

2113-
boolean migrateNonSharedInc = isSourceAndDestinationPoolTypeOfNfs(volumeDataStoreMap);
2114-
21152108
MigrateCommand migrateCommand = new MigrateCommand(vmTO.getName(), destHost.getPrivateIpAddress(), isWindows, vmTO, true);
21162109
migrateCommand.setWait(StorageManager.KvmStorageOnlineMigrationWait.value());
21172110
migrateCommand.setMigrateStorage(migrateStorage);
@@ -2161,6 +2154,22 @@ public void copyAsync(Map<VolumeInfo, DataStore> volumeDataStoreMap, VirtualMach
21612154
}
21622155
}
21632156

2157+
private MigrationOptions.Type decideMigrationTypeAndCopyTemplateIfNeeded(Host destHost, VMInstanceVO vmInstance, VolumeInfo srcVolumeInfo, StoragePoolVO sourceStoragePool, StoragePoolVO destStoragePool, DataStore destDataStore) {
2158+
VMTemplateVO vmTemplate = _vmTemplateDao.findById(vmInstance.getTemplateId());
2159+
String srcVolumeBackingFile = getVolumeBackingFile(srcVolumeInfo);
2160+
if (StringUtils.isNotBlank(srcVolumeBackingFile) && supportStoragePoolType(destStoragePool.getPoolType(), StoragePoolType.Filesystem) &&
2161+
srcVolumeInfo.getTemplateId() != null &&
2162+
Objects.nonNull(vmTemplate) &&
2163+
!Arrays.asList(KVM_VM_IMPORT_DEFAULT_TEMPLATE_NAME, VM_IMPORT_DEFAULT_TEMPLATE_NAME).contains(vmTemplate.getName())) {
2164+
logger.debug(String.format("Copying template [%s] of volume [%s] from source storage pool [%s] to target storage pool [%s].", srcVolumeInfo.getTemplateId(), srcVolumeInfo.getId(), sourceStoragePool.getId(), destStoragePool.getId()));
2165+
copyTemplateToTargetFilesystemStorageIfNeeded(srcVolumeInfo, sourceStoragePool, destDataStore, destStoragePool, destHost);
2166+
return MigrationOptions.Type.LinkedClone;
2167+
}
2168+
logger.debug(String.format("Skipping copy template from source storage pool [%s] to target storage pool [%s] before migration due to volume [%s] does not have a " +
2169+
"template or we are doing full clone migration.", sourceStoragePool.getId(), destStoragePool.getId(), srcVolumeInfo.getId()));
2170+
return MigrationOptions.Type.FullClone;
2171+
}
2172+
21642173
protected String formatMigrationElementsAsJsonToDisplayOnLog(String objectName, Object object, Object from, Object to){
21652174
return String.format("{%s: \"%s\", from: \"%s\", to:\"%s\"}", objectName, object, from, to);
21662175
}
@@ -2422,7 +2431,7 @@ protected void updateCopiedTemplateReference(VolumeInfo srcVolumeInfo, VolumeInf
24222431
/**
24232432
* Handle post destination volume creation actions depending on the migrating volume type: full clone or linked clone
24242433
*/
2425-
protected void postVolumeCreationActions(VolumeInfo srcVolumeInfo, VolumeInfo destVolumeInfo, VirtualMachineTO vmTO, Host srcHost) {
2434+
protected void postVolumeCreationActions(VolumeInfo srcVolumeInfo, VolumeInfo destVolumeInfo) {
24262435
MigrationOptions migrationOptions = destVolumeInfo.getMigrationOptions();
24272436
if (migrationOptions != null) {
24282437
if (migrationOptions.getType() == MigrationOptions.Type.LinkedClone && migrationOptions.isCopySrcTemplate()) {
@@ -2470,7 +2479,8 @@ protected void verifyLiveMigrationForKVM(Map<VolumeInfo, DataStore> volumeDataSt
24702479
throw new CloudRuntimeException("Destination storage pool with ID " + dataStore.getId() + " was not located.");
24712480
}
24722481

2473-
if (srcStoragePoolVO.isManaged() && srcStoragePoolVO.getId() != destStoragePoolVO.getId()) {
2482+
boolean isSrcAndDestPoolPowerFlexStorage = srcStoragePoolVO.getPoolType().equals(Storage.StoragePoolType.PowerFlex) && destStoragePoolVO.getPoolType().equals(Storage.StoragePoolType.PowerFlex);
2483+
if (srcStoragePoolVO.isManaged() && !isSrcAndDestPoolPowerFlexStorage && srcStoragePoolVO.getId() != destStoragePoolVO.getId()) {
24742484
throw new CloudRuntimeException("Migrating a volume online with KVM from managed storage is not currently supported.");
24752485
}
24762486

framework/cluster/src/main/java/com/cloud/cluster/ClusterManagerImpl.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ private void onSendingClusterPdu() {
294294
}
295295
}
296296
} catch (final Throwable e) {
297-
logger.error("Unexcpeted exception: ", e);
297+
logger.error("Unexpected exception: ", e);
298298
}
299299
}
300300
}
@@ -346,7 +346,7 @@ protected void runInContext() {
346346
}
347347
});
348348
} catch (final Throwable e) {
349-
logger.error("Unexcpeted exception: ", e);
349+
logger.error("Unexpected exception: ", e);
350350
}
351351
}
352352
}
@@ -384,7 +384,7 @@ public void broadcast(final long agentId, final String cmds) {
384384
}
385385
executeAsync(peerName, agentId, cmds, true);
386386
} catch (final Exception e) {
387-
logger.warn("Caught exception while talkign to " + peer.getMsid());
387+
logger.warn("Caught exception while talking to " + peer.getMsid());
388388
}
389389
}
390390
}

framework/db/src/main/java/com/cloud/utils/db/GenericDao.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -247,14 +247,6 @@ public interface GenericDao<T, ID extends Serializable> {
247247

248248
int expungeList(List<ID> ids);
249249

250-
/**
251-
* Delete the entity beans specified by the search criteria with a given limit
252-
* @param sc Search criteria
253-
* @param limit Maximum number of rows that will be affected
254-
* @return Number of rows deleted
255-
*/
256-
int expunge(SearchCriteria<T> sc, long limit);
257-
258250
/**
259251
* expunge the removed rows.
260252
*/

0 commit comments

Comments
 (0)