Skip to content

server: fix operator precedence in the updateResourceLimit own-domain guard - #14141

Open
rootnomad wants to merge 1 commit into
apache:4.20from
rootnomad:fix/resourcelimit-admin-precedence
Open

rootnomad wants to merge 1 commit into
apache:4.20from
rootnomad:fix/resourcelimit-admin-precedence

Conversation

@rootnomad

Copy link
Copy Markdown
Collaborator

Description

The domain branch guard in updateResourceLimit is ownDomain && type == DOMAIN_ADMIN || type == RESOURCE_DOMAIN_ADMIN. Since && binds tighter than ||, a resource domain admin is denied updating the limits of every domain, including its own sub-domains ("Unable to update resource limit for domain X, permission denied"). The intent, like the account branch just above it, is only to block an admin on its own domain. This adds the missing parentheses.

Resource domain admins exist only in domains that own a private zone, so this affects those setups. The own domain rule is unchanged, and so is the own account rule discussed in #10922. The same code is on 4.20, 4.22 and main, so this targets 4.20.

Types of changes

  • Breaking change (fix or feature that would cause existing functionality to change)
  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (improves an existing feature and functionality)
  • Cleanup (Code refactoring and cleanup, that may add test cases)
  • build/CI
  • test (unit or integration test code)

Feature/Enhancement Scale or Bug Severity

Feature/Enhancement Scale

  • Major
  • Minor

Bug Severity

  • BLOCKER
  • Critical
  • Major
  • Minor
  • Trivial

Screenshots (if appropriate):

N/A

How Has This Been Tested?

Added two tests to ResourceLimitManagerImplTest: a resource domain admin updating a sub-domain (fails before with PermissionDeniedException, passes after) and the same admin on its own domain (denied before and after). The class passes (57 tests).

Also verified on a live 4.23 KVM environment with the same change: domain /rl-live with sub-domain /rl-live/rl-live-sub, and a Resource Admin account rladmin in /rl-live calling updateResourceLimit (user VMs, max 10).

Before:

rl-live-sub  531 Unable to update resource limit for domain 5, permission denied
rl-live      531 Unable to update resource limit for domain 4, permission denied

After:

rl-live-sub  200 {"resourcelimit":{"domain":"rl-live-sub",...,"max":10}}
rl-live      531 Unable to update resource limit for domain 4, permission denied

How did you try to break this feature and the system with this change?

Domain admins and root admins behave exactly as before, and both admin types are still denied on their own domain. A resource domain admin on another domain still has to pass checkAccess and the parent domain limit check, so it cannot reach domains outside its tree.

… guard

The domain branch guard parsed as (ownDomain && DOMAIN_ADMIN) ||
RESOURCE_DOMAIN_ADMIN because && binds tighter than ||, so a resource domain
admin was denied updating the limits of every domain, including sub-domains it
administers. Group the two admin types so only the caller's own domain is
rejected, the same way the account branch of the method already does.

@DaanHoogland DaanHoogland left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

clgtm, but needs testing rigorously

@rootnomad

Copy link
Copy Markdown
Collaborator Author

Thanks @DaanHoogland. Tested it both ways.

Unit on 4.20: ResourceLimitManagerImplTest is 57 tests, 0 failures with the fix. Reverting just the one-line precedence change and keeping the new tests, updateResourceLimitAllowsAResourceDomainAdminToUpdateASubdomain errors, because the old (domain match && DOMAIN_ADMIN) || RESOURCE_DOMAIN_ADMIN wrongly denied a resource domain admin updating a subdomain. The own-domain case stays denied either way.

Live on a 4.23 management server, as a resource domain admin updating a subdomain's resource limit:

  • before the fix: denied, HTTP 531, "Unable to update resource limit for domain , permission denied"
  • after the fix: allowed, the limit is set on the subdomain

Glad to add anything else you'd find useful.

@DaanHoogland DaanHoogland added this to the 4.20.4 milestone Oct 28, 2026
@rootnomad
rootnomad force-pushed the fix/resourcelimit-admin-precedence branch from 69c73a8 to 592f59e Compare December 2, 2026 16:12
@codecov

codecov Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 16.46%. Comparing base (b93f603) to head (592f59e).
⚠️ Report is 17 commits behind head on 4.20.

Files with missing lines Patch % Lines
.../cloud/resourcelimit/ResourceLimitManagerImpl.java 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##              4.20   #14141       +/-   ##
============================================
+ Coverage     4.14%   16.46%   +12.32%     
- Complexity       0    13718    +13718     
============================================
  Files          405     5670     +5265     
  Lines        33073   501771   +468698     
  Branches      5903    60965    +55062     
============================================
+ Hits          1370    82632    +81262     
- Misses       31527   409868   +378341     
- Partials       176     9271     +9095     
Flag Coverage Δ
uitests 4.16% <ø> (+0.02%) ⬆️
unittests 17.33% <0.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants