Skip to content

Commit ada750e

Browse files
committed
Merge branch '4.20'
2 parents 96ccd7e + 0cbebbd commit ada750e

File tree

27 files changed

+409
-111
lines changed

27 files changed

+409
-111
lines changed

engine/orchestration/src/main/java/com/cloud/agent/manager/AgentManagerImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1710,7 +1710,7 @@ protected void processRequest(final Link link, final Request request) {
17101710
}
17111711
}
17121712
} catch (final Throwable th) {
1713-
logger.warn("Caught: ", th);
1713+
logger.error("Caught: ", th);
17141714
answer = new Answer(cmd, false, th.getMessage());
17151715
}
17161716
answers[i] = answer;
@@ -1725,7 +1725,7 @@ protected void processRequest(final Link link, final Request request) {
17251725
try {
17261726
link.send(response.toBytes());
17271727
} catch (final ClosedChannelException e) {
1728-
logger.warn("Unable to send response because connection is closed: {}", response);
1728+
logger.error("Unable to send response because connection is closed: {}", response);
17291729
}
17301730
}
17311731

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

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@
184184
import com.cloud.vm.dao.UserVmCloneSettingDao;
185185
import com.cloud.vm.dao.UserVmDao;
186186
import com.cloud.vm.dao.VMInstanceDetailsDao;
187+
import com.cloud.vm.dao.VMInstanceDao;
187188

188189
public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrationService, Configurable {
189190

@@ -270,6 +271,8 @@ public enum UserVmCloneType {
270271
ConfigDepot configDepot;
271272
@Inject
272273
ConfigurationDao configurationDao;
274+
@Inject
275+
VMInstanceDao vmInstanceDao;
273276

274277
@Inject
275278
protected SnapshotHelper snapshotHelper;
@@ -972,9 +975,7 @@ private DiskProfile allocateTemplatedVolume(Type type, String name, DiskOffering
972975

973976
// Create event and update resource count for volumes if vm is a user vm
974977
if (vm.getType() == VirtualMachine.Type.User) {
975-
976978
Long offeringId = null;
977-
978979
if (!offering.isComputeOnly()) {
979980
offeringId = offering.getId();
980981
}
@@ -1943,14 +1944,18 @@ protected void updateVolumeSize(DataStore store, VolumeVO vol) throws ResourceAl
19431944

19441945
if (newSize != vol.getSize()) {
19451946
DiskOfferingVO diskOffering = diskOfferingDao.findByIdIncludingRemoved(vol.getDiskOfferingId());
1946-
if (newSize > vol.getSize()) {
1947-
_resourceLimitMgr.checkPrimaryStorageResourceLimit(_accountMgr.getActiveAccountById(vol.getAccountId()),
1948-
vol.isDisplay(), newSize - vol.getSize(), diskOffering);
1949-
_resourceLimitMgr.incrementVolumePrimaryStorageResourceCount(vol.getAccountId(), vol.isDisplay(),
1950-
newSize - vol.getSize(), diskOffering);
1951-
} else {
1952-
_resourceLimitMgr.decrementVolumePrimaryStorageResourceCount(vol.getAccountId(), vol.isDisplay(),
1953-
vol.getSize() - newSize, diskOffering);
1947+
VMInstanceVO vm = vol.getInstanceId() != null ? vmInstanceDao.findById(vol.getInstanceId()) : null;
1948+
if (vm == null || vm.getType() == VirtualMachine.Type.User) {
1949+
// Update resource count for user vm volumes when volume is attached
1950+
if (newSize > vol.getSize()) {
1951+
_resourceLimitMgr.checkPrimaryStorageResourceLimit(_accountMgr.getActiveAccountById(vol.getAccountId()),
1952+
vol.isDisplay(), newSize - vol.getSize(), diskOffering);
1953+
_resourceLimitMgr.incrementVolumePrimaryStorageResourceCount(vol.getAccountId(), vol.isDisplay(),
1954+
newSize - vol.getSize(), diskOffering);
1955+
} else {
1956+
_resourceLimitMgr.decrementVolumePrimaryStorageResourceCount(vol.getAccountId(), vol.isDisplay(),
1957+
vol.getSize() - newSize, diskOffering);
1958+
}
19541959
}
19551960
vol.setSize(newSize);
19561961
_volsDao.persist(vol);

plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3473,7 +3473,7 @@ public int compare(final DiskTO arg0, final DiskTO arg1) {
34733473
}
34743474

34753475
if (vmSpec.getOs().toLowerCase().contains("window")) {
3476-
isWindowsTemplate =true;
3476+
isWindowsTemplate = true;
34773477
}
34783478
for (final DiskTO volume : disks) {
34793479
KVMPhysicalDisk physicalDisk = null;
@@ -3592,6 +3592,9 @@ public int compare(final DiskTO arg0, final DiskTO arg1) {
35923592
disk.defNetworkBasedDisk(physicalDisk.getPath().replace("rbd:", ""), pool.getSourceHost(), pool.getSourcePort(), pool.getAuthUserName(),
35933593
pool.getUuid(), devId, diskBusType, DiskProtocol.RBD, DiskDef.DiskFmtType.RAW);
35943594
} else if (pool.getType() == StoragePoolType.PowerFlex) {
3595+
if (isWindowsTemplate && isUefiEnabled) {
3596+
diskBusTypeData = DiskDef.DiskBus.SATA;
3597+
}
35953598
disk.defBlockBasedDisk(physicalDisk.getPath(), devId, diskBusTypeData);
35963599
if (physicalDisk.getFormat().equals(PhysicalDiskFormat.QCOW2)) {
35973600
disk.setDiskFormatType(DiskDef.DiskFmtType.QCOW2);
@@ -3622,7 +3625,6 @@ public int compare(final DiskTO arg0, final DiskTO arg1) {
36223625
disk.defFileBasedDisk(physicalDisk.getPath(), devId, diskBusType, DiskDef.DiskFmtType.QCOW2);
36233626
}
36243627
}
3625-
36263628
}
36273629
pool.customizeLibvirtDiskDef(disk);
36283630
}
@@ -4911,6 +4913,14 @@ protected String getDiskPathFromDiskDef(DiskDef disk) {
49114913
return token[1];
49124914
}
49134915
} else if (token.length > 3) {
4916+
// for powerflex/scaleio, path = /dev/disk/by-id/emc-vol-2202eefc4692120f-540fd8fa00000003
4917+
if (token.length > 4 && StringUtils.isNotBlank(token[4]) && token[4].startsWith("emc-vol-")) {
4918+
final String[] emcVolToken = token[4].split("-");
4919+
if (emcVolToken.length == 4) {
4920+
return emcVolToken[3];
4921+
}
4922+
}
4923+
49144924
// for example, path = /mnt/pool_uuid/disk_path/
49154925
return token[3];
49164926
}

plugins/metrics/src/main/java/org/apache/cloudstack/metrics/MetricsServiceImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ public ListResponse<VmMetricsStatsResponse> searchForSystemVmMetricsStats(ListSy
235235
@Override
236236
public ListResponse<VolumeMetricsStatsResponse> searchForVolumeMetricsStats(ListVolumesUsageHistoryCmd cmd) {
237237
Pair<List<VolumeVO>, Integer> volumeList = searchForVolumesInternal(cmd);
238-
Map<Long,List<VolumeStatsVO>> volumeStatsList = searchForVolumeMetricsStatsInternal(cmd, volumeList.first());
238+
Map<Long, List<VolumeStatsVO>> volumeStatsList = searchForVolumeMetricsStatsInternal(cmd, volumeList.first());
239239
return createVolumeMetricsStatsResponse(volumeList, volumeStatsList);
240240
}
241241

plugins/storage/volume/scaleio/src/main/java/org/apache/cloudstack/storage/datastore/driver/ScaleIOPrimaryDataStoreDriver.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -573,8 +573,8 @@ public CreateObjectAnswer createVolume(VolumeInfo volumeInfo, long storagePoolId
573573
}
574574
}
575575
} else {
576-
logger.debug("No encryption configured for data volume [id: {}, uuid: {}, name: {}]",
577-
volumeInfo.getId(), volumeInfo.getUuid(), volumeInfo.getName());
576+
logger.debug("No encryption configured for volume [id: {}, uuid: {}, name: {}]",
577+
volumeInfo.getId(), volumeInfo.getUuid(), volumeInfo.getName());
578578
}
579579

580580
return answer;
@@ -1592,7 +1592,7 @@ public void provideVmTags(long vmId, long volumeId, String tagValue) {
15921592
* @return true if resize is required
15931593
*/
15941594
private boolean needsExpansionForEncryptionHeader(long srcSize, long dstSize) {
1595-
int headerSize = 32<<20; // ensure we have 32MiB for encryption header
1595+
int headerSize = 32 << 20; // ensure we have 32MiB for encryption header
15961596
return srcSize + headerSize > dstSize;
15971597
}
15981598

plugins/storage/volume/scaleio/src/main/java/org/apache/cloudstack/storage/datastore/manager/ScaleIOSDCManagerImpl.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,15 @@
6161
public class ScaleIOSDCManagerImpl implements ScaleIOSDCManager, Configurable {
6262
private Logger logger = LogManager.getLogger(getClass());
6363

64+
static ConfigKey<Boolean> ConnectOnDemand = new ConfigKey<>("Storage",
65+
Boolean.class,
66+
"powerflex.connect.on.demand",
67+
Boolean.TRUE.toString(),
68+
"Connect PowerFlex client on Host when first Volume is mapped to SDC and disconnect when last Volume is unmapped from SDC," +
69+
" otherwise no action (that is connection remains in the same state whichever it is, connected or disconnected).",
70+
Boolean.TRUE,
71+
ConfigKey.Scope.Zone);
72+
6473
@Inject
6574
AgentManager agentManager;
6675
@Inject

scripts/util/keystore-cert-import

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ if [ -f "$LIBVIRTD_FILE" ]; then
122122
ln -sf /etc/pki/libvirt/private/serverkey.pem /etc/pki/libvirt-vnc/server-key.pem
123123
cloudstack-setup-agent -s > /dev/null
124124

125-
QEMU_GROUP=$(sed -n 's/^group=//p' /etc/libvirt/qemu.conf | awk -F'"' '{print $2}' | tail -n1)
125+
QEMU_GROUP=$(sed -n 's/^group\s*=//p' /etc/libvirt/qemu.conf | tr -d '"' | tr -d ' ' | tr -d "'" | tail -n1)
126126
if [ ! -z "${QEMU_GROUP// }" ]; then
127127
chgrp $QEMU_GROUP /etc/pki/libvirt /etc/pki/libvirt-vnc /etc/pki/CA /etc/pki/libvirt/private /etc/pki/libvirt/servercert.pem /etc/pki/libvirt/private/serverkey.pem /etc/pki/CA/cacert.pem /etc/pki/libvirt-vnc/ca-cert.pem /etc/pki/libvirt-vnc/server-cert.pem /etc/pki/libvirt-vnc/server-key.pem
128128
chmod 750 /etc/pki/libvirt /etc/pki/libvirt-vnc /etc/pki/CA /etc/pki/libvirt/private /etc/pki/libvirt/servercert.pem /etc/pki/libvirt/private/serverkey.pem /etc/pki/CA/cacert.pem /etc/pki/libvirt-vnc/ca-cert.pem /etc/pki/libvirt-vnc/server-cert.pem /etc/pki/libvirt-vnc/server-key.pem

server/conf/cloudstack-sudoers.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
# The CloudStack management server needs sudo permissions
1919
# without a password.
2020

21-
Cmnd_Alias CLOUDSTACK = /bin/mkdir, /bin/mount, /bin/umount, /bin/cp, /bin/chmod, /usr/bin/keytool, /bin/keytool, /bin/touch, /bin/find, /bin/df, /bin/ls, /bin/qemu-img
21+
Cmnd_Alias CLOUDSTACK = /bin/mkdir, /bin/mount, /bin/umount, /bin/cp, /bin/chmod, /usr/bin/keytool, /bin/keytool, /bin/touch, /bin/find, /bin/df, /bin/ls, /bin/qemu-img, /usr/bin/qemu-img
2222

2323
Defaults:@MSUSER@ !requiretty
2424

server/src/main/java/com/cloud/server/StatsCollector.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1462,7 +1462,7 @@ public void doInTransactionWithoutResult(TransactionStatus status) {
14621462
for (VmDiskStats vmDiskStat : vmDiskStats) {
14631463
VmDiskStatsEntry vmDiskStatEntry = (VmDiskStatsEntry)vmDiskStat;
14641464
SearchCriteria<VolumeVO> sc_volume = _volsDao.createSearchCriteria();
1465-
sc_volume.addAnd("path", SearchCriteria.Op.EQ, vmDiskStatEntry.getPath());
1465+
sc_volume.addAnd("path", SearchCriteria.Op.LIKE, vmDiskStatEntry.getPath() + "%");
14661466
List<VolumeVO> volumes = _volsDao.search(sc_volume, null);
14671467

14681468
if (CollectionUtils.isEmpty(volumes))

server/src/main/java/com/cloud/storage/snapshot/SnapshotManagerImpl.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1965,9 +1965,14 @@ public Snapshot allocSnapshot(Long volumeId, Long policyId, String snapshotName,
19651965
Type snapshotType = getSnapshotType(policyId);
19661966
Account owner = _accountMgr.getAccount(volume.getAccountId());
19671967

1968+
ResourceType storeResourceType = ResourceType.secondary_storage;
1969+
if (!isBackupSnapshotToSecondaryForZone(volume.getDataCenterId()) ||
1970+
Snapshot.LocationType.PRIMARY.equals(locationType)) {
1971+
storeResourceType = ResourceType.primary_storage;
1972+
}
19681973
try {
19691974
_resourceLimitMgr.checkResourceLimit(owner, ResourceType.snapshot);
1970-
_resourceLimitMgr.checkResourceLimit(owner, ResourceType.secondary_storage, new Long(volume.getSize()).longValue());
1975+
_resourceLimitMgr.checkResourceLimit(owner, storeResourceType, volume.getSize());
19711976
} catch (ResourceAllocationException e) {
19721977
if (snapshotType != Type.MANUAL) {
19731978
String msg = String.format("Snapshot resource limit exceeded for account %s. Failed to create recurring snapshots", owner);
@@ -2018,7 +2023,7 @@ public Snapshot allocSnapshot(Long volumeId, Long policyId, String snapshotName,
20182023
}
20192024
CallContext.current().putContextParameter(Snapshot.class, snapshot.getUuid());
20202025
_resourceLimitMgr.incrementResourceCount(volume.getAccountId(), ResourceType.snapshot);
2021-
_resourceLimitMgr.incrementResourceCount(volume.getAccountId(), ResourceType.secondary_storage, new Long(volume.getSize()));
2026+
_resourceLimitMgr.incrementResourceCount(volume.getAccountId(), storeResourceType, volume.getSize());
20222027
return snapshot;
20232028
}
20242029

0 commit comments

Comments
 (0)