diff --git a/compute/src/main/java/org/zstack/compute/allocator/HostAllocatorManagerImpl.java b/compute/src/main/java/org/zstack/compute/allocator/HostAllocatorManagerImpl.java index 48544a68333..a6598082004 100755 --- a/compute/src/main/java/org/zstack/compute/allocator/HostAllocatorManagerImpl.java +++ b/compute/src/main/java/org/zstack/compute/allocator/HostAllocatorManagerImpl.java @@ -851,17 +851,15 @@ public HostCapacityVO call(HostCapacityVO cap) { long deltaMemory = ratioMgr.calculateMemoryByRatio(hostUuid, memory); long availMemory = cap.getAvailableMemory() + deltaMemory; if (availMemory > cap.getTotalMemory()) { - throw new CloudRuntimeException( - String.format("invalid memory capacity of host[uuid:%s]," + - " available memory[%s] is greater than total memory[%s]." + - " Available Memory before is [%s], Delta Memory is [%s].", - hostUuid, - new DecimalFormat(",###").format(availMemory), - new DecimalFormat(",###").format(cap.getTotalMemory()), - new DecimalFormat(",###").format(cap.getAvailableMemory()), - new DecimalFormat(",###").format(deltaMemory) - ) - ); + logger.warn(String.format("memory capacity overflow on host[uuid:%s]," + + " available memory[%s] > total memory[%s], clamping to total." + + " Available Memory before is [%s], Delta Memory is [%s].", + hostUuid, + new DecimalFormat(",###").format(availMemory), + new DecimalFormat(",###").format(cap.getTotalMemory()), + new DecimalFormat(",###").format(cap.getAvailableMemory()), + new DecimalFormat(",###").format(deltaMemory))); + availMemory = cap.getTotalMemory(); } cap.setAvailableMemory(availMemory); diff --git a/plugin/ldap/src/main/java/org/zstack/ldap/LdapUtil.java b/plugin/ldap/src/main/java/org/zstack/ldap/LdapUtil.java index d386ca2d429..5f4b00f59fb 100644 --- a/plugin/ldap/src/main/java/org/zstack/ldap/LdapUtil.java +++ b/plugin/ldap/src/main/java/org/zstack/ldap/LdapUtil.java @@ -657,10 +657,10 @@ public LdapServerVO getLdapServer() { sq.add(LdapServerVO_.scope, SimpleQuery.Op.EQ, scope); List ldapServers = sq.list(); if (ldapServers.isEmpty()) { - throw new CloudRuntimeException("No LDAP/AD server record in database."); + throw new OperationFailureException(operr(ORG_ZSTACK_LDAP_10020, "No LDAP/AD server record in database.")); } if (ldapServers.size() > 1) { - throw new CloudRuntimeException("More than one LDAP/AD server record in database."); + throw new OperationFailureException(operr(ORG_ZSTACK_LDAP_10021, "More than one LDAP/AD server record in database.")); } return ldapServers.get(0); } diff --git a/search/src/main/java/org/zstack/query/QueryFacadeImpl.java b/search/src/main/java/org/zstack/query/QueryFacadeImpl.java index 6dafe940fca..9bd8fa8c724 100755 --- a/search/src/main/java/org/zstack/query/QueryFacadeImpl.java +++ b/search/src/main/java/org/zstack/query/QueryFacadeImpl.java @@ -378,7 +378,7 @@ private void handle(APIQueryMessage msg) { } catch (OperationFailureException of) { throw of; } catch (Exception e) { - throw new CloudRuntimeException(e); + throw new OperationFailureException(inerr("failed to query: %s", e.getMessage())); } } diff --git a/utils/src/main/java/org/zstack/utils/clouderrorcode/CloudOperationsErrorCode.java b/utils/src/main/java/org/zstack/utils/clouderrorcode/CloudOperationsErrorCode.java index a0f09d4f1e9..66ac4c5fc52 100644 --- a/utils/src/main/java/org/zstack/utils/clouderrorcode/CloudOperationsErrorCode.java +++ b/utils/src/main/java/org/zstack/utils/clouderrorcode/CloudOperationsErrorCode.java @@ -1654,6 +1654,10 @@ public class CloudOperationsErrorCode { public static final String ORG_ZSTACK_LDAP_10019 = "ORG_ZSTACK_LDAP_10019"; + public static final String ORG_ZSTACK_LDAP_10020 = "ORG_ZSTACK_LDAP_10020"; + + public static final String ORG_ZSTACK_LDAP_10021 = "ORG_ZSTACK_LDAP_10021"; + public static final String ORG_ZSTACK_IMAGE_10000 = "ORG_ZSTACK_IMAGE_10000"; public static final String ORG_ZSTACK_IMAGE_10001 = "ORG_ZSTACK_IMAGE_10001"; @@ -10652,6 +10656,8 @@ public class CloudOperationsErrorCode { public static final String ORG_ZSTACK_PREMIUM_EXTERNALSERVICE_PROMETHEUS_10013 = "ORG_ZSTACK_PREMIUM_EXTERNALSERVICE_PROMETHEUS_10013"; + public static final String ORG_ZSTACK_PREMIUM_EXTERNALSERVICE_PROMETHEUS_10014 = "ORG_ZSTACK_PREMIUM_EXTERNALSERVICE_PROMETHEUS_10014"; + public static final String ORG_ZSTACK_AI_CONTAINER_10000 = "ORG_ZSTACK_AI_CONTAINER_10000"; public static final String ORG_ZSTACK_AI_CONTAINER_10001 = "ORG_ZSTACK_AI_CONTAINER_10001";