-
Notifications
You must be signed in to change notification settings - Fork 1
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
[WIP] wait for static ip allocation #2
base: master
Are you sure you want to change the base?
Conversation
controllers/vspherevm_controller.go
Outdated
@@ -307,6 +307,11 @@ func (r vmReconciler) reconcileNormal(ctx *context.VMContext) (reconcile.Result, | |||
// TODO(akutz) Implement selection of VM service based on vSphere version | |||
var vmService services.VirtualMachineService = &govmomi.VMService{} | |||
|
|||
if r.isWaitingForStaticIPAllocation(ctx) { | |||
r.Logger.Info("vm is waiting for static ip to be available", "namespace", ctx.VSphereVM.Namespace, "name", ctx.VSphereVM.Name) |
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.
use ctx.Logger which already have namespace/name.
controllers/vspherevm_controller.go
Outdated
if dev.DHCP4 || dev.DHCP6 { | ||
return false | ||
} else { | ||
if len(dev.Gateway4) <= 0 || len(dev.IPAddrs) <= 0 { |
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.
is Gateway6 check needed?
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.
Ack. The 2 gateways are required when the respective DHCP flags are false.
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.
At this point we don't know if IPAddrs has ipv4 or ipv6. So we cant determine which specific gateway(4/6) needs to be available. May be the gateway check is not required here.
ignore the approve, we should not merge. |
controllers/vspherevm_controller.go
Outdated
if dev.DHCP4 || dev.DHCP6 { | ||
return false | ||
} else { | ||
if (!dev.DHCP4 && len(dev.Gateway4) <= 0) || (!dev.DHCP6 && len(dev.Gateway6) <= 0) || len(dev.IPAddrs) <= 0 { |
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.
should it be len()<= 0 ? or just len()==0 is enough?
What this PR does / why we need it:
CAPV has support to assign static IP to VSphereMachine, but the static IP itself can be assigned by different means. For eg., one such implementation can be using a third party controller to modify VSphereMachine to add static IP after the object is created.
Irrespective of the implementation choice to assign static IP, if DHCP is disabled, the CAPV controllers have to wait for static IPs to be available and then continue to provision VMs.
Currently, if both DHCP4 and DHCP6 are disabled and a staticIP is set in HAProxyLB's Network.Devices.IpAddrs, the VSphereVM for HAProxyLB goes to 'Ready' without any IPAddress in the status. The HAProxyLB then never goes to 'Ready' since its indefinitely waiting for the VSphereVM's IPAddress.
This PR checks if both DHCP4 and DHCP6 are disabled for all network devices(NetworkSpec.devices) and if there is no static IP provided in the IPAddrs list, then the CAPV controllers wait for the static IP to be available/assigned.
This PR also makes sure the VSphereVM is set to 'Ready' only after network is reconciled.
Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when PR gets merged):Fixes #
Special notes for your reviewer:
Please confirm that if this PR changes any image versions, then that's the sole change this PR makes.
Release note: