Merge pull request #124 from bprashanth/default_backend_ig_delete
Only delete default backend when there are no loadbalancers
This commit is contained in:
commit
717594ae2a
3 changed files with 28 additions and 12 deletions
|
@ -273,12 +273,6 @@ func (b *Backends) GC(svcNodePorts []int64) error {
|
|||
return err
|
||||
}
|
||||
}
|
||||
if len(svcNodePorts) == 0 {
|
||||
glog.Infof("Deleting instance group %v", b.namer.IGName())
|
||||
if err := b.nodePool.DeleteInstanceGroup(b.namer.IGName()); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
@ -151,7 +151,7 @@ func (c *ClusterManager) Checkpoint(lbs []*loadbalancers.L7RuntimeInfo, nodeName
|
|||
// DefaultBackend is managed in l7 pool, which doesn't understand instances,
|
||||
// which the firewall rule requires.
|
||||
fwNodePorts := nodePorts
|
||||
if len(fwNodePorts) != 0 {
|
||||
if len(lbs) != 0 {
|
||||
// If there are no Ingresses, we shouldn't be allowing traffic to the
|
||||
// default backend. Equally importantly if the cluster gets torn down
|
||||
// we shouldn't leak the firewall rule.
|
||||
|
@ -191,6 +191,17 @@ func (c *ClusterManager) GC(lbNames []string, nodePorts []int64) error {
|
|||
if beErr != nil {
|
||||
return beErr
|
||||
}
|
||||
|
||||
// TODO(ingress#120): Move this to the backend pool so it mirrors creation
|
||||
var igErr error
|
||||
if len(lbNames) == 0 {
|
||||
igName := c.ClusterNamer.IGName()
|
||||
glog.Infof("Deleting instance group %v", igName)
|
||||
igErr = c.instancePool.DeleteInstanceGroup(igName)
|
||||
}
|
||||
if igErr != nil {
|
||||
return igErr
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
@ -267,12 +267,23 @@ func (t *GCETranslator) toURLMap(ing *extensions.Ingress) (utils.GCEURLMap, erro
|
|||
}
|
||||
hostPathBackend[host] = pathToBackend
|
||||
}
|
||||
defaultBackend, _ := t.toGCEBackend(ing.Spec.Backend, ing.Namespace)
|
||||
hostPathBackend.PutDefaultBackend(defaultBackend)
|
||||
|
||||
if defaultBackend != nil && ing.Spec.Backend != nil {
|
||||
t.recorder.Eventf(ing, api.EventTypeNormal, "GCE", fmt.Sprintf("default backend set to %v:%v", ing.Spec.Backend.ServiceName, defaultBackend.Port))
|
||||
var defaultBackend *compute.BackendService
|
||||
if ing.Spec.Backend != nil {
|
||||
var err error
|
||||
defaultBackend, err = t.toGCEBackend(ing.Spec.Backend, ing.Namespace)
|
||||
if err != nil {
|
||||
msg := fmt.Sprintf("%v", err)
|
||||
if _, ok := err.(errorNodePortNotFound); ok {
|
||||
msg = fmt.Sprintf("couldn't find nodeport for %v/%v", ing.Namespace, ing.Spec.Backend.ServiceName)
|
||||
}
|
||||
t.recorder.Eventf(ing, api.EventTypeWarning, "Service", fmt.Sprintf("failed to identify user specified default backend, %v, using system default", msg))
|
||||
} else if defaultBackend != nil {
|
||||
t.recorder.Eventf(ing, api.EventTypeNormal, "Service", fmt.Sprintf("default backend set to %v:%v", ing.Spec.Backend.ServiceName, defaultBackend.Port))
|
||||
}
|
||||
} else {
|
||||
t.recorder.Eventf(ing, api.EventTypeNormal, "Service", "no user specified default backend, using system default")
|
||||
}
|
||||
hostPathBackend.PutDefaultBackend(defaultBackend)
|
||||
return hostPathBackend, nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue