Skip to content

Flexibilize public IP selection #11076

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

erikbocks
Copy link
Contributor

Description

Currently, when a public IP allocation request is made, the quarantined_ips table is ignored during the selection process. Instead, the system selects an IP without checking its quarantine status, and only validates if the IP is quarantined afterward, throwing an exception if it is.

This causes repeated failures for automatic IP selections, as the same IP will be chosen over and over, until the quarantine period ends.

This PR fixes this behaviour by considering the quarantined_ips table during the selection process, and choosing only an allocatable IP. It also brings a minor improvement to the IP quarantine logic, where IPs that were not removed either in active quarantine, were not set removed when allocated.

Now, when these IPs are allocated, the removed column is updated and the removal reason is set to: IP was removed from quarantine because it was no longer in quarantine. The PR also does a little code refactor, improving its legibility and dropping the usage of deprecated methods.

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

How Has This Been Tested?

I made the following tests:

Test case Result Expected? (Y/N)
1 Allocate an IP to a VR IP was allocated successfully Y
2 Allocate an IP to a System VM IP was allocated successfully Y
3 Allocate a specific IP to a VR IP was allocated successfully Y
4 Allocate an IP to a VR, but, all the IPs are already allocated Exception was thrown displaying insufficient address capacity Y
5 Allocate a specific quarantined IP, but, its quarantine is due. IP was allocated successfully Y
6 Allocate a specific quarantined IP, but, it is in active quarantine. Exception was thrown displaying insufficient address capacity. Y
7 Allocate a specific quarantined IP, but, the caller is the previous owner IP was allocated successfully Y
8 Allocated a specific quarantined IP, but, the previous owner is different than the caller Exception was thrown displaying insufficient address capacity. Y

Copy link

codecov bot commented Jun 23, 2025

Codecov Report

Attention: Patch coverage is 10.00000% with 54 lines in your changes missing coverage. Please review.

Project coverage is 16.57%. Comparing base (7632814) to head (7c7e8cc).
Report is 40 commits behind head on main.

Files with missing lines Patch % Lines
...n/java/com/cloud/network/IpAddressManagerImpl.java 13.63% 38 Missing ⚠️
...m/cloud/network/dao/PublicIpQuarantineDaoImpl.java 0.00% 16 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main   #11076      +/-   ##
============================================
- Coverage     16.57%   16.57%   -0.01%     
- Complexity    13868    13965      +97     
============================================
  Files          5719     5743      +24     
  Lines        507178   510495    +3317     
  Branches      61571    62075     +504     
============================================
+ Hits          84085    84616     +531     
- Misses       413674   416417    +2743     
- Partials       9419     9462      +43     
Flag Coverage Δ
uitests 3.90% <ø> (-0.07%) ⬇️
unittests 17.47% <10.00%> (+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.

@Inject
IPAddressDao ipAddressDao;
private IPAddressDao ipAddressDao;
Copy link
Contributor

Choose a reason for hiding this comment

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

i’d prefer to keep injected fields as package scope, because it tends to trigger warnings , “privvate field never assigned”. Strictly speaking these could be private though. It would be just for preventing the warnings and the package scope helps in test cases at times as well.

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