WAGED simulation API doesn't provide actual reason for the assignment calculation fail
- Dominant language
- Java
- Stars
- 504
- Forks
- 255
- Avg merge
- 17d 47m
- Merged PRs (30d)
- 2
Description
### Describe the bug
I've tried to using `HelixUtil.getTargetAssignmentForWagedFullAuto()` to check capacity availability for a resource before adding it to the cluster (refer to the below snippet). However, it ends up in a `HelixException` with `getIdealAssignmentForWagedFullAuto(): Calculation failed: Failed to compute BestPossibleState!` as the cause. Is it because the cluster doesn't have enough capacity for the resource? If so, is there a way to get actual `FAILED_TO_CALCULATE` exception propagated here, instead of having a generic cause?
### To Reproduce
```java
try {
IdealState newIS = getIdealState(resourceName);
ResourceConfig newResourceConfig = new ResourceConfig(resourceName);
// Set PARTITION_CAPACITY_MAP
Map capacityDataMap = ImmutableMap.of("CPU", "20", "MEMORY", "60");
newResourceConfig.getRecord().setMapField(ResourceConfig.ResourceConfigProperty.PARTITION_CAPACITY_MAP.name(),
Collections.singletonMap(ResourceConfig.DEFAULT_PARTITION_KEY, OBJECT_MAPPER.writeValueAsString(capacityDataMap)));
// Read existing cluster/instances/resources info
final ZKHelixDataAccessor dataAccessor = new ZKHelixDataAccessor(CLUSTER_NAME,
new ZkBaseDataAccessor.Builder().setZkAddress(ZK_ADDRESS).build());
ClusterConfig clusterConfig = dataAccessor.getProperty(dataAccessor.keyBuilder().clusterConfig());
List instanceConfigs = dataAccessor.getChildValues(dataAccessor.keyBuilder().instanceConfigs(), true);
List liveInstances = dataAccessor.getChildNames(dataAccessor.keyBuilder().liveInstances());
List idealStates = dataAccessor.getChildValues(dataAccessor.keyBuilder().idealStates(), true);
List resourceConfigs = dataAccessor.getChildValues(dataAccessor.keyBuilder().resourceConfigs(), true);
// Do we need add this?
idealStates.add(newIS);
resourceConfigs.add(newResourceConfig);
// Verify that utilResult contains the assignment for the resources added
Map utilResult = HelixUtil
.getTargetAssignmentForWagedFullAuto(ZK_ADDRESS, clusterConfig, instanceConfigs,
liveInstances, idealStates, resourceConfigs);
} catch (HelixException e) {
// Getting "getIdealAssignmentForWagedFullAuto(): Calculation failed: Failed to compute BestPossibleState!"
// means not enough capacity?
}
```
### Expected behavior
- Get actual `FAILED_TO_CALCULATE` exception propagated to the util, instead of having the generic `HelixException`.
### Additional context
- https://github.com/apache/helix/pull/1701
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.