flasharray: fall back to array capacity when pod has no quota (#13050)

Signed-off-by: Eugenio Grosso <eugenio.grosso@gmail.com>
Co-authored-by: Eugenio Grosso <egrosso@purestorage.com>
This commit is contained in:
Eugenio Grosso 2026-05-27 21:16:52 +01:00 committed by GitHub
parent b642bbe38e
commit 357186d64d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 35 additions and 3 deletions

View File

@ -32,6 +32,7 @@ import java.util.Map;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLContext;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.http.Header;
import org.apache.http.NameValuePair;
import org.apache.cloudstack.storage.datastore.adapter.ProviderAdapter;
@ -491,18 +492,49 @@ public class FlashArrayAdapter implements ProviderAdapter {
@Override
public ProviderVolumeStorageStats getManagedStorageStats() {
FlashArrayPod pod = getVolumeNamespace(this.pod);
// just in case
if (pod == null || pod.getFootprint() == 0) {
if (pod == null) {
return null;
}
Long capacityBytes = pod.getQuotaLimit();
Long usedBytes = pod.getQuotaLimit() - (pod.getQuotaLimit() - pod.getFootprint());
if (capacityBytes == null || capacityBytes == 0) {
// Pod has no explicit quota set; report the array total physical
// capacity so the CloudStack allocator has a real ceiling to plan
// against rather than bailing out with a zero-capacity pool.
capacityBytes = getArrayTotalCapacity();
}
if (capacityBytes == null || capacityBytes == 0) {
return null;
}
Long usedBytes = pod.getFootprint();
if (usedBytes == null) {
usedBytes = 0L;
}
ProviderVolumeStorageStats stats = new ProviderVolumeStorageStats();
stats.setCapacityInBytes(capacityBytes);
stats.setActualUsedInBytes(usedBytes);
return stats;
}
private Long getArrayTotalCapacity() {
try {
FlashArrayList<Map<String, Object>> list = GET("/arrays?space=true",
new TypeReference<FlashArrayList<Map<String, Object>>>() {
});
if (list != null && CollectionUtils.isNotEmpty(list.getItems())) {
Object cap = list.getItems().get(0).get("capacity");
if (cap instanceof Number) {
return ((Number) cap).longValue();
}
}
} catch (Exception e) {
logger.warn("Could not retrieve total capacity for FlashArray [{}] (pod [{}]): {}",
this.url, this.pod, e.getMessage());
logger.debug("Stack trace for array total capacity lookup failure on FlashArray [{}] (pod [{}])",
this.url, this.pod, e);
}
return null;
}
@Override
public ProviderVolumeStats getVolumeStats(ProviderAdapterContext context, ProviderAdapterDataObject dataObject) {
ProviderVolume vol = getVolume(dataObject.getExternalName());