Skip to content

server: report a domain's bucket, object storage and backup limits correctly - #14293

Open
stag7824 wants to merge 1 commit into
apache:4.22from
stag7824:fix-domain-bucket-objectstorage-limits
Open

stag7824 wants to merge 1 commit into
apache:4.22from
stag7824:fix-domain-bucket-objectstorage-limits

Conversation

@stag7824

@stag7824 stag7824 commented Oct 2, 2026

Copy link
Copy Markdown

Description

Fixes #13944

listDomains reports the bucket and object storage limits of every non-root domain as Unlimited, whatever has been configured. @ms30063600's re-test on #13944 shows it clearly: all 17 limits read back correctly from listResourceLimits, but the usage view (which reads listDomains) shows Bucket and Object Storage as Unlimited.

DomainJoinDaoImpl.setResourceLimits resolves those two types through the account helper:

long bucketLimit = ApiDBUtils.findCorrectResourceLimit(domain.getBucketLimit(), domain.getId(), ResourceType.bucket);
long objectStorageLimit = ApiDBUtils.findCorrectResourceLimit(domain.getObjectStorageLimit(), domain.getId(), ResourceType.object_storage);

findCorrectResourceLimit(limit, accountId, type) delegates to ResourceLimitManagerImpl.findCorrectResourceLimitForAccount, which first checks isRootAdmin(accountId) and then _accountDao.findById(accountId), returning unlimited for either. Passed a domain id, it is looking up an unrelated account — typically the root admin (account 2 vs. a domain with id 2) or nothing at all — so the configured limit is never reached. The other fifteen types in this method already use findCorrectResourceLimitForDomain; this changes the two outliers to match.

While in there, the backup rows had their unlimited checks copied from the row above:

String backupLimitDisplay = (fullView || snapshotLimit == -1) ? ...           // should be backupLimit
String backupAvail = (fullView || snapshotLimit == -1) ? ...                  // should be backupLimit
String backupStorageLimitDisplay = (fullView || backupLimit == -1) ? ...      // should be backupStorageLimit

so a domain with unlimited snapshots shows its backup limit as Unlimited, and one with unlimited backups shows its backup storage limit as Unlimited. AccountJoinDaoImpl does not have either problem.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

Feature/Enhancement Scale or Bug Severity

Bug Severity

  • Minor

How Has This Been Tested?

Added DomainJoinDaoImplTest, which calls setResourceLimits directly with ApiDBUtils stubbed (the domain lookup returns the domain's own limit; the account lookup returns unlimited, as it does in practice for a domain id) and verifies the values set on the response:

  • bucket 147 and object storage 157 GiB are reported as 147 / 157
  • backup 127 is reported while the snapshot limit is unlimited
  • backup storage 137 GiB is reported while the backup limit is unlimited
mvn test -pl server -Dtest=DomainJoinDaoImplTest
Tests run: 3, Failures: 0, Errors: 0, Skipped: 0

Without the change to DomainJoinDaoImpl, all three fail. mvn checkstyle:check -pl server reports no violations.

I do not have a live environment to check the UI against, so this is unit-level; the reporter's JSON and screenshots on #13944 are the end-to-end reproduction.

One thing I could not explain from the code: the same screenshot shows VPC as "77 Available" but "0 / 67". Both values come from the same vpcLimit variable in this method, so that mismatch does not originate here and this PR does not address it.

…rrectly

listDomains reported the bucket and object storage limits of every
non-root domain as Unlimited, whatever was configured. DomainJoinDaoImpl
resolved those two through ApiDBUtils.findCorrectResourceLimit, which is
the account variant: it looks the id up in the account table. Given a
domain id it finds either the root admin account or no account, and
answers unlimited either way. The other fifteen resource types already go
through findCorrectResourceLimitForDomain.

The backup and backup storage rows had their unlimited checks copied from
the row above: the backup limit was hidden whenever the snapshot limit was
unlimited, and the backup storage limit whenever the backup limit was.

listResourceLimits was never affected, which is why the values set
through updateResourceLimit read back correctly there and only the usage
view in the UI, which reads listDomains, showed them as Unlimited.

Fixes apache#13944

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant