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

Bad quota calculation #63

Open
solracsf opened this issue Jun 30, 2021 · 5 comments
Open

Bad quota calculation #63

solracsf opened this issue Jun 30, 2021 · 5 comments
Assignees
Labels
3. completed (being tested) Development is done. Will be merged. bug Something isn't working Design/UI

Comments

@solracsf
Copy link

solracsf commented Jun 30, 2021

  • NC 21.0.1
  • Latest master
Key Value
Quota used 7.3 GiB
Quota 57.6 TiB
Quota free 502.7 GiB
  • First row is OK
  • Second row is not OK, but as we are using a data lake, it is hard to detect the total quota... if this is the total Quota for all users, it is OK then.
  • Third row should at least detect the delta between Quota and Quota used.
@bpcurse bpcurse self-assigned this Jun 30, 2021
@bpcurse bpcurse added bug Something isn't working investigate Has to be checked/confirmed labels Jun 30, 2021
@bpcurse
Copy link
Owner

bpcurse commented Jun 30, 2021

@acsfer Thank you for reporting this issue. Could you please add the Nextcloud and Userexport Versions you used?
EDIT: From the text of the other issues I assume it is Nextcloud 21.0.1.

The calculation is pretty simple and can be found in the calculate_quota() function in functions.php

// Loop through raw user data and add quota item values to $_SESSION variables
  foreach($_SESSION['raw_user_data'] as $user_data) {

    $_SESSION['quota_total_used'] += $user_data['ocs']['data']['quota']['used'];
    $_SESSION['quota_total_free'] += $user_data['ocs']['data']['quota']['free'];

    $quota_assigned = $user_data['ocs']['data']['quota']['quota'];

    $_SESSION['quota_total_assigned'] += $quota_assigned > 0
        ? $quota_assigned
        : 0;

    $_SESSION['quota_total_assigned_infin'] = ($quota_assigned == -3);

  }

It sums up the provided API data points for all users using a foreach loop and a simple logic to deal with unlimited quota.

Second row is not OK, but as we are using a data lake, it is hard to detect the total quota... if this is the total Quota for all users, it is OK then.

Correct, this represents the total quota limit for all users. This value can be quite high in many setups and differ a lot from available disk space or factual usage.
I will change the description to make this more obvious. Do you have a proposal on how to describe it?

Third row should at least detect the delta between Quota and Quota used.

This value is also depending on the sum of the provided API responses for each user. Will investigate further how Nextcloud calculates these values.

@solracsf
Copy link
Author

IMHO, this should be :

Key Value
Quota used Total space used/consummed by all users (ex. 3Gb)
Quota Total quota set for all users (ex. 10 users x 10Gb = 100Gb)
Quota free (Row 2 - Row 1 = 97Gb )

@bpcurse bpcurse added Design/UI 2. developing 3. completed (being tested) Development is done. Will be merged. and removed investigate Has to be checked/confirmed 2. developing labels Jun 30, 2021
@bpcurse
Copy link
Owner

bpcurse commented Jun 30, 2021

I probably found the issue regarding the wrong display of "free" quota.

If users have unlimited quota set, the reported free quota seems to equal free disk space and is added to the free quota count for each of these users (can't tell for sure because my test setup is on shared hosting and this value isn't available to Nextcloud in this environment).

The solution should be to ignore free quota values in the calculation for users who are set to unlimited quota (or simply do not rely on the API response for free quota at all and do the basic math as proposed above).

@acsfer:
Can you confirm having at least one user with unlimited quota setting in your setup?
Please try to replace the files functions.php and the l10n language files with the newest version from the dev branch. This fix should address the calculation issue and reword the description on the statistics page to be less ambiguous.

@solracsf
Copy link
Author

All users have a fixed quota of 20Gb, set by LDAP.

@bpcurse
Copy link
Owner

bpcurse commented Jul 7, 2021

Postponing this until #61 is solved to be able to debug this on a "clean" userlist.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3. completed (being tested) Development is done. Will be merged. bug Something isn't working Design/UI
Projects
None yet
Development

No branches or pull requests

2 participants