Flexibilize public IP selection
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)
- [x] 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
- [x] Minor
How Has This Been Tested?
I made the following tests:
| N° | 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 |
Codecov Report
:x: Patch coverage is 10.00000% with 54 lines in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 16.57%. Comparing base (7632814) to head (707c02b).
:warning: Report is 532 commits behind head on main.
Additional details and impacted files
@@ Coverage Diff @@
## main #11076 +/- ##
===========================================
Coverage 16.57% 16.57%
- Complexity 13868 13987 +119
===========================================
Files 5719 5745 +26
Lines 507178 510872 +3694
Branches 61571 62141 +570
===========================================
+ Hits 84085 84698 +613
- Misses 413674 416699 +3025
- Partials 9419 9475 +56
| Flag | Coverage Δ | |
|---|---|---|
| uitests | 3.91% <ø> (-0.06%) |
:arrow_down: |
| unittests | 17.47% <10.00%> (+0.02%) |
:arrow_up: |
Flags with carried forward coverage won't be shown. Click here to find out more.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
- :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
@blueorangutan package
@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.
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 14153
@blueorangutan LLtest
@DaanHoogland a [LL] Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests
@erikbocks , do you still want to move this forwards?
Hello, @DaanHoogland
Yes, I wish to move forward with this PR. It is currently waiting for reviews.