From 23a827088b12e7639ae1db0c3b675554f91f9172 Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Tue, 4 Aug 2020 14:31:28 +0000 Subject: [PATCH] Remove unused stopChan --- prog/weave-npc/main.go | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/prog/weave-npc/main.go b/prog/weave-npc/main.go index efd6af13ed..79909a24fb 100644 --- a/prog/weave-npc/main.go +++ b/prog/weave-npc/main.go @@ -216,17 +216,14 @@ func hCtx() context.Context { return context.Background() } -func stopOnPanicRecover(stopChan chan struct{}) { +func stopOnPanicRecover() { if r := recover(); r != nil { os.Exit(1) } } func root(cmd *cobra.Command, args []string) { - var ( - npController cache.Controller - stopChan chan struct{} - ) + var npController cache.Controller common.SetLogLevel(logLevel) if nodeName == "" { @@ -266,11 +263,11 @@ func root(cmd *cobra.Command, args []string) { nsController := makeController(client.CoreV1().RESTClient(), "namespaces", &coreapi.Namespace{}, cache.ResourceEventHandlerFuncs{ AddFunc: func(obj interface{}) { - defer stopOnPanicRecover(stopChan) + defer stopOnPanicRecover() handleError(npc.AddNamespace(hCtx(), obj.(*coreapi.Namespace))) }, DeleteFunc: func(obj interface{}) { - defer stopOnPanicRecover(stopChan) + defer stopOnPanicRecover() switch obj := obj.(type) { case *coreapi.Namespace: handleError(npc.DeleteNamespace(hCtx(), obj)) @@ -282,18 +279,18 @@ func root(cmd *cobra.Command, args []string) { } }, UpdateFunc: func(old, new interface{}) { - defer stopOnPanicRecover(stopChan) + defer stopOnPanicRecover() handleError(npc.UpdateNamespace(hCtx(), old.(*coreapi.Namespace), new.(*coreapi.Namespace))) }}) podController := makeController(client.CoreV1().RESTClient(), "pods", &coreapi.Pod{}, cache.ResourceEventHandlerFuncs{ AddFunc: func(obj interface{}) { - defer stopOnPanicRecover(stopChan) + defer stopOnPanicRecover() handleError(npc.AddPod(hCtx(), obj.(*coreapi.Pod))) }, DeleteFunc: func(obj interface{}) { - defer stopOnPanicRecover(stopChan) + defer stopOnPanicRecover() switch obj := obj.(type) { case *coreapi.Pod: handleError(npc.DeletePod(hCtx(), obj)) @@ -305,17 +302,17 @@ func root(cmd *cobra.Command, args []string) { } }, UpdateFunc: func(old, new interface{}) { - defer stopOnPanicRecover(stopChan) + defer stopOnPanicRecover() handleError(npc.UpdatePod(hCtx(), old.(*coreapi.Pod), new.(*coreapi.Pod))) }}) npHandlers := cache.ResourceEventHandlerFuncs{ AddFunc: func(obj interface{}) { - defer stopOnPanicRecover(stopChan) + defer stopOnPanicRecover() handleError(npc.AddNetworkPolicy(hCtx(), obj)) }, DeleteFunc: func(obj interface{}) { - defer stopOnPanicRecover(stopChan) + defer stopOnPanicRecover() switch obj := obj.(type) { case cache.DeletedFinalStateUnknown: // We know this object has gone away, but its final state is no longer @@ -327,7 +324,7 @@ func root(cmd *cobra.Command, args []string) { } }, UpdateFunc: func(old, new interface{}) { - defer stopOnPanicRecover(stopChan) + defer stopOnPanicRecover() handleError(npc.UpdateNetworkPolicy(hCtx(), old, new)) }, }