Skip to content

server: allow user to list available IPs on shared networks#7898

Merged
yadvr merged 1 commit intoapache:4.18from
weizhouapache:4.18-user-list-shared-network-ips
Aug 24, 2023
Merged

server: allow user to list available IPs on shared networks#7898
yadvr merged 1 commit intoapache:4.18from
weizhouapache:4.18-user-list-shared-network-ips

Conversation

@weizhouapache
Copy link
Copy Markdown
Member

@weizhouapache weizhouapache commented Aug 23, 2023

Description

This fixes #7817

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)

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?

  • deploy vm with specific IP
  • change nic IP address to specific IP
  • add specific IP as secondary IP

"Set placement of vrouter ips in redundant mode in vpc tiers, this can be 3 value: `first` to use first ips in tiers, `last` to use last ips in tiers and `random` to take random ips in tiers.",
true, ConfigKey.Scope.Account, null, null, null, null, null, ConfigKey.Kind.Select, "first,last,random");

ConfigKey<Boolean> AllowUserListAvailableIpsOnSharedNetwork = new ConfigKey<Boolean>("Advanced", Boolean.class, "allow.user.list.available.ips.on.shared.network", "false",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could this be setup to true by default; it's because users can already see public IPs say in an isolated network or VPC. Only stricter env can disable it.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Also worth testing in the UI -> that users can select shared network IP when adding NIC for example, or deploy a VM? cc @kiranchavala

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@rohityadavcloud
some cloud providers might dislike it (as true) , for security reasons.

the UI changes requires some other changes, as normal users cannot list the global setting . we need to add it as a capability of the platform.

Copy link
Copy Markdown
Member

@yadvr yadvr left a comment

Choose a reason for hiding this comment

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

LGTM - but needs testing

@codecov
Copy link
Copy Markdown

codecov bot commented Aug 23, 2023

Codecov Report

Merging #7898 (6b292b7) into 4.18 (0e9a19f) will decrease coverage by 0.01%.
Report is 4 commits behind head on 4.18.
The diff coverage is 7.69%.

@@             Coverage Diff              @@
##               4.18    #7898      +/-   ##
============================================
- Coverage     13.06%   13.05%   -0.01%     
  Complexity     9083     9083              
============================================
  Files          2720     2720              
  Lines        257289   257381      +92     
  Branches      40116    40126      +10     
============================================
+ Hits          33610    33613       +3     
- Misses       219458   219547      +89     
  Partials       4221     4221              
Files Changed Coverage Δ
...n/java/com/cloud/network/IpAddressManagerImpl.java 3.24% <0.00%> (ø)
...in/java/com/cloud/server/ManagementServerImpl.java 5.64% <0.00%> (-0.01%) ⬇️
.../main/java/com/cloud/network/IpAddressManager.java 100.00% <100.00%> (ø)

... and 6 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@weizhouapache
Copy link
Copy Markdown
Member Author

@blueorangutan package

@blueorangutan
Copy link
Copy Markdown

@weizhouapache a [SF] 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.

@yadvr
Copy link
Copy Markdown
Member

yadvr commented Aug 23, 2023

@weizhouapache have you tested, if say once a user lists and find a free IP address - does deployVM and add nic to network APIs honour user-supplied public IP address?

@weizhouapache
Copy link
Copy Markdown
Member Author

@weizhouapache have you tested, if say once a user lists and find a free IP address - does deployVM and add nic to network APIs honour user-supplied public IP address?

@rohityadavcloud
As I remember, it worked before. I will confirm it.

@DaanHoogland
Copy link
Copy Markdown
Contributor

@blueorangutan test keepEnv

@blueorangutan
Copy link
Copy Markdown

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

@blueorangutan
Copy link
Copy Markdown

[SF] Trillian test result (tid-7526)
Environment: kvm-centos7 (x2), Advanced Networking with Mgmt server 7
Total time taken: 40760 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr7898-t7526-kvm-centos7.zip
Smoke tests completed. 107 look OK, 1 have errors, 0 did not run
Only failed and skipped tests results shown below:

Test Result Time (s) Test File
test_11_destroy_ssvm Error 3.18 test_ssvm.py

@weizhouapache
Copy link
Copy Markdown
Member Author

@weizhouapache have you tested, if say once a user lists and find a free IP address - does deployVM and add nic to network APIs honour user-supplied public IP address?

@rohityadavcloud As I remember, it worked before. I will confirm it.

@rohityadavcloud
tested the following action with specified IP, all work well

  • deploy vm with specific IP
  • change nic IP address to specific IP
  • add specific IP as secondary IP

@weizhouapache weizhouapache marked this pull request as ready for review August 24, 2023 06:36
@yadvr
Copy link
Copy Markdown
Member

yadvr commented Aug 24, 2023

Excellent thanks @weizhouapache let's go ahead and merge this once it meets enought reviews; cc @DaanHoogland

@yadvr yadvr requested a review from DaanHoogland August 24, 2023 07:40
Copy link
Copy Markdown
Member

@harikrishna-patnala harikrishna-patnala left a comment

Choose a reason for hiding this comment

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

Code LGTM

Comment on lines +2479 to +2490
} else if (vlanType == VlanType.DirectAttached && network != null && !isAllocatedTemp && isAllocated) {
if (caller.getType() != Account.Type.ADMIN && !IpAddressManager.AllowUserListAvailableIpsOnSharedNetwork.value()) {
s_logger.debug("Non-admin users are not allowed to list available IPs on shared networks");
} else {
final SearchBuilder<IPAddressVO> searchBuilder = _publicIpAddressDao.createSearchBuilder();
buildParameters(searchBuilder, cmd, false);

SearchCriteria<IPAddressVO> searchCriteria = searchBuilder.create();
setParameters(searchCriteria, cmd, vlanType, false);
searchCriteria.setParameters("state", IpAddress.State.Free.name());
addrs.addAll(_publicIpAddressDao.search(searchCriteria, searchFilter)); // Free IPs on shared network
}
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.

can we move this to a separate method, and the inner else-clause to the Dao?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@DaanHoogland
moving to Dao seems difficult, as this code block calls two methods to build and set search parameters: buildParameters and setParameters

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.

all done in searchForIpAddresses. this is out off scope but definitely needs factoring.

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.

Allow users to see free IPs in a shared network

5 participants