From 995ce06cb740052ed36bbb86bdbf2664577b42a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Beims=20Br=C3=A4scher?= Date: Wed, 22 Dec 2021 01:40:40 -0300 Subject: [PATCH 1/3] Enhance log message in FirstFitPlanner (#5762) * Enhance log message in FirstFitPlanner When cluster reached capacity threshold the message is: "capacity threshold defined at each cluster/ at global value for capacity Type : 0" Admins hardly remember the Capacity Type and it can take a while to look at which is the resource for the respective ID. This enhancement addes log message pointing to the capacity name (e.g. Memory / CPU) as well as global settings parameter name and value to be looked at. * Change formatation in String 'warnMessageForClusterReachedCapacityThreshold' --- .../main/java/com/cloud/deploy/FirstFitPlanner.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/server/src/main/java/com/cloud/deploy/FirstFitPlanner.java b/server/src/main/java/com/cloud/deploy/FirstFitPlanner.java index f5263e21045..7dc2a50382b 100644 --- a/server/src/main/java/com/cloud/deploy/FirstFitPlanner.java +++ b/server/src/main/java/com/cloud/deploy/FirstFitPlanner.java @@ -26,6 +26,7 @@ import java.util.Map; import javax.inject.Inject; import javax.naming.ConfigurationException; +import com.cloud.capacity.CapacityVO; import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager; import org.apache.cloudstack.framework.config.ConfigKey; import org.apache.cloudstack.framework.config.Configurable; @@ -353,12 +354,16 @@ public class FirstFitPlanner extends AdapterBase implements DeploymentClusterPla return; } + String configurationName = ClusterCPUCapacityDisableThreshold.key(); + float configurationValue = ClusterCPUCapacityDisableThreshold.value(); if (capacity == Capacity.CAPACITY_TYPE_CPU) { clustersCrossingThreshold = capacityDao.listClustersCrossingThreshold(capacity, plan.getDataCenterId(), ClusterCPUCapacityDisableThreshold.key(), cpu_requested); } else if (capacity == Capacity.CAPACITY_TYPE_MEMORY) { clustersCrossingThreshold = capacityDao.listClustersCrossingThreshold(capacity, plan.getDataCenterId(), ClusterMemoryCapacityDisableThreshold.key(), ram_requested); + configurationName = ClusterMemoryCapacityDisableThreshold.key(); + configurationValue = ClusterMemoryCapacityDisableThreshold.value(); } if (clustersCrossingThreshold != null && clustersCrossingThreshold.size() != 0) { @@ -367,8 +372,11 @@ public class FirstFitPlanner extends AdapterBase implements DeploymentClusterPla // Remove clusters crossing disabled threshold clusterListForVmAllocation.removeAll(clustersCrossingThreshold); - s_logger.debug("Cannot allocate cluster list " + clustersCrossingThreshold.toString() + " for vm creation since their allocated percentage" + - " crosses the disable capacity threshold defined at each cluster/ at global value for capacity Type : " + capacity + ", skipping these clusters"); + String warnMessageForClusterReachedCapacityThreshold = String.format( + "Cannot allocate cluster list %s for VM creation since their allocated percentage crosses the disable capacity threshold defined at each cluster at" + + " Global Settings Configuration [name: %s, value: %s] for capacity Type : %s, skipping these clusters", clustersCrossingThreshold.toString(), + configurationName, String.valueOf(configurationValue), CapacityVO.getCapacityName(capacity)); + s_logger.warn(warnMessageForClusterReachedCapacityThreshold); } } From 936ebbb90f787209f3dc6f0213165a2691f87dab Mon Sep 17 00:00:00 2001 From: Pearl Dsilva Date: Wed, 22 Dec 2021 10:41:06 +0530 Subject: [PATCH 2/3] api: Fix search cluster by name (#5782) --- .../src/main/java/com/cloud/server/ManagementServerImpl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/src/main/java/com/cloud/server/ManagementServerImpl.java b/server/src/main/java/com/cloud/server/ManagementServerImpl.java index 08ae0ad13f4..2b79ff00be0 100644 --- a/server/src/main/java/com/cloud/server/ManagementServerImpl.java +++ b/server/src/main/java/com/cloud/server/ManagementServerImpl.java @@ -1146,7 +1146,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe final SearchBuilder sb = _clusterDao.createSearchBuilder(); sb.and("id", sb.entity().getId(), SearchCriteria.Op.EQ); - sb.and("name", sb.entity().getName(), SearchCriteria.Op.LIKE); + sb.and("name", sb.entity().getName(), SearchCriteria.Op.EQ); sb.and("podId", sb.entity().getPodId(), SearchCriteria.Op.EQ); sb.and("dataCenterId", sb.entity().getDataCenterId(), SearchCriteria.Op.EQ); sb.and("hypervisorType", sb.entity().getHypervisorType(), SearchCriteria.Op.EQ); @@ -1159,7 +1159,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe } if (name != null) { - sc.setParameters("name", "%" + name + "%"); + sc.setParameters("name", name); } if (podId != null) { From 39e41f6b6e2dbb4066e179a772639f99f3c2dc47 Mon Sep 17 00:00:00 2001 From: sureshanaparti <12028987+sureshanaparti@users.noreply.github.com> Date: Wed, 22 Dec 2021 22:13:02 +0530 Subject: [PATCH 3/3] Allow force reboot VM from user account, to start VM on the same host (#5791) --- .../main/java/com/cloud/vm/UserVmManager.java | 3 +++ .../java/com/cloud/vm/UserVmManagerImpl.java | 17 ++++++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/server/src/main/java/com/cloud/vm/UserVmManager.java b/server/src/main/java/com/cloud/vm/UserVmManager.java index 8d4cf453a56..cde2d04970d 100644 --- a/server/src/main/java/com/cloud/vm/UserVmManager.java +++ b/server/src/main/java/com/cloud/vm/UserVmManager.java @@ -110,6 +110,9 @@ public interface UserVmManager extends UserVmService { Pair> startVirtualMachine(long vmId, Long podId, Long clusterId, Long hostId, Map additionalParams, String deploymentPlannerToUse) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException, ResourceAllocationException; + Pair> startVirtualMachine(long vmId, Long podId, Long clusterId, Long hostId, Map additionalParams, String deploymentPlannerToUse, boolean isExplicitHost) + throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException, ResourceAllocationException; + boolean upgradeVirtualMachine(Long id, Long serviceOfferingId, Map customParameters) throws ResourceUnavailableException, ConcurrentOperationException, ManagementServerException, VirtualMachineMigrationException; diff --git a/server/src/main/java/com/cloud/vm/UserVmManagerImpl.java b/server/src/main/java/com/cloud/vm/UserVmManagerImpl.java index d7c90b305c8..463e17730b8 100644 --- a/server/src/main/java/com/cloud/vm/UserVmManagerImpl.java +++ b/server/src/main/java/com/cloud/vm/UserVmManagerImpl.java @@ -1078,7 +1078,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir params = new HashMap(); params.put(VirtualMachineProfile.Param.BootIntoSetup, Boolean.TRUE); } - return startVirtualMachine(vmId, null, null, hostId, params, null).first(); + return startVirtualMachine(vmId, null, null, hostId, params, null, false).first(); } } catch (ResourceUnavailableException e) { throw new CloudRuntimeException("Unable to reboot the VM: " + vmId, e); @@ -5063,6 +5063,13 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir public Pair> startVirtualMachine(long vmId, Long podId, Long clusterId, Long hostId, Map additionalParams, String deploymentPlannerToUse) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException, ResourceAllocationException { + return startVirtualMachine(vmId, podId, clusterId, hostId, additionalParams, deploymentPlannerToUse, true); + } + + @Override + public Pair> startVirtualMachine(long vmId, Long podId, Long clusterId, Long hostId, + Map additionalParams, String deploymentPlannerToUse, boolean isExplicitHost) + throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException, ResourceAllocationException { // Input validation final Account callerAccount = CallContext.current().getCallingAccount(); UserVO callerUser = _userDao.findById(CallContext.current().getCallingUserId()); @@ -5118,7 +5125,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir boolean isRootAdmin = _accountService.isRootAdmin(callerAccount.getId()); Pod destinationPod = getDestinationPod(podId, isRootAdmin); Cluster destinationCluster = getDestinationCluster(clusterId, isRootAdmin); - Host destinationHost = getDestinationHost(hostId, isRootAdmin); + Host destinationHost = getDestinationHost(hostId, isRootAdmin, isExplicitHost); DataCenterDeployment plan = null; boolean deployOnGivenHost = false; if (destinationHost != null) { @@ -5271,10 +5278,10 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir return destinationCluster; } - private Host getDestinationHost(Long hostId, boolean isRootAdmin) { + private Host getDestinationHost(Long hostId, boolean isRootAdmin, boolean isExplicitHost) { Host destinationHost = null; if (hostId != null) { - if (!isRootAdmin) { + if (isExplicitHost && !isRootAdmin) { throw new PermissionDeniedException( "Parameter " + ApiConstants.HOST_ID + " can only be specified by a Root Admin, permission denied"); } @@ -5615,7 +5622,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir boolean isRootAdmin = _accountService.isRootAdmin(callerId); Long hostId = cmd.getHostId(); - getDestinationHost(hostId, isRootAdmin); + getDestinationHost(hostId, isRootAdmin, true); String ipAddress = cmd.getIpAddress(); String ip6Address = cmd.getIp6Address();