-
Notifications
You must be signed in to change notification settings - Fork 295
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
🌱 Add option for non-mandatory IP/DHCP for network device #2727
🌱 Add option for non-mandatory IP/DHCP for network device #2727
Conversation
Welcome @p-strusiewiczsurmacki-mobica! |
Hi @p-strusiewiczsurmacki-mobica. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
ac11b8c
to
d5fbef4
Compare
apis/v1beta1/types.go
Outdated
|
||
// IPConfigurationNotMandatory allows for the device to not have IP address or DHCP configured. | ||
// +optional | ||
IPConfigurationNotMandatory bool `json:"ipConfigurationNotMandatory,omitempty"` |
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.
maybe we could use something a little more explicit here, e.g. skipWaitForAddress
?
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.
I think we should go into more detail at the godoc.
If this new variable gets set to true, this device gets ignored when checking for an existing ip address. And propably that at least one device should get an IP address (dunno if this is true but I can think of provisioning to fail at different places if there is no IP here)?
SkipWaitForAddress
sounds better to me but not yet perfect. No strong opinion on the name or a better recommendation from my side though...
What about: SkipIPAllocation
or IgnoreIPAllocation
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.
SkipIPAllocation
or IgnoreIPAllocation
sounds more straightforward to me. And I'm thinking perhaps adding static
is more precise, like SkipStaticIPAllocation
or IgnoreStaticIPAllocation
as we're only skipping the static IP allocation but not the DHCP allocation. WDYT?
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.
Changed the name to SkipIPAllocation
.
we're only skipping the static IP allocation but not the DHCP allocation
I think this is something I've got wrong. I've added SkipIPAllocation
check in few more places now.
I think that if user sets SkipIPAllocation
to true, no check should be performed at all.
/ok-to-test |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2727 +/- ##
==========================================
+ Coverage 63.88% 64.05% +0.17%
==========================================
Files 160 160
Lines 9345 9360 +15
==========================================
+ Hits 5970 5996 +26
+ Misses 2914 2908 -6
+ Partials 461 456 -5 ☔ View full report in Codecov by Sentry. |
controllers/vspherevm_controller.go
Outdated
@@ -473,7 +473,7 @@ func (r vmReconciler) reconcileNormal(ctx context.Context, vmCtx *capvcontext.VM | |||
func (r vmReconciler) isWaitingForStaticIPAllocation(vmCtx *capvcontext.VMContext) bool { | |||
devices := vmCtx.VSphereVM.Spec.Network.Devices | |||
for _, dev := range devices { | |||
if !dev.DHCP4 && !dev.DHCP6 && len(dev.IPAddrs) == 0 && len(dev.AddressesFromPools) == 0 { | |||
if !dev.DHCP4 && !dev.DHCP6 && len(dev.IPAddrs) == 0 && len(dev.AddressesFromPools) == 0 && !dev.IPConfigurationNotMandatory { |
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.
Can we have a comment here explaining this long if? Its hard to read and remember again.
We should also adjust the godoc of the function.
Maybe there's a way to write this function in a way so its more readable: (please check if the logic is correct)
// TODO explain
if dev.IgnoreIPAllocation {
continue
}
// TODO explain
if len(dev.IPAddrs) > 0 || len(dev.AddressesFromPools) > 0 {
continue
}
// TODO explain
if dev.DHCP4 || dev.DHCP6 {
continue
}
// TODO explain
return true
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.
I've split this if statement into 3 separate statements as by tour suggestion.
apis/v1beta1/types.go
Outdated
|
||
// IPConfigurationNotMandatory allows for the device to not have IP address or DHCP configured. | ||
// +optional | ||
IPConfigurationNotMandatory bool `json:"ipConfigurationNotMandatory,omitempty"` |
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.
I think we should go into more detail at the godoc.
If this new variable gets set to true, this device gets ignored when checking for an existing ip address. And propably that at least one device should get an IP address (dunno if this is true but I can think of provisioning to fail at different places if there is no IP here)?
SkipWaitForAddress
sounds better to me but not yet perfect. No strong opinion on the name or a better recommendation from my side though...
What about: SkipIPAllocation
or IgnoreIPAllocation
@chrischdi I've tried to add some more details into this godoc comment. Hope it will be OK now. |
Looks like some generated code needs to get regenerated. Thanks for tackling this. I'll try to come back to this tomorrow. |
That's weird, because I've run EDIT: I've force-pushed those once again and it seems to be ok. Maybe CI did not get the last commit. |
f384759
to
2f8fb02
Compare
Signed-off-by: Patryk Strusiewicz-Surmacki <patryk-pawel.strusiewicz-surmacki@external.telekom.de>
Signed-off-by: Patryk Strusiewicz-Surmacki <patryk-pawel.strusiewicz-surmacki@external.telekom.de>
Signed-off-by: Patryk Strusiewicz-Surmacki <patryk-pawel.strusiewicz-surmacki@external.telekom.de>
2f8fb02
to
1b9a82f
Compare
Signed-off-by: Patryk Strusiewicz-Surmacki <patryk-pawel.strusiewicz-surmacki@external.telekom.de>
pkg/services/govmomi/util.go
Outdated
@@ -457,6 +457,11 @@ func waitForIPAddresses( | |||
// Look at each IP and determine whether a reconcile has | |||
// been triggered for the IP. | |||
for _, discoveredIPInfo := range nic.IpConfig.IpAddress { | |||
// Ignore device if SkipIPAllocation is set. | |||
if deviceSpec.SkipIPAllocation { |
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.
Not sure if we want to run continue in this first case. Wouldn't this also skip discovering if IP Addresses get set on this interface?
If so, we should add it to the description that IPs for this device don't get bubbled up.
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.
I think you're right. Even if there is IP address discovered but the device has no static IP or DHCP configured, the discovered address will be skipped anyway.
Deleted this if statement.
pkg/util/machines.go
Outdated
@@ -109,10 +109,21 @@ func GetMachineMetadata(hostname string, vsphereVM infrav1.VSphereVM, ipamState | |||
devices[i].Gateway6 = state.Gateway6 | |||
} | |||
|
|||
// Ignore device if SkipIPAllocation is set |
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.
Can we add why we want to skip this device here? What impact has that?
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.
After some consideration I think it's not really necessary. If the device has no static IP address or DHCP configured, then waitForIPv4
and waitForIPv6
should be false
anyway.
pkg/util/machines.go
Outdated
if waitForIPv4 && waitForIPv6 { | ||
// break early as we already wait for ipv4 and ipv6 | ||
continue | ||
} | ||
|
||
if vsphereVM.Spec.Network.Devices[i].SkipIPAllocation { |
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.
duplicate to above?
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.
Deleted that.
Co-authored-by: Christian Schlotter <chrischdi@users.noreply.github.com>
Signed-off-by: Patryk Strusiewicz-Surmacki <patryk-pawel.strusiewicz-surmacki@external.telekom.de>
4582c46
to
2f50975
Compare
apis/v1beta1/types.go
Outdated
// If true, both static IP address allocation and DHCP allocation will be skipped, | ||
// and provider will not verify IP address allocation. |
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.
Sorry for nitpicking here, but this may not be entirely true?
CAPV will only not verify IP address allocation. The vm itself may still doe static IP configuration or DHCP allocation (depending on the other configuration)
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.
Changed that to
// If true, CAPV will not verify IP address allocation.
Signed-off-by: Patryk Strusiewicz-Surmacki <patryk-pawel.strusiewicz-surmacki@external.telekom.de>
52a634f
to
b020650
Compare
/test help |
@chrischdi: The specified target(s) for
The following commands are available to trigger optional jobs:
Use
In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/test pull-cluster-api-provider-vsphere-e2e-conformance-ci-latest-main |
/test pull-cluster-api-provider-vsphere-e2e-conformance-main |
/test pull-cluster-api-provider-vsphere-e2e-main |
/test pull-cluster-api-provider-vsphere-e2e-upgrade-1-29-1-30-main |
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
@schrej could you maybe give this another look in its final state :-)
LGTM label has been added. Git tree hash: 1fcc6b6fed9e860a93895d30b9198608f06e1e40
|
lgtm! Thanks @p-strusiewiczsurmacki-mobica 🎉 |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: chrischdi The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
What this PR does / why we need it:
This PR introduces
ipConfigurationNotMandatory
for for network device configuration (deviceSpec
). If settrue
controller should not wait for IP address allocation for this network device.Which issue(s) this PR fixes:
Fixes #2721