Skip to content
This repository has been archived by the owner on Jun 20, 2024. It is now read-only.

Commit

Permalink
Break out of kube rm peers loop if nothing changes
Browse files Browse the repository at this point in the history
Avoid getting into an infinite loop if some of the logic or underlying
data is bad
  • Loading branch information
bboreham committed Jun 12, 2018
1 parent c19c64a commit ad6148f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion prog/kube-peers/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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 {
Expand All @@ -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
Expand Down

0 comments on commit ad6148f

Please sign in to comment.