Skip to content

Commit

Permalink
S3UTILS-155: keep the original values for current & nonCurrent
Browse files Browse the repository at this point in the history
Thsi ensures backward compatibility and remove the need to update
the services using theses values: ZKUI and PENSIVE-API
  • Loading branch information
williamlardier committed Mar 26, 2024
1 parent 461f8f3 commit 712edf2
Show file tree
Hide file tree
Showing 7 changed files with 1,143 additions and 1,142 deletions.
59 changes: 35 additions & 24 deletions CountItems/utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ function consolidateDataMetrics(target, source) {
usedCapacity: {
current: 0,
nonCurrent: 0,
currentCold: 0,
nonCurrentCold: 0,
currentRestored: 0,
currentRestoring: 0,
nonCurrentRestored: 0,
nonCurrentRestoring: 0,
_currentCold: 0,
_nonCurrentCold: 0,
_currentRestored: 0,
_currentRestoring: 0,
_nonCurrentRestored: 0,
_nonCurrentRestoring: 0,
},
});
}
Expand All @@ -25,12 +25,12 @@ function consolidateDataMetrics(target, source) {
objectCount: {
current: 0,
nonCurrent: 0,
currentCold: 0,
nonCurrentCold: 0,
currentRestored: 0,
currentRestoring: 0,
nonCurrentRestored: 0,
nonCurrentRestoring: 0,
_currentCold: 0,
_nonCurrentCold: 0,
_currentRestored: 0,
_currentRestoring: 0,
_nonCurrentRestored: 0,
_nonCurrentRestoring: 0,
deleteMarker: 0,
},
});
Expand All @@ -41,22 +41,33 @@ function consolidateDataMetrics(target, source) {
const { usedCapacity, objectCount } = source;
resTarget.usedCapacity.current += usedCapacity && usedCapacity.current ? usedCapacity.current : 0;
resTarget.usedCapacity.nonCurrent += usedCapacity && usedCapacity.nonCurrent ? usedCapacity.nonCurrent : 0;
resTarget.usedCapacity.currentCold += usedCapacity && usedCapacity.currentCold ? usedCapacity.currentCold : 0;
resTarget.usedCapacity.nonCurrentCold += usedCapacity && usedCapacity.nonCurrentCold ? usedCapacity.nonCurrentCold : 0;
resTarget.usedCapacity.currentRestoring += usedCapacity && usedCapacity.currentRestoring ? usedCapacity.currentRestoring : 0;
resTarget.usedCapacity.currentRestored += usedCapacity && usedCapacity.currentRestored ? usedCapacity.currentRestored : 0;
resTarget.usedCapacity.nonCurrentRestoring += usedCapacity && usedCapacity.nonCurrentRestoring ? usedCapacity.nonCurrentRestoring : 0;
resTarget.usedCapacity.nonCurrentRestored += usedCapacity && usedCapacity.nonCurrentRestored ? usedCapacity.nonCurrentRestored : 0;
resTarget.usedCapacity._currentCold += usedCapacity && usedCapacity._currentCold ? usedCapacity._currentCold : 0;
resTarget.usedCapacity._nonCurrentCold += usedCapacity && usedCapacity._nonCurrentCold ? usedCapacity._nonCurrentCold : 0;
resTarget.usedCapacity._currentRestoring += usedCapacity && usedCapacity._currentRestoring ? usedCapacity._currentRestoring : 0;
resTarget.usedCapacity._currentRestored += usedCapacity && usedCapacity._currentRestored ? usedCapacity._currentRestored : 0;
resTarget.usedCapacity._nonCurrentRestoring += usedCapacity && usedCapacity._nonCurrentRestoring ? usedCapacity._nonCurrentRestoring : 0;
resTarget.usedCapacity._nonCurrentRestored += usedCapacity && usedCapacity._nonCurrentRestored ? usedCapacity._nonCurrentRestored : 0;

resTarget.objectCount.current += objectCount && objectCount.current ? objectCount.current : 0;
resTarget.objectCount.nonCurrent += objectCount && objectCount.nonCurrent ? objectCount.nonCurrent : 0;
resTarget.objectCount.deleteMarker += objectCount && objectCount.deleteMarker ? objectCount.deleteMarker : 0;
resTarget.objectCount.currentCold += objectCount && objectCount.currentCold ? objectCount.currentCold : 0;
resTarget.objectCount.nonCurrentCold += objectCount && objectCount.nonCurrentCold ? objectCount.nonCurrentCold : 0;
resTarget.objectCount.currentRestoring += objectCount && objectCount.currentRestoring ? objectCount.currentRestoring : 0;
resTarget.objectCount.currentRestored += objectCount && objectCount.currentRestored ? objectCount.currentRestored : 0;
resTarget.objectCount.nonCurrentRestoring += objectCount && objectCount.nonCurrentRestoring ? objectCount.nonCurrentRestoring : 0;
resTarget.objectCount.nonCurrentRestored += objectCount && objectCount.nonCurrentRestored ? objectCount.nonCurrentRestored : 0;
resTarget.objectCount._currentCold += objectCount && objectCount._currentCold ? objectCount._currentCold : 0;
resTarget.objectCount._nonCurrentCold += objectCount && objectCount._nonCurrentCold ? objectCount._nonCurrentCold : 0;
resTarget.objectCount._currentRestoring += objectCount && objectCount._currentRestoring ? objectCount._currentRestoring : 0;
resTarget.objectCount._currentRestored += objectCount && objectCount._currentRestored ? objectCount._currentRestored : 0;
resTarget.objectCount._nonCurrentRestoring += objectCount && objectCount._nonCurrentRestoring ? objectCount._nonCurrentRestoring : 0;
resTarget.objectCount._nonCurrentRestored += objectCount && objectCount._nonCurrentRestored ? objectCount._nonCurrentRestored : 0;

// Current and NonCurrent are the total of all other metrics
resTarget.usedCapacity.current += usedCapacity
? usedCapacity._currentCold + usedCapacity._currentRestored + usedCapacity._currentRestoring : 0;
resTarget.usedCapacity.nonCurrent += usedCapacity
? usedCapacity._nonCurrentCold + usedCapacity._nonCurrentRestored + usedCapacity._nonCurrentRestoring : 0;
resTarget.objectCount.current += objectCount
? objectCount._currentCold + objectCount._currentRestored + objectCount._currentRestoring : 0;
resTarget.objectCount.nonCurrent += objectCount
? objectCount._nonCurrentCold + objectCount._nonCurrentRestored + objectCount._nonCurrentRestoring : 0;

return resTarget;
}

Expand Down
14 changes: 2 additions & 12 deletions DataReport/collectBucketMetricsAndUpdateBucketCapacityInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,7 @@ function isValidBucketStorageMetrics(bucketMetric) {
&& typeof bucketMetric.usedCapacity.current === 'number'
&& typeof bucketMetric.usedCapacity.nonCurrent === 'number'
&& bucketMetric.usedCapacity.current > -1
&& bucketMetric.usedCapacity.nonCurrent > -1
&& (typeof bucketMetric.usedCapacity.currentCold === 'undefined' || (bucketMetric.usedCapacity.currentCold > -1))
&& (typeof bucketMetric.usedCapacity.nonCurrentCold === 'undefined' || (bucketMetric.usedCapacity.nonCurrentCold > -1))
&& (typeof bucketMetric.usedCapacity.currentRestoring === 'undefined' || (bucketMetric.usedCapacity.currentRestoring > -1))
&& (typeof bucketMetric.usedCapacity.currentRestored === 'undefined' || (bucketMetric.usedCapacity.currentRestored > -1))
&& (typeof bucketMetric.usedCapacity.nonCurrentRestoring === 'undefined' || (bucketMetric.usedCapacity.nonCurrentRestoring > -1))
&& (typeof bucketMetric.usedCapacity.nonCurrentRestored === 'undefined' || (bucketMetric.usedCapacity.nonCurrentRestored > -1));
&& bucketMetric.usedCapacity.nonCurrent > -1;
}

function isValidCapacityValue(capacity) {
Expand Down Expand Up @@ -84,11 +78,7 @@ function collectBucketMetricsAndUpdateBucketCapacityInfo(mongoClient, log, callb
if (isValidBucketStorageMetrics(storageMetricDoc)) {
// Do not count the objects in cold for SOSAPI
bucketStorageUsed = storageMetricDoc.usedCapacity.current
+ storageMetricDoc.usedCapacity.nonCurrent
+ (storageMetricDoc.usedCapacity.currentRestoring || 0)
+ (storageMetricDoc.usedCapacity.nonCurrentRestoring || 0)
+ (storageMetricDoc.usedCapacity.currentRestored || 0)
+ (storageMetricDoc.usedCapacity.nonCurrentRestored || 0);
+ storageMetricDoc.usedCapacity.nonCurrent;
}
// read Capacity from bucket._capabilities
const { Capacity } = bucket.getCapabilities().VeeamSOSApi.CapacityInfo;
Expand Down
Loading

0 comments on commit 712edf2

Please sign in to comment.