Skip to content

Commit dcfa614

Browse files
fix the retrieval of ceph rgw buckets usage information
1 parent 5328528 commit dcfa614

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

plugins/storage/object/ceph/src/main/java/org/apache/cloudstack/storage/datastore/driver/CephObjectStoreDriverImpl.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -302,13 +302,20 @@ public void setBucketQuota(BucketTO bucket, long storeId, long size) {
302302
public Map<String, Long> getAllBucketsUsage(long storeId) {
303303
RgwAdmin rgwAdmin = getRgwAdminClient(storeId);
304304
try {
305-
List<BucketInfo> bucketinfo = rgwAdmin.listBucketInfo();
306-
Map<String, Long> bucketsusage = new HashMap<String, Long>();
307-
for (BucketInfo bucket: bucketinfo) {
305+
logger.debug("Fetching statistics for all buckets accessible by the RGW administrator of the provider with ID [{}].", storeId);
306+
List<BucketInfo> bucketsInfo = rgwAdmin.listBucketInfo();
307+
Map<String, Long> bucketsUsage = new HashMap<>();
308+
for (BucketInfo bucket : bucketsInfo) {
308309
BucketInfo.Usage usage = bucket.getUsage();
309-
bucketsusage.put(bucket.getBucket(), usage.getRgwMain().getSize_kb());
310+
if (usage == null || usage.getRgwMain() == null) {
311+
logger.debug("Skipping bucket [{}] because RGW usage information is unavailable.", bucket.getBucket());
312+
continue;
313+
}
314+
315+
bucketsUsage.put(bucket.getBucket(), usage.getRgwMain().getSize_kb());
310316
}
311-
return bucketsusage;
317+
318+
return bucketsUsage;
312319
} catch (Exception e) {
313320
throw new CloudRuntimeException(e);
314321
}

0 commit comments

Comments
 (0)