From 75f49b331aa64b441c1de92fbd137bd0eb221468 Mon Sep 17 00:00:00 2001 From: Angus Lees Date: Fri, 5 Jun 2015 16:27:45 +1000 Subject: [PATCH] Ignore "unspecified" externalIP during LB create Previously we always passed `Address: externalIP.String()` while creating a loadbalancer VIP. This passed "0.0.0.0" when externalIP was unspecified, effectively making it mandatory to specify an externalIP. This change correctly leaves `Address` unspecified when externalIP is unspecified (has a zero value). (Thanks to @justinsb for the report) --- pkg/cloudprovider/openstack/openstack.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pkg/cloudprovider/openstack/openstack.go b/pkg/cloudprovider/openstack/openstack.go index fb6030cc49..38520b28e7 100644 --- a/pkg/cloudprovider/openstack/openstack.go +++ b/pkg/cloudprovider/openstack/openstack.go @@ -607,15 +607,19 @@ func (lb *LoadBalancer) CreateTCPLoadBalancer(name, region string, externalIP ne } } - vip, err := vips.Create(lb.network, vips.CreateOpts{ + createOpts := vips.CreateOpts{ Name: name, Description: fmt.Sprintf("Kubernetes external service %s", name), - Address: externalIP.String(), Protocol: "TCP", ProtocolPort: ports[0].Port, //TODO: need to handle multi-port PoolID: pool.ID, Persistence: persistence, - }).Extract() + } + if !externalIP.IsUnspecified() { + createOpts.Address = externalIP.String() + } + + vip, err := vips.Create(lb.network, createOpts).Extract() if err != nil { if mon != nil { monitors.Delete(lb.network, mon.ID)