Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quota UI: Adding Overall storage consumption for Super users panel page (PROJQUAY-3639) #1307

Merged
merged 1 commit into from May 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 13 additions & 0 deletions static/js/pages/superuser.js
Expand Up @@ -48,6 +48,7 @@
'TB': 1024**4,
};
$scope.quotaUnits = Object.keys($scope.disk_size_units);
$scope.registryQuota = null;

$scope.showQuotaConfig = function (org) {
if (StateService.inReadOnlyMode()) {
Expand Down Expand Up @@ -111,10 +112,22 @@
['name', 'email'], []);
};

var caclulateRegistryStorage = function () {
if (!Features.QUOTA_MANAGEMENT || !$scope.organizations) {
return;
}
let total = 0;
$scope.organizations.forEach(function (obj){
Copy link
Member

@kleesc kleesc May 9, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wondering if just doing a sum over the repositorysize table would be better. It would keep it to a single table operation, easier to cache, etc... as opposed to going through every single organization in the registry, which involves selecting from the tag and manifest tables.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i.e have a superuser specific endpoint that just does this repositorysize table aggregation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have the Quota Consumption data for every org under quota_report key. So, instead of making another API call, we are using the data the /organizations endpoint is fetching.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah ok. I guess that panel is already fetching the complete list of organization.

total += obj['quota_report']['quota_bytes'];
})
$scope.registryQuota = total;
}

$scope.loadOrganizationsInternal = function() {
$scope.organizationsResource = ApiService.listAllOrganizationsAsResource().get(function(resp) {
$scope.organizations = resp['organizations'];
sortOrgs();
caclulateRegistryStorage();
return $scope.organizations;
});
};
Expand Down
4 changes: 3 additions & 1 deletion static/partials/super-user.html
Expand Up @@ -70,7 +70,9 @@ <h3 style="margin-top: 0px;">Change Log</h3>
<cor-tab-pane id="organizations">
<div class="resource-view" resource="organizationsResource"
error-message="'Could not load organizations'">
<div class="manager-header" header-title="Organizations">
<div class="manager-header" header-title="Organizations
{{ Features.QUOTA_MANAGEMENT ? '(Total Quota Consumption: ' + bytesToHumanReadableString(registryQuota) + ')' : '' }}
">
</div>

<div class="co-top-bar">
Expand Down