This is an automated email from the ASF dual-hosted git repository.

DaanHoogland pushed a commit to branch 4.20
in repository https://gitbox.apache.org/repos/asf/cloudstack.git


The following commit(s) were added to refs/heads/4.20 by this push:
     new 08b1d387557 adaptive: honor user-provided capacityBytes when provider 
stats are unavailable (#13059)
08b1d387557 is described below

commit 08b1d38755727b615fda6a668ba9ac035f3b8002
Author: Eugenio Grosso <[email protected]>
AuthorDate: Sat May 2 11:21:13 2026 +0100

    adaptive: honor user-provided capacityBytes when provider stats are 
unavailable (#13059)
    
    Signed-off-by: Eugenio Grosso <[email protected]>
    Co-authored-by: Eugenio Grosso <[email protected]>
---
 .../datastore/lifecycle/AdaptiveDataStoreLifeCycleImpl.java | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git 
a/plugins/storage/volume/adaptive/src/main/java/org/apache/cloudstack/storage/datastore/lifecycle/AdaptiveDataStoreLifeCycleImpl.java
 
b/plugins/storage/volume/adaptive/src/main/java/org/apache/cloudstack/storage/datastore/lifecycle/AdaptiveDataStoreLifeCycleImpl.java
index 771f79887e0..c8efc08c289 100644
--- 
a/plugins/storage/volume/adaptive/src/main/java/org/apache/cloudstack/storage/datastore/lifecycle/AdaptiveDataStoreLifeCycleImpl.java
+++ 
b/plugins/storage/volume/adaptive/src/main/java/org/apache/cloudstack/storage/datastore/lifecycle/AdaptiveDataStoreLifeCycleImpl.java
@@ -217,13 +217,14 @@ public class AdaptiveDataStoreLifeCycleImpl extends 
BasePrimaryDataStoreLifeCycl
             // validate the provided details are correct/valid for the provider
             api.validate();
 
-            // if we have user-provided capacity bytes, validate they do not 
exceed the manaaged storage capacity bytes
+            // User-provided capacityBytes always wins; validate against 
storage stats only when
+            // the provider could actually report them. If the provider cannot 
(empty pod with no
+            // footprint, no quota set, transient probe failure), fall through 
and use what the
+            // user supplied rather than failing the whole registration.
             ProviderVolumeStorageStats stats = api.getManagedStorageStats();
-            if (capacityBytes != null && capacityBytes != 0 && stats != null) {
-                if (stats.getCapacityInBytes() > 0) {
-                    if (stats.getCapacityInBytes() < capacityBytes) {
-                        throw new InvalidParameterValueException("Capacity 
bytes provided exceeds the capacity of the storage endpoint: provided by user: 
" + capacityBytes + ", storage capacity from storage provider: " + 
stats.getCapacityInBytes());
-                    }
+            if (capacityBytes != null && capacityBytes > 0) {
+                if (stats != null && stats.getCapacityInBytes() > 0 && 
stats.getCapacityInBytes() < capacityBytes) {
+                    throw new InvalidParameterValueException("Provided 
capacity bytes exceed the capacity of the storage endpoint: provided by user: " 
+ capacityBytes + ", storage capacity from storage provider: " + 
stats.getCapacityInBytes());
                 }
                 parameters.setCapacityBytes(capacityBytes);
             }

Reply via email to