Skip to content

Commit 7c7b840

Browse files
authored
Merge branch 'apache:main' into main
2 parents a4d9c18 + a1a3aff commit 7c7b840

File tree

44 files changed

+858
-362
lines changed

Some content is hidden

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

44 files changed

+858
-362
lines changed

agent/conf/agent.properties

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,5 +271,11 @@ iscsi.session.cleanup.enabled=false
271271
# Depending on the use case, this timeout might need increasing/decreasing.
272272
# heartbeat.update.timeout=60000
273273

274+
# This parameter specifies the timeout in seconds to retrieve the target's domain id when migrating a VM with KVM.
275+
# vm.migrate.domain.retrieve.timeout=10
276+
277+
# This parameter specifies if the host must be rebooted when something goes wrong with the heartbeat.
278+
# reboot.host.and.alert.management.on.heartbeat.timeout=true
279+
274280
# Enable manually setting CPU's topology on KVM's VM.
275281
# enable.manually.setting.cpu.topology.on.kvm.vm=true

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

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,24 @@ public class AgentProperties{
2929
* Heartbeat update timeout. <br>
3030
* Data type: int. <br>
3131
* Default value: 60000 (ms).
32-
*/
32+
*/
3333
public static final Property<Integer> HEARTBEAT_UPDATE_TIMEOUT = new Property<Integer>("heartbeat.update.timeout", 60000);
3434

35+
/**
36+
* The timeout in seconds to retrieve the target's domain id when migrating a VM with KVM. <br>
37+
* Data type: int. <br>
38+
* Default value: 10 (sec).
39+
*/
40+
public static final Property<Integer> VM_MIGRATE_DOMAIN_RETRIEVE_TIMEOUT = new Property<Integer>("vm.migrate.domain.retrieve.timeout", 10);
41+
42+
/**
43+
* Reboot host and alert management on heartbeat timeout. <br>
44+
* Data type: boolean.<br>
45+
* Default value: true.
46+
*/
47+
public static final Property<Boolean> REBOOT_HOST_AND_ALERT_MANAGEMENT_ON_HEARTBEAT_TIMEOUT
48+
= new Property<Boolean>("reboot.host.and.alert.management.on.heartbeat.timeout", true);
49+
3550
/**
3651
* Enable manually setting CPU's topology on KVM's VM. <br>
3752
* Data type: boolean.<br>

api/src/main/java/com/cloud/vm/VmDetailConstants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public interface VmDetailConstants {
2929
String DATA_DISK_CONTROLLER = "dataDiskController";
3030
String SVGA_VRAM_SIZE = "svga.vramSize";
3131
String NESTED_VIRTUALIZATION_FLAG = "nestedVirtualizationFlag";
32+
String RAM_RESERVATION = "ramReservation";
3233

3334
// XenServer specific (internal)
3435
String HYPERVISOR_TOOLS_VERSION = "hypervisortoolsversion";

api/src/main/java/org/apache/cloudstack/api/command/admin/host/AddHostCmd.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,10 @@ public class AddHostCmd extends BaseCmd {
5454
@Parameter(name = ApiConstants.CLUSTER_NAME, type = CommandType.STRING, description = "the cluster name for the host")
5555
private String clusterName;
5656

57-
@Parameter(name = ApiConstants.PASSWORD, type = CommandType.STRING, required = true, description = "the password for the host")
57+
@Parameter(name = ApiConstants.USERNAME, type = CommandType.STRING, description = "the username for the host; required to be passed for hypervisors other than VMWare")
58+
private String username;
59+
60+
@Parameter(name = ApiConstants.PASSWORD, type = CommandType.STRING, description = "the password for the host; required to be passed for hypervisors other than VMWare")
5861
private String password;
5962

6063
@Parameter(name = ApiConstants.POD_ID, type = CommandType.UUID, entityType = PodResponse.class, required = true, description = "the Pod ID for the host")
@@ -63,9 +66,6 @@ public class AddHostCmd extends BaseCmd {
6366
@Parameter(name = ApiConstants.URL, type = CommandType.STRING, required = true, description = "the host URL")
6467
private String url;
6568

66-
@Parameter(name = ApiConstants.USERNAME, type = CommandType.STRING, required = true, description = "the username for the host")
67-
private String username;
68-
6969
@Parameter(name = ApiConstants.ZONE_ID, type = CommandType.UUID, entityType = ZoneResponse.class, required = true, description = "the Zone ID for the host")
7070
private Long zoneId;
7171

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

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@
119119
import com.cloud.storage.Snapshot;
120120
import com.cloud.storage.Storage;
121121
import com.cloud.storage.Storage.ImageFormat;
122+
import com.cloud.storage.Storage.StoragePoolType;
122123
import com.cloud.storage.StorageManager;
123124
import com.cloud.storage.StoragePool;
124125
import com.cloud.storage.VMTemplateStorageResourceAssoc;
@@ -131,6 +132,7 @@
131132
import com.cloud.storage.dao.VMTemplateDetailsDao;
132133
import com.cloud.storage.dao.VolumeDao;
133134
import com.cloud.storage.dao.VolumeDetailsDao;
135+
import com.cloud.storage.snapshot.SnapshotManager;
134136
import com.cloud.template.TemplateManager;
135137
import com.cloud.template.VirtualMachineTemplate;
136138
import com.cloud.user.Account;
@@ -491,18 +493,11 @@ public VolumeInfo createVolumeFromSnapshot(Volume volume, Snapshot snapshot, Use
491493
if (snapInfo == null) {
492494
throw new CloudRuntimeException("Cannot find snapshot " + snapshot.getId());
493495
}
494-
// We need to copy the snapshot onto secondary.
495-
SnapshotStrategy snapshotStrategy = _storageStrategyFactory.getSnapshotStrategy(snapshot, SnapshotOperation.BACKUP);
496-
snapshotStrategy.backupSnapshot(snapInfo);
497496

498-
// Attempt to grab it again.
499-
snapInfo = snapshotFactory.getSnapshot(snapshot.getId(), dataStoreRole);
500-
if (snapInfo == null) {
501-
throw new CloudRuntimeException("Cannot find snapshot " + snapshot.getId() + " on secondary and could not create backup");
502-
}
497+
snapInfo = backupSnapshotIfNeeded(snapshot, dataStoreRole, snapInfo);
503498
}
504499
// don't try to perform a sync if the DataStoreRole of the snapshot is equal to DataStoreRole.Primary
505-
if (!DataStoreRole.Primary.equals(dataStoreRole)) {
500+
if (!DataStoreRole.Primary.equals(snapInfo.getDataStore().getRole())) {
506501
try {
507502
// sync snapshot to region store if necessary
508503
DataStore snapStore = snapInfo.getDataStore();
@@ -534,6 +529,25 @@ public VolumeInfo createVolumeFromSnapshot(Volume volume, Snapshot snapshot, Use
534529

535530
}
536531

532+
private SnapshotInfo backupSnapshotIfNeeded(Snapshot snapshot, DataStoreRole dataStoreRole, SnapshotInfo snapInfo) {
533+
boolean backupSnapToSecondary = SnapshotManager.BackupSnapshotAfterTakingSnapshot.value() == null || SnapshotManager.BackupSnapshotAfterTakingSnapshot.value();
534+
535+
StoragePoolVO srcPool = _storagePoolDao.findById(snapInfo.getBaseVolume().getPoolId());
536+
// We need to copy the snapshot onto secondary.
537+
//Skipping the backup to secondary storage with NFS/FS could be supported when CLOUDSTACK-5297 is accepted with small enhancement in:
538+
//KVMStorageProcessor::createVolumeFromSnapshot and CloudStackPrimaryDataStoreDriverImpl::copyAsync/createAsync
539+
if ((!backupSnapToSecondary && (StoragePoolType.NetworkFilesystem.equals(srcPool.getPoolType()) || StoragePoolType.Filesystem.equals(srcPool.getPoolType())))) {
540+
SnapshotStrategy snapshotStrategy = _storageStrategyFactory.getSnapshotStrategy(snapshot, SnapshotOperation.BACKUP);
541+
snapshotStrategy.backupSnapshot(snapInfo);
542+
// Attempt to grab it again.
543+
snapInfo = snapshotFactory.getSnapshot(snapshot.getId(), dataStoreRole);
544+
if (snapInfo == null) {
545+
throw new CloudRuntimeException("Cannot find snapshot " + snapshot.getId() + " on secondary and could not create backup");
546+
}
547+
}
548+
return snapInfo;
549+
}
550+
537551
public DataStoreRole getDataStoreRole(Snapshot snapshot) {
538552
SnapshotDataStoreVO snapshotStore = _snapshotDataStoreDao.findBySnapshot(snapshot.getId(), DataStoreRole.Primary);
539553

engine/schema/src/main/java/com/cloud/host/dao/HostDao.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ public interface HostDao extends GenericDao<HostVO, Long>, StateDao<Status, Stat
7575

7676
List<HostVO> findHypervisorHostInCluster(long clusterId);
7777

78+
HostVO findOldestExistentHypervisorHostInCluster(long clusterId);
79+
7880
List<HostVO> listAllUpAndEnabledNonHAHosts(Type type, Long clusterId, Long podId, long dcId, String haTag);
7981

8082
List<HostVO> findByDataCenterId(Long zoneId);

engine/schema/src/main/java/com/cloud/host/dao/HostDaoImpl.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1168,6 +1168,23 @@ public List<HostVO> findHypervisorHostInCluster(long clusterId) {
11681168
return listBy(sc);
11691169
}
11701170

1171+
@Override
1172+
public HostVO findOldestExistentHypervisorHostInCluster(long clusterId) {
1173+
SearchCriteria<HostVO> sc = TypeClusterStatusSearch.create();
1174+
sc.setParameters("type", Host.Type.Routing);
1175+
sc.setParameters("cluster", clusterId);
1176+
sc.setParameters("status", Status.Up);
1177+
sc.setParameters("resourceState", ResourceState.Enabled);
1178+
Filter orderByFilter = new Filter(HostVO.class, "created", true, null, null);
1179+
1180+
List<HostVO> hosts = search(sc, orderByFilter, null, false);
1181+
if (hosts != null && hosts.size() > 0) {
1182+
return hosts.get(0);
1183+
}
1184+
1185+
return null;
1186+
}
1187+
11711188
@Override
11721189
public List<Long> listAllHosts(long zoneId) {
11731190
SearchCriteria<Long> sc = HostIdSearch.create();

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ public DatabaseUpgradeChecker() {
199199
.next("4.14.1.0", new Upgrade41400to41500())
200200
.next("4.15.0.0", new Upgrade41500to41510())
201201
.next("4.15.1.0", new Upgrade41510to41600())
202+
.next("4.15.2.0", new Upgrade41510to41600())
202203
.build();
203204
}
204205

engine/schema/src/main/java/org/apache/cloudstack/storage/datastore/db/SnapshotDataStoreDao.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ public interface SnapshotDataStoreDao extends GenericDao<SnapshotDataStoreVO, Lo
6868

6969
SnapshotDataStoreVO findByVolume(long volumeId, DataStoreRole role);
7070

71+
SnapshotDataStoreVO findByVolume(long snapshotId, long volumeId, DataStoreRole role);
72+
7173
/**
7274
* List all snapshots in 'snapshot_store_ref' by volume and data store role. Therefore, it is possible to list all snapshots that are in the primary storage or in the secondary storage.
7375
*/

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public SnapshotInfo getSnapshot(long snapshotId, DataStoreRole role) {
9292
}
9393
SnapshotDataStoreVO snapshotStore = snapshotStoreDao.findBySnapshot(snapshotId, role);
9494
if (snapshotStore == null) {
95-
snapshotStore = snapshotStoreDao.findByVolume(snapshot.getVolumeId(), role);
95+
snapshotStore = snapshotStoreDao.findByVolume(snapshotId, snapshot.getVolumeId(), role);
9696
if (snapshotStore == null) {
9797
return null;
9898
}

0 commit comments

Comments
 (0)