network: custom DHCP range for isolated networks (API and UI) - #14217
Open
nagaboinaramgopal wants to merge 2 commits into
Open
nagaboinaramgopal wants to merge 2 commits into
nagaboinaramgopal wants to merge 2 commits into
Conversation
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.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.