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)
pull/6/head
Angus Lees 2015-06-05 16:27:45 +10:00
parent 9394635cc0
commit 75f49b331a
1 changed files with 7 additions and 3 deletions

View File

@ -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, Name: name,
Description: fmt.Sprintf("Kubernetes external service %s", name), Description: fmt.Sprintf("Kubernetes external service %s", name),
Address: externalIP.String(),
Protocol: "TCP", Protocol: "TCP",
ProtocolPort: ports[0].Port, //TODO: need to handle multi-port ProtocolPort: ports[0].Port, //TODO: need to handle multi-port
PoolID: pool.ID, PoolID: pool.ID,
Persistence: persistence, Persistence: persistence,
}).Extract() }
if !externalIP.IsUnspecified() {
createOpts.Address = externalIP.String()
}
vip, err := vips.Create(lb.network, createOpts).Extract()
if err != nil { if err != nil {
if mon != nil { if mon != nil {
monitors.Delete(lb.network, mon.ID) monitors.Delete(lb.network, mon.ID)