Skip to content

Commit 357186d

Browse files
genegrEugenio Grosso
andauthored
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>
1 parent b642bbe commit 357186d

1 file changed

Lines changed: 35 additions & 3 deletions

File tree

  • plugins/storage/volume/flasharray/src/main/java/org/apache/cloudstack/storage/datastore/adapter/flasharray

plugins/storage/volume/flasharray/src/main/java/org/apache/cloudstack/storage/datastore/adapter/flasharray/FlashArrayAdapter.java

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import javax.net.ssl.HostnameVerifier;
3333
import javax.net.ssl.SSLContext;
3434

35+
import org.apache.commons.collections4.CollectionUtils;
3536
import org.apache.http.Header;
3637
import org.apache.http.NameValuePair;
3738
import org.apache.cloudstack.storage.datastore.adapter.ProviderAdapter;
@@ -491,18 +492,49 @@ public void disconnect() {
491492
@Override
492493
public ProviderVolumeStorageStats getManagedStorageStats() {
493494
FlashArrayPod pod = getVolumeNamespace(this.pod);
494-
// just in case
495-
if (pod == null || pod.getFootprint() == 0) {
495+
if (pod == null) {
496496
return null;
497497
}
498498
Long capacityBytes = pod.getQuotaLimit();
499-
Long usedBytes = pod.getQuotaLimit() - (pod.getQuotaLimit() - pod.getFootprint());
499+
if (capacityBytes == null || capacityBytes == 0) {
500+
// Pod has no explicit quota set; report the array total physical
501+
// capacity so the CloudStack allocator has a real ceiling to plan
502+
// against rather than bailing out with a zero-capacity pool.
503+
capacityBytes = getArrayTotalCapacity();
504+
}
505+
if (capacityBytes == null || capacityBytes == 0) {
506+
return null;
507+
}
508+
Long usedBytes = pod.getFootprint();
509+
if (usedBytes == null) {
510+
usedBytes = 0L;
511+
}
500512
ProviderVolumeStorageStats stats = new ProviderVolumeStorageStats();
501513
stats.setCapacityInBytes(capacityBytes);
502514
stats.setActualUsedInBytes(usedBytes);
503515
return stats;
504516
}
505517

518+
private Long getArrayTotalCapacity() {
519+
try {
520+
FlashArrayList<Map<String, Object>> list = GET("/arrays?space=true",
521+
new TypeReference<FlashArrayList<Map<String, Object>>>() {
522+
});
523+
if (list != null && CollectionUtils.isNotEmpty(list.getItems())) {
524+
Object cap = list.getItems().get(0).get("capacity");
525+
if (cap instanceof Number) {
526+
return ((Number) cap).longValue();
527+
}
528+
}
529+
} catch (Exception e) {
530+
logger.warn("Could not retrieve total capacity for FlashArray [{}] (pod [{}]): {}",
531+
this.url, this.pod, e.getMessage());
532+
logger.debug("Stack trace for array total capacity lookup failure on FlashArray [{}] (pod [{}])",
533+
this.url, this.pod, e);
534+
}
535+
return null;
536+
}
537+
506538
@Override
507539
public ProviderVolumeStats getVolumeStats(ProviderAdapterContext context, ProviderAdapterDataObject dataObject) {
508540
ProviderVolume vol = getVolume(dataObject.getExternalName());

0 commit comments

Comments
 (0)