From a6b0405480d1e7541d9c60cf5ee52fd6051f9088 Mon Sep 17 00:00:00 2001 From: bprashanth Date: Mon, 9 Jan 2017 07:53:44 -0800 Subject: [PATCH] Move IG GC out of backend pool and into cluster manager --- controllers/gce/backends/backends.go | 6 ------ controllers/gce/controller/cluster_manager.go | 13 ++++++++++++- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/controllers/gce/backends/backends.go b/controllers/gce/backends/backends.go index 11f1188d1..18686b968 100644 --- a/controllers/gce/backends/backends.go +++ b/controllers/gce/backends/backends.go @@ -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 } diff --git a/controllers/gce/controller/cluster_manager.go b/controllers/gce/controller/cluster_manager.go index dec9994a5..c16ddb709 100644 --- a/controllers/gce/controller/cluster_manager.go +++ b/controllers/gce/controller/cluster_manager.go @@ -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 }