diff --git a/prog/kube-peers/main.go b/prog/kube-peers/main.go index 53708d03..1b17a88f 100644 --- a/prog/kube-peers/main.go +++ b/prog/kube-peers/main.go @@ -97,7 +97,7 @@ func checkIamInPeerList(cml *configMapAnnotations, c *kubernetes.Clientset, peer // For each of those peers that is no longer listed as a node by // Kubernetes, remove it from Weave IPAM func reclaimRemovedPeers(weave *weaveapi.Client, cml *configMapAnnotations, nodes []nodeInfo, myPeerName string) error { - for { + for loopsWhenNothingChanged := 0; loopsWhenNothingChanged < 3; loopsWhenNothingChanged++ { if err := cml.Init(); err != nil { return err } @@ -144,6 +144,7 @@ func reclaimRemovedPeers(weave *weaveapi.Client, cml *configMapAnnotations, node if err != nil { return err } + loopsWhenNothingChanged = 0 cml.LoopUpdate(func() error { // 7aa. Remove any annotations Z* that have contents X if err := cml.RemoveAnnotationsWithValue(peer.PeerName); err != nil { @@ -168,6 +169,7 @@ func reclaimRemovedPeers(weave *weaveapi.Client, cml *configMapAnnotations, node } // 9. Go back to step 1 until there is no difference between the two sets + // (or we hit the counter that says we've been round the loop 3 times and nothing happened) } // Question: Should we narrow step 2 by checking against Weave Net IPAM? // i.e. If peer X owns any address space and is marked unreachable, we want to rmpeer X