Skip to content
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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Conversation

abhinavnagaraj
Copy link

@abhinavnagaraj abhinavnagaraj commented Jul 1, 2020

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:


@abhinavnagaraj abhinavnagaraj requested a review from jzhoucliqr July 1, 2020 18:23
jzhoucliqr
jzhoucliqr previously approved these changes Jul 1, 2020
@@ -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)

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.

if dev.DHCP4 || dev.DHCP6 {
return false
} else {
if len(dev.Gateway4) <= 0 || len(dev.IPAddrs) <= 0 {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is Gateway6 check needed?

Copy link
Author

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.

Copy link
Author

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.

@jzhoucliqr
Copy link

ignore the approve, we should not merge.

@abhinavnagaraj abhinavnagaraj changed the title wait for static ip allocation [WIP] wait for static ip allocation Jul 1, 2020
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 {

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants