Skip to content

Commit 08b1d38

Browse files
genegrEugenio Grosso
andauthored
adaptive: honor user-provided capacityBytes when provider stats are unavailable (#13059)
Signed-off-by: Eugenio Grosso <eugenio.grosso@gmail.com> Co-authored-by: Eugenio Grosso <egrosso@purestorage.com>
1 parent 9f96c9d commit 08b1d38

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("Provided capacity bytes exceed 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)