From e9cc5551d310c288a4b5ff748eee00951020f9a2 Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Thu, 3 Dec 2015 09:07:48 +0100 Subject: [PATCH 01/10] [UI] fix bug: Cannot delete SSH keypairs in projects Before change: error message: ProjectId and account/domainId can't be specified together After change: SSH keypairs can be removed --- ui/scripts/accounts.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ui/scripts/accounts.js b/ui/scripts/accounts.js index f0c0bff80ad..be620a46483 100644 --- a/ui/scripts/accounts.js +++ b/ui/scripts/accounts.js @@ -1876,10 +1876,14 @@ }, action: function(args) { var data = { - domainid: args.context.sshkeypairs[0].domainid, - account: args.context.sshkeypairs[0].account, name: args.context.sshkeypairs[0].name }; + if (!args.context.projects) { + $.extend(data, { + domainid: args.context.sshkeypairs[0].domainid, + account: args.context.sshkeypairs[0].account, + }); + } $.ajax({ url: createURL('deleteSSHKeyPair'), data: data, From 119b27b2c6c366949b574fbca1574f15d67a3af3 Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Thu, 3 Dec 2015 11:54:20 +0100 Subject: [PATCH 02/10] CLOUDSTACK-9101: update volume size after resizevolume --- server/src/com/cloud/storage/VolumeApiServiceImpl.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/server/src/com/cloud/storage/VolumeApiServiceImpl.java b/server/src/com/cloud/storage/VolumeApiServiceImpl.java index 6fe0a14343e..4313bfc4319 100644 --- a/server/src/com/cloud/storage/VolumeApiServiceImpl.java +++ b/server/src/com/cloud/storage/VolumeApiServiceImpl.java @@ -1158,6 +1158,9 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic if (newDiskOfferingId != null) { volume.setDiskOfferingId(newDiskOfferingId); } + if (currentSize != newSize) { + volume.setSize(newSize); + } _volsDao.update(volume.getId(), volume); From d6e21f74163212b198731ddf23dd48bc4c787b84 Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Thu, 3 Dec 2015 11:53:42 +0100 Subject: [PATCH 03/10] CLOUDSTACK-9101: add UI support for root volume resize --- ui/scripts/storage.js | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/ui/scripts/storage.js b/ui/scripts/storage.js index 77bd00284b1..599802a45ab 100644 --- a/ui/scripts/storage.js +++ b/ui/scripts/storage.js @@ -1536,14 +1536,27 @@ }, createForm: { title: 'label.action.resize.volume', + preFilter: function(args) { + if (args.context.volumes != null && args.context.volumes[0].type == 'ROOT') { + args.$form.find('.form-item[rel=newdiskoffering]').hide(); + } else { + args.$form.find('.form-item[rel=newsize]').hide(); + } + }, fields: { newdiskoffering: { label: 'label.resize.new.offering.id', select: function(args) { + if (args.context.volumes != null && args.context.volumes[0].type == 'ROOT') { + args.response.success({ + data: [] + }); + return; + } + $.ajax({ url: createURL("listDiskOfferings"), dataType: "json", - async: false, success: function(json) { diskofferingObjs = json.listdiskofferingsresponse.diskoffering; var items = []; @@ -1605,8 +1618,7 @@ validation: { required: true, number: true - }, - isHidden: true + } }, shrinkok: { label: 'label.resize.shrink.ok', @@ -1640,7 +1652,7 @@ var newDiskOffering = args.data.newdiskoffering; var newSize; - if (selectedDiskOfferingObj.iscustomized == true) { + if (selectedDiskOfferingObj == null || selectedDiskOfferingObj.iscustomized == true) { newSize = args.data.newsize; } if (newDiskOffering != null && newDiskOffering.length > 0) { @@ -1651,9 +1663,9 @@ } var minIops; - var maxIops + var maxIops; - if (selectedDiskOfferingObj.iscustomizediops == true) { + if (selectedDiskOfferingObj != null && selectedDiskOfferingObj.iscustomizediops == true) { minIops = args.data.minIops; maxIops = args.data.maxIops; } @@ -2338,11 +2350,14 @@ allowedActions.push("takeSnapshot"); allowedActions.push("recurringSnapshot"); } + } - if (jsonObj.type == "DATADISK") { + if (jsonObj.hypervisor == "KVM" || jsonObj.hypervisor == "XenServer" || jsonObj.hypervisor == "VMware") { + if (jsonObj.state == "Ready" || jsonObj.state == "Allocated") { allowedActions.push("resize"); } } + if (jsonObj.state != "Allocated") { if ((jsonObj.vmstate == "Stopped" || jsonObj.virtualmachineid == null) && jsonObj.state == "Ready") { allowedActions.push("downloadVolume"); From 9221cb3e0d0e5a0ea374f10e889f7e32c2a3eda1 Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Thu, 3 Dec 2015 14:31:55 +0100 Subject: [PATCH 04/10] CLOUDSTACK-9101: resize root volume of stopped vm on KVM --- scripts/storage/qcow2/resizevolume.sh | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/scripts/storage/qcow2/resizevolume.sh b/scripts/storage/qcow2/resizevolume.sh index 1e6ffd648f5..da77cb1adca 100755 --- a/scripts/storage/qcow2/resizevolume.sh +++ b/scripts/storage/qcow2/resizevolume.sh @@ -187,6 +187,22 @@ resizeqcow2() { # if this is a shrink operation, fail if commands will shrink the volume and we haven't signed of on shrinking failshrink + #move this back into cloudstack libvirt calls once the libvirt java bindings support block resize + #we try to inform hypervisor of new size, but don't fail if we can't + if `virsh help 2>/dev/null | grep -q blockresize` + then + if `virsh domstate $vmname >/dev/null 2>&1` + then + log "vm $vmname is running, use 'virsh blockresize' to resize the volume" + notifyqemu + if [ $? -eq 0 ] + then + log "performed successful resize - currentsize:$currentsize newsize:$newsize path:$path type:$ptype vmname:$vmname live:$liveresize shrink:$shrink" + exit 0 + fi + fi + fi + output=`qemu-img resize $path $newsize 2>&1` retval=$? @@ -196,10 +212,6 @@ resizeqcow2() { exit 1 fi - #move this back into cloudstack libvirt calls once the libvirt java bindings support block resize - #we try to inform hypervisor of new size, but don't fail if we can't - notifyqemu - log "performed successful resize - currentsize:$currentsize newsize:$newsize path:$path type:$ptype vmname:$vmname live:$liveresize shrink:$shrink" } @@ -244,7 +256,7 @@ then resizelvm elif [ "$ptype" == "QCOW2" ] then - notifyqemu + resizeqcow2 elif [ "$ptype" == "NOTIFYONLY" ] then notifyqemu From 52412286c657d384f86441095f5cbef510dd8763 Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Fri, 4 Dec 2015 08:18:09 +0100 Subject: [PATCH 05/10] CLOUDSTACK-8845: set isRevertable of snapshot to false if the volume is removed --- .../snapshot/StorageSystemSnapshotStrategy.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/StorageSystemSnapshotStrategy.java b/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/StorageSystemSnapshotStrategy.java index 2c71525aad5..d1470e43596 100644 --- a/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/StorageSystemSnapshotStrategy.java +++ b/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/StorageSystemSnapshotStrategy.java @@ -442,6 +442,12 @@ public class StorageSystemSnapshotStrategy extends SnapshotStrategyBase { public StrategyPriority canHandle(Snapshot snapshot, SnapshotOperation op) { long volumeId = snapshot.getVolumeId(); VolumeVO volumeVO = _volumeDao.findById(volumeId); + if (SnapshotOperation.REVERT.equals(op)) { + if (volumeVO != null && ImageFormat.QCOW2.equals(volumeVO.getFormat())) + return StrategyPriority.DEFAULT; + else + return StrategyPriority.CANT_HANDLE; + } long storagePoolId; @@ -459,13 +465,6 @@ public class StorageSystemSnapshotStrategy extends SnapshotStrategyBase { storagePoolId = volumeVO.getPoolId(); } - if (SnapshotOperation.REVERT.equals(op)) { - if (volumeVO != null && ImageFormat.QCOW2.equals(volumeVO.getFormat())) - return StrategyPriority.DEFAULT; - else - return StrategyPriority.CANT_HANDLE; - } - DataStore dataStore = _dataStoreMgr.getDataStore(storagePoolId, DataStoreRole.Primary); Map mapCapabilities = dataStore.getDriver().getCapabilities(); From dcc66651c0a5f53fcd9395139dad147b4ac1ea09 Mon Sep 17 00:00:00 2001 From: Rohit Yadav Date: Fri, 4 Dec 2015 13:47:03 +0530 Subject: [PATCH 06/10] rate-limit: increase JVM memory and enable fork mode for unit tests Enables forkmode for surefire plugin and increases memory opts for JVM for rate-limit tests. This tries to fix intermittent Jenkins failures which look like: multipleClientsCanAccessWithoutBlocking(org.apache.cloudstack.ratelimit.ApiRateLimitTest): unable to create new native thread (cherry picked from commit 421bc00cd6005d9e8484c6df46a3b84ff466afd2) Signed-off-by: Rohit Yadav --- plugins/api/rate-limit/pom.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/api/rate-limit/pom.xml b/plugins/api/rate-limit/pom.xml index 43e0848f9f1..faa73c32b82 100644 --- a/plugins/api/rate-limit/pom.xml +++ b/plugins/api/rate-limit/pom.xml @@ -32,7 +32,8 @@ org.apache.maven.plugins maven-surefire-plugin - -Xmx1024m + always + -Xmx2048m -XX:MaxPermSize=1024m org/apache/cloudstack/ratelimit/integration/* From f8790c3b9e8220666662bcdce88f62f57884bfc4 Mon Sep 17 00:00:00 2001 From: Anshul Gangwar Date: Fri, 4 Dec 2015 14:50:01 +0530 Subject: [PATCH 07/10] CLOUDSTACK-9025: Fixed can't create usable template from snapshot in Xenserver and Vmware Fix also reverts below commit as below solution making assumption about hypervisor which are not applicable in case of XenServer and VmWare Revert "CLOUDSTACK-8964: Can't create template or volume from snapshot" This reverts commit ccf5d75cfbe769b34c021ab3653ed318cae25933. --- .../src/com/cloud/hypervisor/XenServerGuru.java | 11 ++++++++--- .../cloud/hypervisor/HypervisorGuruManagerImpl.java | 5 +---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/XenServerGuru.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/XenServerGuru.java index 9567f313492..28bcf0db9f4 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/XenServerGuru.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/XenServerGuru.java @@ -185,7 +185,8 @@ public class XenServerGuru extends HypervisorGuruBase implements HypervisorGuru, DataTO srcData = cpyCommand.getSrcTO(); DataTO destData = cpyCommand.getDestTO(); - if (srcData.getObjectType() == DataObjectType.SNAPSHOT && destData.getObjectType() == DataObjectType.TEMPLATE) { + if (srcData.getHypervisorType() == HypervisorType.XenServer && srcData.getObjectType() == DataObjectType.SNAPSHOT && + destData.getObjectType() == DataObjectType.TEMPLATE) { DataStoreTO srcStore = srcData.getDataStore(); DataStoreTO destStore = destData.getDataStore(); if (srcStore instanceof NfsTO && destStore instanceof NfsTO) { @@ -193,9 +194,13 @@ public class XenServerGuru extends HypervisorGuruBase implements HypervisorGuru, EndPoint ep = endPointSelector.selectHypervisorHost(new ZoneScope(host.getDataCenterId())); host = hostDao.findById(ep.getId()); hostDao.loadDetails(host); + String hypervisorVersion = host.getHypervisorVersion(); String snapshotHotFixVersion = host.getDetail(XenserverConfigs.XS620HotFix); - if (snapshotHotFixVersion != null && snapshotHotFixVersion.equalsIgnoreCase(XenserverConfigs.XSHotFix62ESP1004)) { - return new Pair(Boolean.TRUE, new Long(ep.getId())); + if (hypervisorVersion != null && !hypervisorVersion.equalsIgnoreCase("6.1.0")) { + if (!(hypervisorVersion.equalsIgnoreCase("6.2.0") && + !(snapshotHotFixVersion != null && snapshotHotFixVersion.equalsIgnoreCase(XenserverConfigs.XSHotFix62ESP1004)))) { + return new Pair(Boolean.TRUE, new Long(ep.getId())); + } } } } diff --git a/server/src/com/cloud/hypervisor/HypervisorGuruManagerImpl.java b/server/src/com/cloud/hypervisor/HypervisorGuruManagerImpl.java index 4dcd703370f..ade1b9677ac 100644 --- a/server/src/com/cloud/hypervisor/HypervisorGuruManagerImpl.java +++ b/server/src/com/cloud/hypervisor/HypervisorGuruManagerImpl.java @@ -28,7 +28,6 @@ import org.apache.log4j.Logger; import org.springframework.stereotype.Component; import com.cloud.agent.api.Command; -import com.cloud.host.HostVO; import com.cloud.host.dao.HostDao; import com.cloud.hypervisor.Hypervisor.HypervisorType; import com.cloud.utils.Pair; @@ -75,9 +74,7 @@ public class HypervisorGuruManagerImpl extends ManagerBase implements Hypervisor @Override public long getGuruProcessedCommandTargetHost(long hostId, Command cmd) { - HostVO host = _hostDao.findById(hostId); - HypervisorGuru guru = getGuru(host.getHypervisorType()); - if (guru != null) { + for (HypervisorGuru guru : _hvGuruList) { Pair result = guru.getCommandHostDelegation(hostId, cmd); if (result.first()) { return result.second(); From e0501be87ea3a171afba03086139355bb3dc6051 Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Fri, 4 Dec 2015 18:18:15 +0100 Subject: [PATCH 08/10] Revert "CLOUDSTACK-8964 side effect isolation" This reverts commit fc18d1e8b11c82a18854234b0c8c827896a5b78d. --- .../hypervisor/ovm3/resources/Ovm3HypervisorGuru.java | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/plugins/hypervisors/ovm3/src/main/java/com/cloud/hypervisor/ovm3/resources/Ovm3HypervisorGuru.java b/plugins/hypervisors/ovm3/src/main/java/com/cloud/hypervisor/ovm3/resources/Ovm3HypervisorGuru.java index 3711bbf65f1..5a2e39bc787 100755 --- a/plugins/hypervisors/ovm3/src/main/java/com/cloud/hypervisor/ovm3/resources/Ovm3HypervisorGuru.java +++ b/plugins/hypervisors/ovm3/src/main/java/com/cloud/hypervisor/ovm3/resources/Ovm3HypervisorGuru.java @@ -87,15 +87,6 @@ public class Ovm3HypervisorGuru extends HypervisorGuruBase implements Hypervisor */ public Pair getCommandHostDelegation(long hostId, Command cmd) { LOGGER.debug("getCommandHostDelegation: " + cmd.getClass()); - performSideEffectsForDelegationOnCommand(hostId, cmd); - return new Pair(Boolean.FALSE, Long.valueOf(hostId)); - } - - /** - * @param hostId - * @param cmd - */ - void performSideEffectsForDelegationOnCommand(long hostId, Command cmd) { if (cmd instanceof StorageSubSystemCommand) { StorageSubSystemCommand c = (StorageSubSystemCommand)cmd; c.setExecuteInSequence(true); @@ -117,5 +108,6 @@ public class Ovm3HypervisorGuru extends HypervisorGuruBase implements Hypervisor } } } + return new Pair(Boolean.FALSE, Long.valueOf(hostId)); } } From 69e031d9beb662f28d0c5ca46ac19a6280ee2d4e Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Fri, 4 Dec 2015 18:18:28 +0100 Subject: [PATCH 09/10] Revert "simple change to prevent failure and keep OVM3 snapshots working" This reverts commit 66fed462b64c8e3fe9e7ee39c7a1c07ff33108f9. --- .../cloud/hypervisor/ovm3/resources/Ovm3HypervisorGuru.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugins/hypervisors/ovm3/src/main/java/com/cloud/hypervisor/ovm3/resources/Ovm3HypervisorGuru.java b/plugins/hypervisors/ovm3/src/main/java/com/cloud/hypervisor/ovm3/resources/Ovm3HypervisorGuru.java index 5a2e39bc787..6ec77414a53 100755 --- a/plugins/hypervisors/ovm3/src/main/java/com/cloud/hypervisor/ovm3/resources/Ovm3HypervisorGuru.java +++ b/plugins/hypervisors/ovm3/src/main/java/com/cloud/hypervisor/ovm3/resources/Ovm3HypervisorGuru.java @@ -105,6 +105,9 @@ public class Ovm3HypervisorGuru extends HypervisorGuruBase implements Hypervisor EndPoint ep = endPointSelector.selectHypervisorHost(new ZoneScope(host.getDataCenterId())); host = hostDao.findById(ep.getId()); hostDao.loadDetails(host); + // String snapshotHotFixVersion = host.getDetail(XenserverConfigs.XS620HotFix); + // if (snapshotHotFixVersion != null && snapshotHotFixVersion.equalsIgnoreCase(XenserverConfigs.XSHotFix62ESP1004)) { + return new Pair(Boolean.TRUE, Long.valueOf(ep.getId())); } } } From a90b953dbcb80cba09e03f34f96a7a52c0521d4f Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Fri, 4 Dec 2015 18:26:12 +0100 Subject: [PATCH 10/10] CLOUDSTACK-8964: Ovm3HypervisorGuru handle only srcData with HypervisorType is Ovm3 --- .../hypervisor/ovm3/resources/Ovm3HypervisorGuru.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/plugins/hypervisors/ovm3/src/main/java/com/cloud/hypervisor/ovm3/resources/Ovm3HypervisorGuru.java b/plugins/hypervisors/ovm3/src/main/java/com/cloud/hypervisor/ovm3/resources/Ovm3HypervisorGuru.java index 6ec77414a53..4d222bbae2f 100755 --- a/plugins/hypervisors/ovm3/src/main/java/com/cloud/hypervisor/ovm3/resources/Ovm3HypervisorGuru.java +++ b/plugins/hypervisors/ovm3/src/main/java/com/cloud/hypervisor/ovm3/resources/Ovm3HypervisorGuru.java @@ -96,18 +96,16 @@ public class Ovm3HypervisorGuru extends HypervisorGuruBase implements Hypervisor DataTO srcData = cpyCommand.getSrcTO(); DataTO destData = cpyCommand.getDestTO(); - if (srcData.getObjectType() == DataObjectType.SNAPSHOT && destData.getObjectType() == DataObjectType.TEMPLATE) { + if (HypervisorType.Ovm3.equals(srcData.getHypervisorType()) && srcData.getObjectType() == DataObjectType.SNAPSHOT && destData.getObjectType() == DataObjectType.TEMPLATE) { LOGGER.debug("Snapshot to Template: " + cmd); DataStoreTO srcStore = srcData.getDataStore(); DataStoreTO destStore = destData.getDataStore(); if (srcStore instanceof NfsTO && destStore instanceof NfsTO) { HostVO host = hostDao.findById(hostId); EndPoint ep = endPointSelector.selectHypervisorHost(new ZoneScope(host.getDataCenterId())); - host = hostDao.findById(ep.getId()); - hostDao.loadDetails(host); - // String snapshotHotFixVersion = host.getDetail(XenserverConfigs.XS620HotFix); - // if (snapshotHotFixVersion != null && snapshotHotFixVersion.equalsIgnoreCase(XenserverConfigs.XSHotFix62ESP1004)) { - return new Pair(Boolean.TRUE, Long.valueOf(ep.getId())); + if (ep != null) { + return new Pair(Boolean.TRUE, Long.valueOf(ep.getId())); + } } } }