From 95ee99d652aac08622b73a6ee55bcce88c4f7007 Mon Sep 17 00:00:00 2001 From: Mike Bryant Date: Fri, 12 May 2017 09:25:35 +0100 Subject: [PATCH 1/2] style: singular vs plural --- prog/weave-npc/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/prog/weave-npc/main.go b/prog/weave-npc/main.go index 4a2f205f..8644c191 100644 --- a/prog/weave-npc/main.go +++ b/prog/weave-npc/main.go @@ -91,7 +91,7 @@ func resetIPSets(ips ipset.Interface) error { common.Log.Debugf("Got list of ipsets: %v", sets) for _, s := range sets { - common.Log.Debugf("Destroying ipsets '%s'", string(s)) + common.Log.Debugf("Destroying ipset '%s'", string(s)) if err := ips.Destroy(s); err != nil { common.Log.Errorf("Failed to destroy ipset '%s'", string(s)) return err From 8668f6bb1e31f10a493c0121c3f72a15c6ac5fff Mon Sep 17 00:00:00 2001 From: Mike Bryant Date: Fri, 12 May 2017 09:27:55 +0100 Subject: [PATCH 2/2] Flush weave ipsets before destroying ipsets can't be destroyed when there are references to them. This takes the easy way out and flushes all weave ipsets first. Fixes #2915 --- prog/weave-npc/main.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/prog/weave-npc/main.go b/prog/weave-npc/main.go index 8644c191..e6818875 100644 --- a/prog/weave-npc/main.go +++ b/prog/weave-npc/main.go @@ -90,6 +90,15 @@ func resetIPSets(ips ipset.Interface) error { common.Log.Debugf("Got list of ipsets: %v", sets) + // Must remove references to ipsets by other ipsets before they're destroyed + for _, s := range sets { + common.Log.Debugf("Flushing ipset '%s'", string(s)) + if err := ips.Flush(s); err != nil { + common.Log.Errorf("Failed to flush ipset '%s'", string(s)) + return err + } + } + for _, s := range sets { common.Log.Debugf("Destroying ipset '%s'", string(s)) if err := ips.Destroy(s); err != nil {