Skip to content

Commit 25641c3

Browse files
genegrEugenio Grosso
authored andcommitted
adaptive: honor user-provided capacityBytes when provider stats are unavailable
AdaptiveDataStoreLifeCycleImpl.initialize() guarded the user-provided capacityBytes behind stats != null when computing the pool capacity to persist. As a consequence, any adaptive provider that could not report capacity yet (for example a FlashArray pod that has not been given a quota and has no footprint yet, or a transient probe failure) caused the whole pool registration to fail with "Capacity bytes not available from the storage provider, user provided capacity bytes must be specified" even when the operator had passed capacityBytes= on createStoragePool. Accept the user-supplied value unconditionally and use the provider stats only as an upper-bound sanity check when they are actually available. The "no user-provided capacity, no provider capacity" branch is preserved and still raises the same InvalidParameterValueException. Signed-off-by: Eugenio Grosso <eugenio.grosso@gmail.com>
1 parent 9f96c9d commit 25641c3

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

plugins/storage/volume/adaptive/src/main/java/org/apache/cloudstack/storage/datastore/lifecycle/AdaptiveDataStoreLifeCycleImpl.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -217,13 +217,14 @@ public DataStore initialize(Map<String, Object> dsInfos) {
217217
// validate the provided details are correct/valid for the provider
218218
api.validate();
219219

220-
// if we have user-provided capacity bytes, validate they do not exceed the manaaged storage capacity bytes
220+
// User-provided capacityBytes always wins; validate against storage stats only when
221+
// the provider could actually report them. If the provider cannot (empty pod with no
222+
// footprint, no quota set, transient probe failure), fall through and use what the
223+
// user supplied rather than failing the whole registration.
221224
ProviderVolumeStorageStats stats = api.getManagedStorageStats();
222-
if (capacityBytes != null && capacityBytes != 0 && stats != null) {
223-
if (stats.getCapacityInBytes() > 0) {
224-
if (stats.getCapacityInBytes() < capacityBytes) {
225-
throw new InvalidParameterValueException("Capacity bytes provided exceeds the capacity of the storage endpoint: provided by user: " + capacityBytes + ", storage capacity from storage provider: " + stats.getCapacityInBytes());
226-
}
225+
if (capacityBytes != null && capacityBytes != 0) {
226+
if (stats != null && stats.getCapacityInBytes() > 0 && stats.getCapacityInBytes() < capacityBytes) {
227+
throw new InvalidParameterValueException("Capacity bytes provided exceeds the capacity of the storage endpoint: provided by user: " + capacityBytes + ", storage capacity from storage provider: " + stats.getCapacityInBytes());
227228
}
228229
parameters.setCapacityBytes(capacityBytes);
229230
}

0 commit comments

Comments
 (0)