Thanks to visit codestin.com
Credit goes to github.com

Skip to content

list only own zones for resource manager #11087

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

Draft
wants to merge 2 commits into
base: 4.20
Choose a base branch
from

Conversation

DaanHoogland
Copy link
Contributor

Description

This PR...

Fixes: #10906

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):

How Has This Been Tested?

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

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR tightens zone-level access for resource managers and applies broad Java refactoring to modernize code style.

  • Enforce per-zone permissions in listDataCentersInternal by renaming id to zoneId and invoking checkAccessAndSpecifyAuthority.
  • Remove unused imports and private methods across QueryManagerImpl, and standardize Java 7+ features (diamond operators, toArray(new T[0])).
  • Simplify API commands by dropping redundant static names/overrides and adopting diamond operators in response list declarations.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
server/src/main/java/com/cloud/api/query/QueryManagerImpl.java Enforce zone access control, remove unused code, and refactor to use diamond operators and array patterns.
api/src/main/java/org/apache/cloudstack/api/command/user/zone/ListZonesCmd.java Remove obsolete getCommandName() override and static response name.
api/src/main/java/org/apache/cloudstack/api/command/admin/pod/ListPodsByCmd.java Adopt diamond operators in ListResponse and collection initializations.
api/src/main/java/org/apache/cloudstack/api/command/admin/cluster/ListClustersCmd.java Simplify Pair constructions and apply diamond operators to list declarations.
Comments suppressed due to low confidence (2)

server/src/main/java/com/cloud/api/query/QueryManagerImpl.java:3151

  • The internal method searchForStorageTagsInternal no longer accepts the command parameter, so any filtering based on ListStorageTagsCmd fields may be skipped. Restore or pass the command to preserve expected filtering behavior.
        Pair<List<StoragePoolTagVO>, Integer> result = searchForStorageTagsInternal();

server/src/main/java/com/cloud/api/query/QueryManagerImpl.java:3192

  • The signature for searchForHostTagsInternal was changed to drop the ListHostTagsCmd argument, which likely removes filtering by command parameters. Confirm that host-tag filters are still applied or reintroduce the parameter.
        Pair<List<HostTagVO>, Integer> result = searchForHostTagsInternal();

Comment on lines 632 to 636
// TODO fix bug : id is always null from here
Long id = null;

if (caller.getType() == Account.Type.NORMAL) {
long currentId = CallContext.current().getCallingUser().getId();
if (id != null && currentId != id.longValue()) {
throw new PermissionDeniedException("Calling user is not authorized to see the user requested by id");
}
id = currentId;
id = CallContext.current().getCallingUser().getId();
Copy link
Preview

Copilot AI Jun 25, 2025

Choose a reason for hiding this comment

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

[nitpick] This TODO indicates a known issue where id is always null. Consider removing or addressing this comment by fixing the initialization logic or clarifying its intended behavior.

Copilot uses AI. Check for mistakes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

issue created for this in #11088

Comment on lines +4230 to +4231
Long zoneId = cmd.getId();
zoneId = accountMgr.checkAccessAndSpecifyAuthority(CallContext.current().getCallingAccount(), zoneId);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

for reviewer; this is the actual change. (i’ve been going overboard on cleanup during investigation)

@DaanHoogland
Copy link
Contributor Author

@blueorangutan package

@blueorangutan
Copy link

@DaanHoogland a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

@blueorangutan
Copy link

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 13913

@apache apache deleted a comment from blueorangutan Jul 2, 2025
@apache apache deleted a comment from blueorangutan Jul 2, 2025
@DaanHoogland
Copy link
Contributor Author

@blueorangutan test

@blueorangutan
Copy link

@DaanHoogland a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests

Copy link

codecov bot commented Jul 2, 2025

Codecov Report

Attention: Patch coverage is 7.21649% with 90 lines in your changes missing coverage. Please review.

Project coverage is 16.15%. Comparing base (8f2735a) to head (d1f441a).
Report is 4 commits behind head on 4.20.

Files with missing lines Patch % Lines
...ain/java/com/cloud/api/query/QueryManagerImpl.java 7.60% 82 Missing and 3 partials ⚠️
...ack/api/command/admin/cluster/ListClustersCmd.java 0.00% 3 Missing ⚠️
...loudstack/api/command/admin/pod/ListPodsByCmd.java 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##               4.20   #11087   +/-   ##
=========================================
  Coverage     16.15%   16.15%           
- Complexity    13273    13278    +5     
=========================================
  Files          5657     5657           
  Lines        497898   497892    -6     
  Branches      60374    60384   +10     
=========================================
+ Hits          80435    80445   +10     
+ Misses       408505   408481   -24     
- Partials       8958     8966    +8     
Flag Coverage Δ
uitests 4.00% <ø> (-0.01%) ⬇️
unittests 17.00% <7.21%> (+<0.01%) ⬆️

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

☔ View full report in Codecov by Sentry.
📢 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.

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.

Zones listing filtering is not being applied for dedicated domains
2 participants