This is an automated email from the ASF dual-hosted git repository. vishesh pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/cloudstack.git
commit 19f79b1d94f986d012cc1e6ee42bfc2e21319bfe Merge: a44f28bb312 d3e020a5452 Author: Vishesh <vishes...@gmail.com> AuthorDate: Fri Apr 12 16:31:40 2024 +0530 Merge branch '4.19' agent/conf/agent.properties | 4 + .../cloud/agent/properties/AgentProperties.java | 7 ++ .../service/VolumeOrchestrationService.java | 2 + .../engine/orchestration/VolumeOrchestrator.java | 39 ++++--- .../java/com/cloud/storage/VolumeDetailVO.java | 3 + .../kvm/resource/LibvirtComputingResource.java | 69 ++++--------- .../hypervisor/kvm/resource/LibvirtConnection.java | 7 +- .../kvm/resource/LibvirtDomainListener.java | 65 ++++++++++++ .../wrapper/LibvirtScaleVmCommandWrapper.java | 8 -- .../apache/cloudstack/utils/linux/KVMHostInfo.java | 1 - .../cloudstack/utils/linux/KVMHostInfoTest.java | 3 - .../driver/ScaleIOPrimaryDataStoreDriver.java | 112 ++++++++++++++------- .../com/cloud/storage/ResizeVolumePayload.java | 8 ++ .../com/cloud/storage/VolumeApiServiceImpl.java | 12 ++- 14 files changed, 233 insertions(+), 107 deletions(-) diff --cc plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java index 7ba75d65466,37aba35bb9c..b30f2b6a6f0 --- a/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java +++ b/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java @@@ -503,8 -499,23 +500,23 @@@ public class LibvirtComputingResource e } @Override - public void registerStatusUpdater(AgentStatusUpdater updater) { - _agentStatusUpdater = updater; + public synchronized void registerStatusUpdater(AgentStatusUpdater updater) { + if (AgentPropertiesFileHandler.getPropertyValue(AgentProperties.LIBVIRT_EVENTS_ENABLED)) { + try { + Connect conn = LibvirtConnection.getConnection(); + if (libvirtDomainListener != null) { - s_logger.debug("Clearing old domain listener"); ++ LOGGER.debug("Clearing old domain listener"); + conn.removeLifecycleListener(libvirtDomainListener); + } + libvirtDomainListener = new LibvirtDomainListener(updater); + conn.addLifecycleListener(libvirtDomainListener); - s_logger.debug("Set up the libvirt domain event lifecycle listener"); ++ LOGGER.debug("Set up the libvirt domain event lifecycle listener"); + } catch (LibvirtException e) { - s_logger.error("Failed to get libvirt connection for domain event lifecycle", e); ++ LOGGER.error("Failed to get libvirt connection for domain event lifecycle", e); + } + } else { - s_logger.debug("Libvirt event listening is disabled, not registering status updater"); ++ LOGGER.debug("Libvirt event listening is disabled, not registering status updater"); + } } @Override @@@ -1879,9 -1890,13 +1891,13 @@@ public boolean stop() { try { final Connect conn = LibvirtConnection.getConnection(); + if (AgentPropertiesFileHandler.getPropertyValue(AgentProperties.LIBVIRT_EVENTS_ENABLED) && libvirtDomainListener != null) { - s_logger.debug("Clearing old domain listener"); ++ LOGGER.debug("Clearing old domain listener"); + conn.removeLifecycleListener(libvirtDomainListener); + } conn.close(); } catch (final LibvirtException e) { - s_logger.trace("Ignoring libvirt error.", e); + LOGGER.trace("Ignoring libvirt error.", e); } return true; @@@ -3697,9 -3702,8 +3713,8 @@@ sscmd.setDataCenter(dcId); sscmd.setResourceType(Storage.StorageResourceType.STORAGE_POOL); } catch (final CloudRuntimeException e) { - s_logger.debug("Unable to initialize local storage pool: " + e); + LOGGER.debug("Unable to initialize local storage pool: " + e); } - setupLibvirtEventListener(); return sscmd; } diff --cc plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtConnection.java index 2b0e088f5c7,0fa012b2c90..cbb5d85b712 --- a/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtConnection.java +++ b/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtConnection.java @@@ -42,8 -41,8 +42,8 @@@ public class LibvirtConnection return getConnection(s_hypervisorURI); } - static public Connect getConnection(String hypervisorURI) throws LibvirtException { + static synchronized public Connect getConnection(String hypervisorURI) throws LibvirtException { - s_logger.debug("Looking for libvirtd connection at: " + hypervisorURI); + LOGGER.debug("Looking for libvirtd connection at: " + hypervisorURI); Connect conn = s_connections.get(hypervisorURI); if (conn == null) { @@@ -122,6 -121,11 +122,11 @@@ * @throws LibvirtException */ private static synchronized void setupEventListener() throws LibvirtException { + if (!AgentPropertiesFileHandler.getPropertyValue(AgentProperties.LIBVIRT_EVENTS_ENABLED)) { - s_logger.debug("Libvirt event listening is disabled, not setting up event loop"); ++ LOGGER.debug("Libvirt event listening is disabled, not setting up event loop"); + return; + } + if (libvirtEventThread == null || !libvirtEventThread.isAlive()) { // Registers a default event loop, must be called before connecting to hypervisor Library.initEventLoop(); diff --cc plugins/storage/volume/scaleio/src/main/java/org/apache/cloudstack/storage/datastore/driver/ScaleIOPrimaryDataStoreDriver.java index b6335cf01ff,1d2cace8d21..31308a429da --- a/plugins/storage/volume/scaleio/src/main/java/org/apache/cloudstack/storage/datastore/driver/ScaleIOPrimaryDataStoreDriver.java +++ b/plugins/storage/volume/scaleio/src/main/java/org/apache/cloudstack/storage/datastore/driver/ScaleIOPrimaryDataStoreDriver.java @@@ -147,38 -187,11 +188,11 @@@ public class ScaleIOPrimaryDataStoreDri try { if (DataObjectType.VOLUME.equals(dataObject.getType())) { final VolumeVO volume = volumeDao.findById(dataObject.getId()); - LOGGER.debug("Granting access for PowerFlex volume: " + volume.getPath()); + logger.debug("Granting access for PowerFlex volume: " + volume.getPath()); - - Long bandwidthLimitInKbps = Long.valueOf(0); // Unlimited - // Check Bandwidht Limit parameter in volume details - final VolumeDetailVO bandwidthVolumeDetail = volumeDetailsDao.findDetail(volume.getId(), Volume.BANDWIDTH_LIMIT_IN_MBPS); - if (bandwidthVolumeDetail != null && bandwidthVolumeDetail.getValue() != null) { - bandwidthLimitInKbps = Long.parseLong(bandwidthVolumeDetail.getValue()) * 1024; - } - - Long iopsLimit = Long.valueOf(0); // Unlimited - // Check IOPS Limit parameter in volume details, else try MaxIOPS - final VolumeDetailVO iopsVolumeDetail = volumeDetailsDao.findDetail(volume.getId(), Volume.IOPS_LIMIT); - if (iopsVolumeDetail != null && iopsVolumeDetail.getValue() != null) { - iopsLimit = Long.parseLong(iopsVolumeDetail.getValue()); - } else if (volume.getMaxIops() != null) { - iopsLimit = volume.getMaxIops(); - } - if (iopsLimit > 0 && iopsLimit < ScaleIOUtil.MINIMUM_ALLOWED_IOPS_LIMIT) { - iopsLimit = ScaleIOUtil.MINIMUM_ALLOWED_IOPS_LIMIT; - } - - final String sdcId = getConnectedSdc(dataStore.getId(), host.getId()); - if (StringUtils.isBlank(sdcId)) { - alertHostSdcDisconnection(host); - throw new CloudRuntimeException("Unable to grant access to volume: " + dataObject.getId() + ", no Sdc connected with host ip: " + host.getPrivateIpAddress()); - } - - final ScaleIOGatewayClient client = getScaleIOClient(dataStore.getId()); - return client.mapVolumeToSdcWithLimits(ScaleIOUtil.getVolumePath(volume.getPath()), sdcId, iopsLimit, bandwidthLimitInKbps); + return setVolumeLimitsFromDetails(volume, host, dataStore); } else if (DataObjectType.TEMPLATE.equals(dataObject.getType())) { final VMTemplateStoragePoolVO templatePoolRef = vmTemplatePoolDao.findByPoolTemplate(dataStore.getId(), dataObject.getId(), null); - LOGGER.debug("Granting access for PowerFlex template volume: " + templatePoolRef.getInstallPath()); + logger.debug("Granting access for PowerFlex template volume: " + templatePoolRef.getInstallPath()); final String sdcId = getConnectedSdc(dataStore.getId(), host.getId()); if (StringUtils.isBlank(sdcId)) { @@@ -789,10 -802,18 +803,18 @@@ EndPoint ep = destHost != null ? RemoteHostEndPoint.getHypervisorHostEndPoint(destHost) : selector.select(srcData, encryptionRequired); if (ep == null) { String errorMsg = String.format("No remote endpoint to send command, unable to find a valid endpoint. Requires encryption support: %s", encryptionRequired); - LOGGER.error(errorMsg); + logger.error(errorMsg); answer = new Answer(cmd, false, errorMsg); } else { - answer = ep.sendMessage(cmd); + VolumeVO volume = volumeDao.findById(destData.getId()); + Host host = destHost != null ? destHost : hostDao.findById(ep.getId()); + try { + setVolumeLimitsOnSDC(volume, host, destData.getDataStore(), 0L, 0L); + answer = ep.sendMessage(cmd); + } catch (Exception e) { - LOGGER.error("Failed to copy template to volume due to: " + e.getMessage(), e); ++ logger.error("Failed to copy template to volume due to: " + e.getMessage(), e); + answer = new Answer(cmd, false, e.getMessage()); + } } return answer; @@@ -1211,8 -1232,22 +1233,22 @@@ } } + Long newMaxIops = payload.newMaxIops != null ? payload.newMaxIops : volumeInfo.getMaxIops(); + long newBandwidthLimit = 0L; + Long newDiskOfferingId = payload.newDiskOfferingId != null ? payload.newDiskOfferingId : volumeInfo.getDiskOfferingId(); + if (newDiskOfferingId != null) { + DiskOfferingDetailVO bandwidthLimitDetail = diskOfferingDetailsDao.findDetail(newDiskOfferingId, Volume.BANDWIDTH_LIMIT_IN_MBPS); + if (bandwidthLimitDetail != null) { + newBandwidthLimit = Long.parseLong(bandwidthLimitDetail.getValue()) * 1024; + } + DiskOfferingDetailVO iopsLimitDetail = diskOfferingDetailsDao.findDetail(newDiskOfferingId, Volume.IOPS_LIMIT); + if (iopsLimitDetail != null) { + newMaxIops = Long.parseLong(iopsLimitDetail.getValue()); + } + } + if (volumeInfo.getFormat().equals(Storage.ImageFormat.QCOW2) || attachedRunning) { - LOGGER.debug("Volume needs to be resized at the hypervisor host"); + logger.debug("Volume needs to be resized at the hypervisor host"); if (hostId == 0) { hostId = selector.select(volumeInfo, true).getId();