Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
17 changes: 9 additions & 8 deletions compute/src/main/java/org/zstack/compute/VmNicUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import static org.zstack.core.Platform.argerr;
import static org.zstack.header.vm.VmInstanceConstant.VM_NIC_QOS_MAX;
import static org.zstack.header.vm.VmInstanceConstant.VM_NIC_QOS_MIN;
import static org.zstack.utils.clouderrorcode.CloudOperationsErrorCode.*;

public class VmNicUtils {
public static void validateVmParms(List<VmNicParam> vmNicParms, List<String> l3Uuids, List<String> supportNicDriverTypes) {
Expand All @@ -22,45 +23,45 @@ public static void validateVmParms(List<VmNicParam> vmNicParms, List<String> l3U

List<String> l3UuidsInParms = vmNicParms.stream().map(VmNicParam::getL3NetworkUuid).distinct().collect(Collectors.toList());
if (l3UuidsInParms.size() != vmNicParms.size()) {
throw new ApiMessageInterceptionException(argerr("duplicate nic params"));
throw new ApiMessageInterceptionException(argerr(ORG_ZSTACK_COMPUTE_10000, "duplicate nic params"));
}

for (VmNicParam nic : vmNicParms) {
String l3 = nic.getL3NetworkUuid();
if (StringUtils.isEmpty(l3)) {
throw new ApiMessageInterceptionException(argerr("l3NetworkUuid of vm nic can not be null"));
throw new ApiMessageInterceptionException(argerr(ORG_ZSTACK_COMPUTE_10001, "l3NetworkUuid of vm nic can not be null"));
}
if (!CollectionUtils.isEmpty(l3Uuids) && !l3Uuids.contains(nic.getL3NetworkUuid())) {
throw new ApiMessageInterceptionException(argerr("l3NetworkUuid of vm nic is not in l3[%s]", l3Uuids));
throw new ApiMessageInterceptionException(argerr(ORG_ZSTACK_COMPUTE_10002, "l3NetworkUuid of vm nic is not in l3[%s]", l3Uuids));
}

if (nic.getOutboundBandwidth() != null) {
if (nic.getOutboundBandwidth() < VM_NIC_QOS_MIN || nic.getOutboundBandwidth() > VM_NIC_QOS_MAX) {
throw new ApiMessageInterceptionException(argerr("outbound bandwidth[%d] of vm nic is out of [8192, 32212254720]", nic.getOutboundBandwidth()));
throw new ApiMessageInterceptionException(argerr(ORG_ZSTACK_COMPUTE_10003, "outbound bandwidth[%d] of vm nic is out of [8192, 32212254720]", nic.getOutboundBandwidth()));
}
}

if (nic.getInboundBandwidth() != null) {
if (nic.getInboundBandwidth() < VM_NIC_QOS_MIN || nic.getInboundBandwidth() > VM_NIC_QOS_MAX) {
throw new ApiMessageInterceptionException(argerr("inbound bandwidth[%d] of vm nic is out of [8192, 32212254720]", nic.getInboundBandwidth()));
throw new ApiMessageInterceptionException(argerr(ORG_ZSTACK_COMPUTE_10004, "inbound bandwidth[%d] of vm nic is out of [8192, 32212254720]", nic.getInboundBandwidth()));
}
}

if (nic.getMultiQueueNum() != null ) {
if (nic.getMultiQueueNum() < 1 || nic.getMultiQueueNum() > 256) {
throw new ApiMessageInterceptionException(argerr("multi queue num[%d] of vm nic is out of [1,256]", nic.getMultiQueueNum()));
throw new ApiMessageInterceptionException(argerr(ORG_ZSTACK_COMPUTE_10005, "multi queue num[%d] of vm nic is out of [1,256]", nic.getMultiQueueNum()));
}
}

if (nic.getState() != null) {
if (!asList(VmNicState.enable.toString(), VmNicState.disable.toString()).contains(nic.getState())) {
throw new ApiMessageInterceptionException(argerr("vm nic of l3[uuid:%s] state[%s] is not %s or %s ", nic.getL3NetworkUuid(), nic.getState(), VmNicState.enable.toString(), VmNicState.disable.toString()));
throw new ApiMessageInterceptionException(argerr(ORG_ZSTACK_COMPUTE_10006, "vm nic of l3[uuid:%s] state[%s] is not %s or %s ", nic.getL3NetworkUuid(), nic.getState(), VmNicState.enable.toString(), VmNicState.disable.toString()));
}
}

String driverType = nic.getDriverType();
if (!StringUtils.isEmpty(driverType) && !CollectionUtils.isEmpty(supportNicDriverTypes) && !supportNicDriverTypes.contains(driverType)){
throw new ApiMessageInterceptionException(argerr("vm nic driver %s not support yet", driverType));
throw new ApiMessageInterceptionException(argerr(ORG_ZSTACK_COMPUTE_10007, "vm nic driver %s not support yet", driverType));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import org.zstack.utils.logging.CLogger;
import org.zstack.utils.Utils;
import static org.zstack.utils.clouderrorcode.CloudOperationsErrorCode.*;


@Configurable(preConstruction = true, autowire = Autowire.BY_TYPE)
Expand Down Expand Up @@ -172,7 +173,7 @@ public void allocate() {
}

if (candidates.isEmpty()) {
fail(Platform.operr("no host found in clusters that has attached to L2Networks which have L3Networks%s", spec.getL3NetworkUuids()));
fail(Platform.operr(ORG_ZSTACK_COMPUTE_ALLOCATOR_10027, "no host found in clusters that has attached to L2Networks which have L3Networks%s", spec.getL3NetworkUuids()));
} else {
next(candidates);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import javax.persistence.TypedQuery;
import java.util.List;
import java.util.Set;
import static org.zstack.utils.clouderrorcode.CloudOperationsErrorCode.*;
@Configurable(preConstruction = true, autowire = Autowire.BY_TYPE)
public class AttachedPrimaryStorageAllocatorFlow extends AbstractHostAllocatorFlow {
private static final CLogger logger = Utils.getLogger(AttachedPrimaryStorageAllocatorFlow.class);
Expand Down Expand Up @@ -76,7 +77,7 @@ public String call(VolumeInventory arg) {
candidates = allocate(psuuids, vm);

if (candidates.isEmpty()) {
fail(Platform.operr("no host found in clusters that have attached to primary storage %s", psuuids));
fail(Platform.operr(ORG_ZSTACK_COMPUTE_ALLOCATOR_10014, "no host found in clusters that have attached to primary storage %s", psuuids));
} else {
next(candidates);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.zstack.utils.function.Function;

import java.util.*;
import static org.zstack.utils.clouderrorcode.CloudOperationsErrorCode.*;

/**
*/
Expand All @@ -38,7 +39,7 @@ public void allocate() {

VmInstanceInventory vm = spec.getVmInstance();
if (vm.getRootVolume() == null || !VolumeStatus.Ready.toString().equals(vm.getRootVolume().getStatus())) {
fail(Platform.operr("cannot find root volume of vm[uuid:%s]", vm.getUuid()));
fail(Platform.operr(ORG_ZSTACK_COMPUTE_ALLOCATOR_10022, "cannot find root volume of vm[uuid:%s]", vm.getUuid()));
}

List<String> requiredPsUuids = CollectionUtils.transformToList(vm.getAllVolumes(), new Function<String, VolumeInventory>() {
Expand Down Expand Up @@ -81,7 +82,7 @@ public String call(VolumeInventory arg) {
}

if (candidates.isEmpty()) {
fail(Platform.operr("no host found in clusters which have attached to all primary storage %s where vm[uuid:%s]'s volumes locate",
fail(Platform.operr(ORG_ZSTACK_COMPUTE_ALLOCATOR_10023, "no host found in clusters which have attached to all primary storage %s where vm[uuid:%s]'s volumes locate",
requiredPsUuids, vm.getUuid()));
} else {
next(candidates);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.zstack.utils.function.Function;

import java.util.List;
import static org.zstack.utils.clouderrorcode.CloudOperationsErrorCode.*;

@Configurable(preConstruction = true, autowire = Autowire.BY_TYPE)
public class AvoidHostAllocatorFlow extends AbstractHostAllocatorFlow {
Expand All @@ -27,7 +28,7 @@ public HostVO call(HostVO arg) {
});

if (ret.isEmpty()) {
fail(Platform.operr("after rule out avoided host%s, there is no host left in candidates", spec.getAvoidHostUuids()));
fail(Platform.operr(ORG_ZSTACK_COMPUTE_ALLOCATOR_10026, "after rule out avoided host%s, there is no host left in candidates", spec.getAvoidHostUuids()));
} else {
next(ret);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

import static org.zstack.core.Platform.inerr;
import static org.zstack.core.Platform.operr;
import static org.zstack.utils.clouderrorcode.CloudOperationsErrorCode.*;

/**
* Created by xing5 on 2016/8/17.
Expand Down Expand Up @@ -59,7 +60,7 @@ public void allocate() {
List<String> possiblePrimaryStorageTypes = spec.getBackupStoragePrimaryStorageMetrics().get(type);
if (possiblePrimaryStorageTypes == null) {
throw new OperationFailureException(inerr(
"the image[uuid:%s] is on the backup storage[uuid:%s, type:%s] that doesn't have metrics defined" +
ORG_ZSTACK_COMPUTE_ALLOCATOR_10006, "the image[uuid:%s] is on the backup storage[uuid:%s, type:%s] that doesn't have metrics defined" +
" in conf/springConfigXml/HostAllocatorManager.xml. The developer should add its primary storage metrics",
spec.getImage().getUuid(), spec.getRequiredBackupStorageUuid(), type
));
Expand All @@ -69,7 +70,7 @@ public void allocate() {
if (result.isEmpty()) {
String name = spec.getImage().getName();
throw new OperationFailureException(operr(
"The image[uuid:%s, name:%s] is on the backup storage[uuid:%s, type:%s] that requires to work with primary storage[types:%s]," +
ORG_ZSTACK_COMPUTE_ALLOCATOR_10007, "The image[uuid:%s, name:%s] is on the backup storage[uuid:%s, type:%s] that requires to work with primary storage[types:%s]," +
"however, no host found suitable to work with those primary storage", spec.getImage().getUuid(), name,
spec.getRequiredBackupStorageUuid(),spec.getImage().getType(), possiblePrimaryStorageTypes
));
Expand All @@ -78,13 +79,13 @@ public void allocate() {
result = findHostsByPrimaryStorageUuids(psUuids);
if (result.isEmpty()) {
throw new OperationFailureException(operr(
"The image[uuid:%s] is on the backup storage[uuid:%s, type:%s] that requires to work with primary storage[uuids:%s]," +
ORG_ZSTACK_COMPUTE_ALLOCATOR_10008, "The image[uuid:%s] is on the backup storage[uuid:%s, type:%s] that requires to work with primary storage[uuids:%s]," +
"however, no host found suitable to work with those primary storage", spec.getImage().getUuid(),
spec.getRequiredBackupStorageUuid(), type, psUuids)
);
}
} else {
throw new OperationFailureException(operr("the backup storage[uuid:%s, type:%s] requires bound" +
throw new OperationFailureException(operr(ORG_ZSTACK_COMPUTE_ALLOCATOR_10009, "the backup storage[uuid:%s, type:%s] requires bound" +
" primary storage, however, the primary storage has not been added", spec.getRequiredBackupStorageUuid(), bsType));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import javax.persistence.TypedQuery;
import java.util.ArrayList;
import java.util.List;
import static org.zstack.utils.clouderrorcode.CloudOperationsErrorCode.*;
@Configurable(preConstruction = true, autowire = Autowire.BY_TYPE)
public class DesignatedHostAllocatorFlow extends AbstractHostAllocatorFlow {
private static final CLogger logger = Utils.getLogger(DesignatedHostAllocatorFlow.class);
Expand Down Expand Up @@ -105,7 +106,7 @@ public void allocate() {
if (spec.getHypervisorType() != null) {
args.append(String.format("hypervisorType=%s", spec.getHypervisorType())).append(" ");
}
fail(Platform.operr("No host with %s found", args));
fail(Platform.operr(ORG_ZSTACK_COMPUTE_ALLOCATOR_10036, "No host with %s found", args));
} else {
next(candidates);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.zstack.header.errorcode.OperationFailureException;
import org.zstack.utils.Utils;
import org.zstack.utils.logging.CLogger;
import static org.zstack.utils.clouderrorcode.CloudOperationsErrorCode.*;

/**
* Created by frank on 7/2/2015.
Expand All @@ -33,7 +34,7 @@ public void allocate() {
logger.debug(String.format("after being filtered by HostAllocatorFilterExtensionPoint[%s], candidates num: %s", filter.getClass(), candidates.size()));

if (candidates.isEmpty()) {
fail(Platform.operr("after filtering, HostAllocatorFilterExtensionPoint[%s] returns zero candidate host, it means: %s", filter.getClass().getSimpleName(), filter.filterErrorReason()));
fail(Platform.operr(ORG_ZSTACK_COMPUTE_ALLOCATOR_10037, "after filtering, HostAllocatorFilterExtensionPoint[%s] returns zero candidate host, it means: %s", filter.getClass().getSimpleName(), filter.filterErrorReason()));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import static org.zstack.core.Platform.argerr;

import java.util.List;
import static org.zstack.utils.clouderrorcode.CloudOperationsErrorCode.*;

/**
* Created with IntelliJ IDEA.
Expand Down Expand Up @@ -54,7 +55,7 @@ public APIMessage intercept(APIMessage msg) throws ApiMessageInterceptionExcepti
private void validate(APIGetCandidateBackupStorageForCreatingImageMsg msg) {
if (msg.getVolumeSnapshotUuid() == null && msg.getVolumeUuid() == null) {
throw new ApiMessageInterceptionException(argerr(
"either volumeUuid or volumeSnapshotUuid must be set"
ORG_ZSTACK_COMPUTE_ALLOCATOR_10024, "either volumeUuid or volumeSnapshotUuid must be set"
));
}
}
Expand All @@ -72,7 +73,7 @@ private void validate(APIGetCpuMemoryCapacityMsg msg) {
}

if (!pass && !msg.isAll()) {
throw new ApiMessageInterceptionException(argerr("zoneUuids, clusterUuids, hostUuids must at least have one be none-empty list, or all is set to true"));
throw new ApiMessageInterceptionException(argerr(ORG_ZSTACK_COMPUTE_ALLOCATOR_10025, "zoneUuids, clusterUuids, hostUuids must at least have one be none-empty list, or all is set to true"));
}

if (msg.isAll() && (msg.getZoneUuids() == null || msg.getZoneUuids().isEmpty())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

import static org.zstack.core.Platform.err;
import static org.zstack.core.Platform.inerr;
import static org.zstack.utils.clouderrorcode.CloudOperationsErrorCode.*;

/**
*/
Expand Down Expand Up @@ -101,10 +102,10 @@ private void done() {
// in case a wrong flow returns an empty result set
if (result.isEmpty()) {
if (isDryRun) {
dryRunCompletion.fail(err(HostAllocatorError.NO_AVAILABLE_HOST,
dryRunCompletion.fail(err(ORG_ZSTACK_COMPUTE_ALLOCATOR_10017, HostAllocatorError.NO_AVAILABLE_HOST,
"host allocation flow doesn't indicate any details"));
} else {
completion.fail(err(HostAllocatorError.NO_AVAILABLE_HOST,
completion.fail(err(ORG_ZSTACK_COMPUTE_ALLOCATOR_10018, HostAllocatorError.NO_AVAILABLE_HOST,
"host allocation flow doesn't indicate any details"));
}
return;
Expand Down Expand Up @@ -145,7 +146,7 @@ private void runFlow(AbstractHostAllocatorFlow flow) {
}
} catch (Throwable t) {
logger.warn("unhandled throwable", t);
completion.fail(inerr(t.toString()));
completion.fail(inerr(ORG_ZSTACK_COMPUTE_ALLOCATOR_10019, t.toString()));
}
Comment on lines 147 to 150
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

cat -n compute/src/main/java/org/zstack/compute/allocator/HostAllocatorChain.java | head -200

Repository: MatheMatrix/zstack

Length of output: 180


🏁 Script executed:

# Check if completion field could be null during dry-run
rg -n "dryRunCompletion|completion\s*=" compute/src/main/java/org/zstack/compute/allocator/HostAllocatorChain.java -A 2

Repository: MatheMatrix/zstack

Length of output: 180


🏁 Script executed:

# Search for inerr method signature
rg -n "ErrorCode\s+inerr\s*\(" --type=java -A 3 | head -50

Repository: MatheMatrix/zstack

Length of output: 439


🏁 Script executed:

rg "private.*completion|this\.completion\s*=" --type=java -B 2 -A 2 | grep -A 5 -B 5 "HostAllocatorChain"

Repository: MatheMatrix/zstack

Length of output: 2722


🏁 Script executed:

rg "dryRunCompletion|isDryRun" --type=java | head -40

Repository: MatheMatrix/zstack

Length of output: 4654


🏁 Script executed:

# Search for the specific error code constants
rg "ORG_ZSTACK_COMPUTE_ALLOCATOR_1001[0-9]" --type=java -B 1 -A 1 | head -50

Repository: MatheMatrix/zstack

Length of output: 6395


🏁 Script executed:

# Get the runFlow method to see the exception handling
rg -n "private void runFlow\|} catch \(Throwable" compute/src/main/java/org/zstack/compute/allocator/HostAllocatorChain.java -A 15 | head -80

Repository: MatheMatrix/zstack

Length of output: 44


🏁 Script executed:

# Get a specific range around line 147-150
sed -n '140,160p' compute/src/main/java/org/zstack/compute/allocator/HostAllocatorChain.java

Repository: MatheMatrix/zstack

Length of output: 1095


🏁 Script executed:

# Look for the full context around the allocate and dryRun methods to confirm flow
sed -n '53,85p' compute/src/main/java/org/zstack/compute/allocator/HostAllocatorChain.java

Repository: MatheMatrix/zstack

Length of output: 886


🏁 Script executed:

# Check other exception handlers in this file to see the pattern
rg -n "if \(isDryRun\)" compute/src/main/java/org/zstack/compute/allocator/HostAllocatorChain.java -B 2 -A 2

Repository: MatheMatrix/zstack

Length of output: 819


🏁 Script executed:

# Verify that dryRun() only sets dryRunCompletion and not completion
sed -n '77,87p' compute/src/main/java/org/zstack/compute/allocator/HostAllocatorChain.java

Repository: MatheMatrix/zstack

Length of output: 280


🏁 Script executed:

# Check the exact catch block implementation once more with more context
sed -n '145,155p' compute/src/main/java/org/zstack/compute/allocator/HostAllocatorChain.java

Repository: MatheMatrix/zstack

Length of output: 536


严重:dry-run 场景的异常捕获会导致 NPE,覆盖原始异常

runFlow()catch (Throwable) 分支(第 147-150 行)直接调用 completion.fail(...),但 dryRun() 方法仅设置 dryRunCompletion,将 completion 保留为 null。当异常被捕获时,会在 null 的 completion 上调用 fail(),触发 NullPointerException,进而掩盖真实异常。

代码的其他部分(如 done() 方法)都正确地通过 if (isDryRun) 判断路由到对应的 completion 对象,但该 catch 块未遵循此模式。

建议修复
        } catch (Throwable t) {
            logger.warn("unhandled throwable", t);
-            completion.fail(inerr(ORG_ZSTACK_COMPUTE_ALLOCATOR_10019, t.toString()));
+            ErrorCode ec = inerr(ORG_ZSTACK_COMPUTE_ALLOCATOR_10019, t.toString());
+            if (isDryRun) {
+                dryRunCompletion.fail(ec);
+            } else {
+                completion.fail(ec);
+            }
        }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
} catch (Throwable t) {
logger.warn("unhandled throwable", t);
completion.fail(inerr(t.toString()));
completion.fail(inerr(ORG_ZSTACK_COMPUTE_ALLOCATOR_10019, t.toString()));
}
} catch (Throwable t) {
logger.warn("unhandled throwable", t);
ErrorCode ec = inerr(ORG_ZSTACK_COMPUTE_ALLOCATOR_10019, t.toString());
if (isDryRun) {
dryRunCompletion.fail(ec);
} else {
completion.fail(ec);
}
}
🤖 Prompt for AI Agents
In @compute/src/main/java/org/zstack/compute/allocator/HostAllocatorChain.java
around lines 147 - 150, The catch(Throwable t) in runFlow incorrectly always
calls completion.fail(...), which can be null in dry-run mode and causes an NPE
that hides the original error; change the catch block to mirror done() by
checking isDryRun and invoking dryRunCompletion.fail(...) when dry-run is
active, otherwise invoking completion.fail(...), and ensure you null-check the
chosen completion before calling fail and log the original throwable.

}

Expand Down Expand Up @@ -228,7 +229,7 @@ public void fail(ErrorCode errorCode) {
lastFlow.getClass().getName(), errorCode.getDetails()));
this.errorCode = errorCode;
} else {
this.errorCode = err(HostAllocatorError.NO_AVAILABLE_HOST, seriesErrorWhenPagination.iterator().next(), "unable to allocate hosts; due to pagination is enabled, " +
this.errorCode = err(ORG_ZSTACK_COMPUTE_ALLOCATOR_10020, HostAllocatorError.NO_AVAILABLE_HOST, seriesErrorWhenPagination.iterator().next(), "unable to allocate hosts; due to pagination is enabled, " +
"there might be several allocation failures happened before;" +
" the error list is %s", seriesErrorWhenPagination.stream().map(ErrorCode::getDetails).collect(Collectors.toList()));
logger.debug(this.errorCode.getDetails());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@

import static org.zstack.core.Platform.operr;
import static org.zstack.utils.CollectionDSL.list;
import static org.zstack.utils.clouderrorcode.CloudOperationsErrorCode.*;

public class HostAllocatorManagerImpl extends AbstractService implements HostAllocatorManager, VmAbnormalLifeCycleExtensionPoint {
private static final CLogger logger = Utils.getLogger(HostAllocatorManagerImpl.class);
Expand Down Expand Up @@ -956,7 +957,7 @@ public void run() {

trigger.next();
} catch (UnableToReserveHostCapacityException e) {
trigger.fail(operr(e.getMessage()));
trigger.fail(operr(ORG_ZSTACK_COMPUTE_ALLOCATOR_10012, e.getMessage()));
}
}

Expand All @@ -979,7 +980,7 @@ public void run() {

trigger.next();
} catch (UnableToReserveHostCapacityException e) {
trigger.fail(operr(e.getMessage()));
trigger.fail(operr(ORG_ZSTACK_COMPUTE_ALLOCATOR_10013, e.getMessage()));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import java.util.List;
import java.util.stream.Collectors;
import static org.zstack.utils.clouderrorcode.CloudOperationsErrorCode.*;

@Configurable(preConstruction = true, autowire = Autowire.BY_TYPE)
public class HostCapacityAllocatorFlow extends AbstractHostAllocatorFlow {
Expand Down Expand Up @@ -62,7 +63,7 @@ public void allocate() {
ret = reserveMgr.filterOutHostsByReservedCapacity(ret, spec.getCpuCapacity(), spec.getMemoryCapacity());

if (ret.isEmpty()) {
fail(Platform.operr("no host having cpu[%s], memory[%s bytes] found",
fail(Platform.operr(ORG_ZSTACK_COMPUTE_ALLOCATOR_10021, "no host having cpu[%s], memory[%s bytes] found",
spec.getCpuCapacity(), spec.getMemoryCapacity()));
} else {
next(ret);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.util.stream.Collectors;

import static org.zstack.utils.CollectionUtils.*;
import static org.zstack.utils.clouderrorcode.CloudOperationsErrorCode.*;

/**
* Filter out hosts that do not match the operating system of the specific host
Expand Down Expand Up @@ -69,7 +70,7 @@ public void allocate() {
.collect(Collectors.toList());

if (matchedHosts.isEmpty()) {
fail(Platform.operr("no candidate host has version[%s]", currentHostOs));
fail(Platform.operr(ORG_ZSTACK_COMPUTE_ALLOCATOR_10000, "no candidate host has version[%s]", currentHostOs));
} else {
next(matchedHosts);
}
Expand Down
Loading