Skip to content

Commit f418cd8

Browse files
authored
Merge branch '4.22' into forwarded-ip-accesslog
2 parents 7c48df3 + b8ed34e commit f418cd8

File tree

78 files changed

+852
-333
lines changed

Some content is hidden

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

78 files changed

+852
-333
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ public interface VmDetailConstants {
5555
String NIC_MULTIQUEUE_NUMBER = "nic.multiqueue.number";
5656
String NIC_PACKED_VIRTQUEUES_ENABLED = "nic.packed.virtqueues.enabled";
5757

58+
// KVM specific, disk controllers
59+
String KVM_SKIP_FORCE_DISK_CONTROLLER = "skip.force.disk.controller";
60+
5861
// Mac OSX guest specific (internal)
5962
String SMC_PRESENT = "smc.present";
6063
String FIRMWARE = "firmware";

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import org.apache.cloudstack.api.BaseCmd;
2727
import org.apache.cloudstack.api.Parameter;
2828
import org.apache.cloudstack.api.ServerApiException;
29-
import org.apache.cloudstack.api.response.BackupResponse;
3029
import org.apache.cloudstack.api.response.BackupScheduleResponse;
3130
import org.apache.cloudstack.api.response.UserVmResponse;
3231
import org.apache.cloudstack.backup.BackupManager;
@@ -38,7 +37,7 @@
3837

3938
@APICommand(name = "createBackupSchedule",
4039
description = "Creates a User-defined Instance backup schedule",
41-
responseObject = BackupResponse.class, since = "4.14.0",
40+
responseObject = BackupScheduleResponse.class, since = "4.14.0",
4241
authorized = {RoleType.Admin, RoleType.ResourceAdmin, RoleType.DomainAdmin, RoleType.User})
4342
public class CreateBackupScheduleCmd extends BaseCmd {
4443

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
package org.apache.cloudstack.api.command.user.backup.repository;
1919

20+
import com.cloud.utils.StringUtils;
2021
import org.apache.cloudstack.acl.RoleType;
2122
import org.apache.cloudstack.api.APICommand;
2223
import org.apache.cloudstack.api.ApiConstants;
@@ -100,7 +101,7 @@ public String getProvider() {
100101
}
101102

102103
public String getMountOptions() {
103-
return mountOptions == null ? "" : mountOptions;
104+
return StringUtils.isBlank(mountOptions) ? "" : mountOptions;
104105
}
105106

106107
public Long getZoneId() {

api/src/main/java/org/apache/cloudstack/api/response/BackupRepositoryResponse.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ public class BackupRepositoryResponse extends BaseResponse {
5757
@Param(description = "backup type")
5858
private String type;
5959

60+
@SerializedName(ApiConstants.MOUNT_OPTIONS)
61+
@Param(description = "mount options", since = "4.22.1")
62+
private String mountOptions;
63+
6064
@SerializedName(ApiConstants.CAPACITY_BYTES)
6165
@Param(description = "capacity of the backup repository")
6266
private Long capacityBytes;
@@ -128,6 +132,14 @@ public void setType(String type) {
128132
this.type = type;
129133
}
130134

135+
public String getMountOptions() {
136+
return mountOptions;
137+
}
138+
139+
public void setMountOptions(String mountOptions) {
140+
this.mountOptions = mountOptions;
141+
}
142+
131143
public Long getCapacityBytes() {
132144
return capacityBytes;
133145
}

api/src/main/java/org/apache/cloudstack/backup/BackupRepositoryService.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,4 @@ public interface BackupRepositoryService {
3232
BackupRepository updateBackupRepository(UpdateBackupRepositoryCmd cmd);
3333
boolean deleteBackupRepository(DeleteBackupRepositoryCmd cmd);
3434
Pair<List<BackupRepository>, Integer> listBackupRepositories(ListBackupRepositoriesCmd cmd);
35-
3635
}

core/src/main/java/com/cloud/storage/template/HttpTemplateDownloader.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ private void checkCredentials(String user, String password) {
151151
client.getParams().setAuthenticationPreemptive(true);
152152
Credentials defaultcreds = new UsernamePasswordCredentials(user, password);
153153
client.getState().setCredentials(new AuthScope(hostAndPort.first(), hostAndPort.second(), AuthScope.ANY_REALM), defaultcreds);
154-
logger.info("Added username=" + user + ", password=" + password + "for host " + hostAndPort.first() + ":" + hostAndPort.second());
154+
logger.info("Added username={}, password=****** for host {}:{}", user, hostAndPort.first(), hostAndPort.second());
155155
} else {
156156
logger.info("No credentials configured for host=" + hostAndPort.first() + ":" + hostAndPort.second());
157157
}

engine/api/src/main/java/org/apache/cloudstack/engine/subsystem/api/storage/ObjectInDataStoreStateMachine.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ enum State {
3535
Failed("Failed to download Template"),
3636
Hidden("The object is hidden from the user");
3737

38-
String _description;
38+
final String _description;
3939

40-
private State(String description) {
40+
State(String description) {
4141
_description = description;
4242
}
4343

@@ -50,7 +50,7 @@ enum Event {
5050
CreateRequested,
5151
CreateOnlyRequested,
5252
DestroyRequested,
53-
OperationSuccessed,
53+
OperationSucceeded,
5454
OperationFailed,
5555
CopyRequested,
5656
CopyingRequested,

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

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3053,7 +3053,7 @@ private void orchestrateMigrate(final String vmUuid, final long srcHostId, final
30533053
}
30543054

30553055
protected void migrate(final VMInstanceVO vm, final long srcHostId, final DeployDestination dest) throws ResourceUnavailableException, ConcurrentOperationException {
3056-
logger.info("Migrating {} to {}", vm, dest);
3056+
logger.info("Start preparing migration of the VM: {} to {}", vm, dest);
30573057
final long dstHostId = dest.getHost().getId();
30583058
final Host fromHost = _hostDao.findById(srcHostId);
30593059
if (fromHost == null) {
@@ -3118,9 +3118,11 @@ protected void migrate(final VMInstanceVO vm, final long srcHostId, final Deploy
31183118
if (pfma == null || !pfma.getResult()) {
31193119
final String details = pfma != null ? pfma.getDetails() : "null answer returned";
31203120
final String msg = "Unable to prepare for migration due to " + details;
3121+
logger.error("Failed to prepare destination host {} for migration of VM {} : {}", dstHostId, vm.getInstanceName(), details);
31213122
pfma = null;
31223123
throw new AgentUnavailableException(msg, dstHostId);
31233124
}
3125+
logger.debug("Successfully prepared destination host {} for migration of VM {} ", dstHostId, vm.getInstanceName());
31243126
} catch (final OperationTimedoutException e1) {
31253127
throw new AgentUnavailableException("Operation timed out", dstHostId);
31263128
} finally {
@@ -3141,18 +3143,23 @@ protected void migrate(final VMInstanceVO vm, final long srcHostId, final Deploy
31413143
volumeMgr.release(vm.getId(), dstHostId);
31423144
}
31433145

3144-
logger.info("Migration cancelled because state has changed: {}", vm);
3145-
throw new ConcurrentOperationException("Migration cancelled because state has changed: " + vm);
3146+
String msg = "Migration cancelled because state has changed: " + vm;
3147+
logger.warn(msg);
3148+
throw new ConcurrentOperationException(msg);
31463149
}
31473150
} catch (final NoTransitionException e1) {
31483151
_networkMgr.rollbackNicForMigration(vmSrc, profile);
31493152
volumeMgr.release(vm.getId(), dstHostId);
3150-
logger.info("Migration cancelled because {}", e1.getMessage());
3153+
String msg = String.format("Migration cancelled for VM %s due to state transition failure: %s",
3154+
vm.getInstanceName(), e1.getMessage());
3155+
logger.warn(msg, e1);
31513156
throw new ConcurrentOperationException("Migration cancelled because " + e1.getMessage());
31523157
} catch (final CloudRuntimeException e2) {
31533158
_networkMgr.rollbackNicForMigration(vmSrc, profile);
31543159
volumeMgr.release(vm.getId(), dstHostId);
3155-
logger.info("Migration cancelled because {}", e2.getMessage());
3160+
String msg = String.format("Migration cancelled for VM %s due to runtime exception: %s",
3161+
vm.getInstanceName(), e2.getMessage());
3162+
logger.error(msg, e2);
31563163
work.setStep(Step.Done);
31573164
_workDao.update(work.getId(), work);
31583165
try {
@@ -3172,8 +3179,12 @@ protected void migrate(final VMInstanceVO vm, final long srcHostId, final Deploy
31723179
final Answer ma = _agentMgr.send(vm.getLastHostId(), mc);
31733180
if (ma == null || !ma.getResult()) {
31743181
final String details = ma != null ? ma.getDetails() : "null answer returned";
3182+
String msg = String.format("Migration command failed for VM %s on source host id=%s to destination host %s: %s",
3183+
vm.getInstanceName(), vm.getLastHostId(), dstHostId, details);
3184+
logger.error(msg);
31753185
throw new CloudRuntimeException(details);
31763186
}
3187+
logger.info("Migration command successful for VM {}", vm.getInstanceName());
31773188
} catch (final OperationTimedoutException e) {
31783189
boolean success = false;
31793190
if (HypervisorType.KVM.equals(vm.getHypervisorType())) {
@@ -3210,7 +3221,7 @@ protected void migrate(final VMInstanceVO vm, final long srcHostId, final Deploy
32103221

32113222
try {
32123223
if (!checkVmOnHost(vm, dstHostId)) {
3213-
logger.error("Unable to complete migration for {}", vm);
3224+
logger.error("Migration verification failed for VM {} : VM not found on destination host {} ", vm.getInstanceName(), dstHostId);
32143225
try {
32153226
_agentMgr.send(srcHostId, new Commands(cleanup(vm, dpdkInterfaceMapping)), null);
32163227
} catch (final AgentUnavailableException e) {
@@ -3225,7 +3236,7 @@ protected void migrate(final VMInstanceVO vm, final long srcHostId, final Deploy
32253236
migrated = true;
32263237
} finally {
32273238
if (!migrated) {
3228-
logger.info("Migration was unsuccessful. Cleaning up: {}", vm);
3239+
logger.info("Migration was unsuccessful. Cleaning up: {}", vm);
32293240
_networkMgr.rollbackNicForMigration(vmSrc, profile);
32303241
volumeMgr.release(vm.getId(), dstHostId);
32313242
// deallocate GPU devices for the VM on the destination host
@@ -3237,7 +3248,7 @@ protected void migrate(final VMInstanceVO vm, final long srcHostId, final Deploy
32373248
try {
32383249
_agentMgr.send(dstHostId, new Commands(cleanup(vm, dpdkInterfaceMapping)), null);
32393250
} catch (final AgentUnavailableException ae) {
3240-
logger.warn("Looks like the destination Host is unavailable for cleanup", ae);
3251+
logger.warn("Destination host {} unavailable for cleanup after failed migration of VM {}", dstHostId, vm.getInstanceName(), ae);
32413252
}
32423253
_networkMgr.setHypervisorHostname(profile, dest, false);
32433254
try {
@@ -3246,6 +3257,7 @@ protected void migrate(final VMInstanceVO vm, final long srcHostId, final Deploy
32463257
logger.warn(e.getMessage());
32473258
}
32483259
} else {
3260+
logger.info("Migration completed successfully for VM %s" + vm);
32493261
_networkMgr.commitNicForMigration(vmSrc, profile);
32503262
volumeMgr.release(vm.getId(), srcHostId);
32513263
// deallocate GPU devices for the VM on the src host after migration is complete
@@ -3276,6 +3288,7 @@ protected MigrateCommand buildMigrateCommand(VMInstanceVO vmInstance, VirtualMac
32763288
migrateCommand.setVlanToPersistenceMap(vlanToPersistenceMap);
32773289
}
32783290

3291+
logger.debug("Setting auto convergence to: {}", StorageManager.KvmAutoConvergence.value());
32793292
migrateCommand.setAutoConvergence(StorageManager.KvmAutoConvergence.value());
32803293
migrateCommand.setHostGuid(destination.getHost().getGuid());
32813294

engine/schema/src/main/java/com/cloud/capacity/dao/CapacityDaoImpl.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,8 @@ public class CapacityDaoImpl extends GenericDaoBase<CapacityVO, Long> implements
213213

214214
private static final String LEFT_JOIN_VM_TEMPLATE = "LEFT JOIN vm_template ON vm_template.id = vi.vm_template_id ";
215215

216+
private static final String STORAGE_POOLS_WITH_CHILDREN = "SELECT DISTINCT parent FROM storage_pool WHERE parent != 0 AND removed IS NULL";
217+
216218
public CapacityDaoImpl() {
217219
_hostIdTypeSearch = createSearchBuilder();
218220
_hostIdTypeSearch.and("hostId", _hostIdTypeSearch.entity().getHostOrPoolId(), SearchCriteria.Op.EQ);
@@ -379,6 +381,11 @@ public List<SummedCapacity> listCapacitiesGroupedByLevelAndType(Integer capacity
379381
finalQuery.append(" AND capacity_type = ?");
380382
resourceIdList.add(capacityType.longValue());
381383
}
384+
385+
// Exclude storage pools with children from capacity calculations to avoid double counting
386+
finalQuery.append(" AND NOT (capacity.capacity_type = ").append(Capacity.CAPACITY_TYPE_STORAGE_ALLOCATED)
387+
.append(" AND capacity.host_id IN (").append(STORAGE_POOLS_WITH_CHILDREN).append("))");
388+
382389
if (CollectionUtils.isNotEmpty(hostIds)) {
383390
finalQuery.append(String.format(" AND capacity.host_id IN (%s)", StringUtils.join(hostIds, ",")));
384391
if (capacityType == null) {
@@ -541,6 +548,10 @@ public List<SummedCapacity> findFilteredCapacityBy(Integer capacityType, Long zo
541548
StringBuilder sql = new StringBuilder(LIST_CAPACITY_GROUP_BY_CAPACITY_PART1);
542549
List<Long> resourceIdList = new ArrayList<Long>();
543550

551+
// Exclude storage pools with children from capacity calculations to avoid double counting
552+
sql.append(" AND NOT (capacity.capacity_type = ").append(Capacity.CAPACITY_TYPE_STORAGE_ALLOCATED)
553+
.append(" AND capacity.host_id IN (").append(STORAGE_POOLS_WITH_CHILDREN).append("))");
554+
544555
if (zoneId != null) {
545556
sql.append(" AND capacity.data_center_id = ?");
546557
resourceIdList.add(zoneId);

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,5 +163,7 @@ public interface VolumeDao extends GenericDao<VolumeVO, Long>, StateDao<Volume.S
163163

164164
VolumeVO findOneByIScsiName(String iScsiName);
165165

166+
int getVolumeCountByOfferingId(long diskOfferingId);
167+
166168
VolumeVO findByLastIdAndState(long lastVolumeId, Volume.State...states);
167169
}

0 commit comments

Comments
 (0)