Repository navigation
Conversation
|
This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #14217 +/- ##
===========================================
Coverage 20.80% 20.81%
- Complexity 20919 20933 +14
===========================================
Files 6053 6053
Lines 548451 548507 +56
Branches 78719 73289 -5430
===========================================
+ Hits 114128 114166 +38
- Misses 420958 420966 +8
- Partials 13365 13375 +10
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
a4394f9 to
f3ad009
Compare
|
This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch. |
f3ad009 to
6ba5120
Compare
|
This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch. |
6ba5120 to
590e476
Compare
|
@blueorangutan package |
|
@Damans227 a [SL] Jenkins job has been kicked to build packages. It will be bundled with no SystemVM templates. I'll keep you posted as I make progress. |
|
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 19501 |
Damans227
left a comment
There was a problem hiding this comment.
thanks @rootnomad, tested both fixes on a kvm lab and they work. LGTM
|
tested the two fixes from 1bade4b on a kvm lab. a bad range is refused and no network is left behind. shrinking with guestvmcidr is refused when the range wont fit, and works when it does. |
|
@blueorangutan test |
|
This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch. |
|
This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch. |
e79e804 to
dd9d019
Compare
DaanHoogland
left a comment
There was a problem hiding this comment.
just style remarks, clgtm
| // For an isolated guest network, an optional custom DHCP range within the CIDR that guest IPs | ||
| // are allocated from; null means the whole CIDR is used, which is the default. |
There was a problem hiding this comment.
| // For an isolated guest network, an optional custom DHCP range within the CIDR that guest IPs | |
| // are allocated from; null means the whole CIDR is used, which is the default. | |
| /** | |
| * For an isolated guest network, an optional custom DHCP range within the CIDR that guest IPs | |
| * are allocated from; null means the whole CIDR is used, which is the default. | |
| */ |
| // For an isolated network a start/end IP defines a custom DHCP range within the CIDR that guest IPs are | ||
| // allocated from; without it the whole CIDR is used, which is the default. Validate it up front so a bad | ||
| // range is rejected before the network is persisted, rather than throwing after commit and leaving an | ||
| // orphaned network. | ||
| boolean hasIsolatedDhcpRange = ntwkOff.getGuestType() == GuestType.Isolated && StringUtils.isNotBlank(startIP); | ||
| if (hasIsolatedDhcpRange) { | ||
| validateIsolatedNetworkDhcpRange(startIP, endIP, cidr, gateway); | ||
| } |
There was a problem hiding this comment.
can you extract this as a method with javadoc?
| // A custom DHCP range must stay within the reserved Guest VM CIDR; reject a reservation that would | ||
| // leave the stored range partly or wholly outside it, otherwise guest IP allocation could be starved. | ||
| if (StringUtils.isNoneBlank(network.getDhcpStartIp(), network.getDhcpEndIp())) { | ||
| long dhcpStart = NetUtils.ip2Long(network.getDhcpStartIp()); | ||
| long dhcpEnd = NetUtils.ip2Long(network.getDhcpEndIp()); | ||
| if (dhcpStart < startIp || dhcpEnd > endIp) { | ||
| throw new InvalidParameterValueException(String.format("The network has a custom DHCP range %s-%s that falls outside the requested Guest VM CIDR %s. Remove or adjust the DHCP range before applying the reservation.", | ||
| network.getDhcpStartIp(), network.getDhcpEndIp(), guestVmCidr)); | ||
| } | ||
| } |
There was a problem hiding this comment.
can you extract this as a method?
|
This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch. |
An isolated guest network allocates guest IPs from the whole CIDR, so there is no way to reserve part of the address space or restrict the DHCP pool. createNetwork already takes startip and endip, but they were only used for shared networks. This stores the start and end IP on an isolated network as a DHCP range, in two new networks columns dhcp_start_ip and dhcp_end_ip, validated to be within the network CIDR, in order, and not to include the gateway. NetworkModelImpl.getAvailableIps then restricts the guest IP pool to that range when it is set. The dnsmasq config on the VR is unchanged, since it serves the host entry CloudStack writes for the IP it allocated, so no system VM template change is needed. Without a range the whole CIDR is used, so existing networks are unaffected. The range is returned by listNetworks.
Show the start/end IP fields on the isolated network create form once a gateway is set, and surface the range on the network details tab so an operator can see and set the guest IP allocation window without the API.
… it on reservation Validate a custom isolated-network DHCP range before committing the network, so a range outside the CIDR (or reversed, or over the gateway) is rejected up front instead of throwing after the network is saved and leaving an orphaned network. The checks move into validateIsolatedNetworkDhcpRange, reused by storeIsolatedNetworkDhcpRange. Also reject an IP reservation (guestvmcidr) that would leave the stored DHCP range outside the reserved Guest VM CIDR, which would otherwise starve guest IP allocation.
dd9d019 to
dfdc7f5
Compare
|
@blueorangutan package |
|
@RosiKyu a [SL] Jenkins job has been kicked to build packages. It will be bundled with no SystemVM templates. I'll keep you posted as I make progress. |
|
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 20131 |
|
@blueorangutan test |
|
@RosiKyu a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests |
|
can we simply honor the start_ip and end_ip, instead of introducing new columns ? |
|
[SF] Trillian test result (tid-17614)
|
|
@rootnomad the smoke run on the current commit has 5 errors, and one of them is the new test from this PR: Could you please also answer @weizhouapache's question above (using the existing start_ip and end_ip instead of the new columns), and look at the 3 open review threads from @DaanHoogland? I will run the lab test once the design question is settled and the new test passes. Thank you! |
Addresses the review request not to introduce new columns. The optional custom DHCP range for an isolated network is now stored as network details (dhcpStartIp, dhcpEndIp) instead of dedicated dhcp_start_ip and dhcp_end_ip columns on the networks table, and read back from the details during guest IP allocation, on the Guest VM CIDR reservation check and when building the network response. The reservation-within-CIDR check is extracted into its own method.
|
@weizhouapache good point. Reworked in 8f911ef to drop the new columns: the custom DHCP range is now stored as network details (dhcpStartIp, dhcpEndIp) instead of the dhcp_start_ip and dhcp_end_ip columns, and read back from the details during guest IP allocation, on the Guest VM CIDR reservation check and in the network response. I kept it off the vlan IP range table on purpose, since a SourceNat isolated network creates no vlan range (it allocates guest IPs straight from the CIDR), so network details is the minimal fit without changing how isolated networks allocate. @RosiKyu the design is settled above. The new smoke test failure was a cleanup ordering bug in the test, not the feature: the asserts passed (the VM got an IP inside the custom range), it only failed in tearDown because the network was deleted before the VM. Fixed by deleting the VM first. @DaanHoogland the reservation-within-CIDR check is now extracted into its own method with javadoc. The getDhcpStartIp accessor was removed in favour of the detail keys, so that earlier javadoc suggestion no longer applies. Ready for the lab re-run. |
Description
An isolated guest network allocates guest IPs from the whole CIDR, so there is no way
to reserve part of the address space or keep the DHCP pool to a sub-range. createNetwork
already takes startip/endip, but NetworkServiceImpl only uses them for shared
networks.
This stores the start and end IP on an isolated network as a DHCP range, in two new
networks columns dhcp_start_ip/dhcp_end_ip, validated to be within the network CIDR,
in order, and not to include the gateway. NetworkModelImpl.getAvailableIps then restricts
the guest IP pool to that range when it is set; without one the whole CIDR is used, so
existing networks are unaffected.
The dnsmasq config on the VR is unchanged: for an isolated network it serves the host entry
CloudStack writes for the IP it allocated, so constraining the allocation is enough and no
system VM template change is needed. The range is returned by listNetworks as startip
and endip.
Creating an isolated network with a range needs gateway and netmask passed too
(already enforced by createNetwork), so the CIDR is deterministic. The create form shows
the start and end IP fields once a gateway is entered, and the network details tab shows the
range on an existing network, so the whole flow is usable from the UI.
Fixes: #12661
Types of changes
Feature/Enhancement Scale or Bug Severity
Feature/Enhancement Scale
Screenshots (if appropriate):


Isolated network detail showing the DHCP range, and the deployed VMs leased inside it.
How Has This Been Tested?
Unit tests in server, 101 green. NetworkModelImplTest adds two for getAvailableIps:
the pool is restricted to the range when set, and is the whole CIDR (minus the gateway)
when it is not. NetworkServiceImplTest adds five for the validation: a valid range is
stored, the end defaults to the start, and a range outside the CIDR, a start greater than
the end, or a range that includes the gateway are each rejected. DatabaseUpgradeCheckerTest
is green with the schema change. The two changed UI files pass eslint clean.
Manually on a KVM advanced zone. Created an isolated network with gateway 10.99.99.1,
netmask /24 and a DHCP range 10.99.99.10-10.99.99.20, confirmed listNetworks returned
that range, then deployed three VMs on it. All three leased inside the range
(10.99.99.14, .15, .19), where without the change they would draw from the whole /24.
How did you try to break this feature and the system with this change?
at create time.
networks and shared networks are unchanged.