-
Notifications
You must be signed in to change notification settings - Fork 6
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
Auto fill ippool #15
Auto fill ippool #15
Conversation
3c1d185
to
428aaee
Compare
135d4d5
to
a72fba7
Compare
Code conflicts are resolved. |
pkg/webhook/ippool/mutator.go
Outdated
ipPool := newObj.(*networkv1.IPPool) | ||
|
||
serverIP := ipPool.Spec.IPv4Config.ServerIP | ||
if err := ensureServerIP( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we update serverIP in this method, and currently the method signature makes this hard to ready. we should may be return a *string, and use nil/not nil to identify if it has been updated?
pkg/webhook/ippool/mutator.go
Outdated
return nil, fmt.Errorf(webhook.CreateErr, "IPPool", ipPool.Namespace, ipPool.Name, err) | ||
} | ||
pool := ipPool.Spec.IPv4Config.Pool | ||
if err := ensurePoolRange( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should change the method signature to make the pool object return more specific
If IPPool object is created without explicitly specified the serverIP, the start and end IP of the pool, the IPPool mutator will try to assign IPs to them. Also, if the serverIP or router is within the pool range, i.e., in between the start and end IPs, those IPs will then be marked as "RESERVED" (by the controller) and will not be allocatable. Signed-off-by: Zespre Chang <[email protected]>
a72fba7
to
b8a395a
Compare
@ibrokethecloud I've updated the method signatures to make them more explicit. PTAL, thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm. thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm!
IMPORTANT: Please do not create a Pull Request without creating an issue first.
Problem:
To successfully create the IPPool object, users must specify the pool range, i.e., the start and end IPs, and the DHCP server's IP. The reason why this is bad when it comes to user experience is that:
Solution:
Implement a mutator to automatically add the missing fields (
serverIP
,start
, andend
). Also, if theserverIP
orrouter
is within the range consisting ofstart
andend
, mark it asRESERVED
and make it not allocatable.Related Issue:
harvester/harvester#5045
Test plan:
Install harvester-vm-dhcp-controller on the Harvester cluster
Create Cluster Network (ClusterNetwork), Network Config (VlanConfig), and VM Network (NAD)
default/test-net
Create an IPPool object associated with the above-created VM Network
Check the IPPool's spec and status section, the following fields should be filled:
.spec.ipv4Config.serverIP
.spec.ipv4Config.pool.start
.spec.ipv4Config.pool.end
For example:
Note that because the
serverIP
is within the pool range (fromstart
toend
), the IP must be marked asRESERVED
under the.status.ipv4.allocated
field.