Merge pull request #3173 from weaveworks/reclaim-tweaks

Rearrange peer reclaim checks in weave-kube launch script
This commit is contained in:
Bryan Boreham authored and GitHub committed 2017-11-16 17:05:46 +00:00
commit bee1c44859
2 files changed
+10 -10

No files matched your search

+2 -2
View File
@@ -79,7 +79,6 @@ func addMyselfToPeerList(cml *configMapAnnotations, c *kubernetes.Clientset, pee
}
return nil
})
common.Log.Infoln("[kube-peers] Added myself to peer list", list)
return list, err
}
@@ -216,10 +215,11 @@ func main() {
if justReclaim {
cml := newConfigMapAnnotations(configMapNamespace, configMapName, c)
_, err := addMyselfToPeerList(cml, c, peerName, nodeName)
list, err := addMyselfToPeerList(cml, c, peerName, nodeName)
if err != nil {
common.Log.Fatalf("[kube-peers] Could not update peer list: %v", err)
}
common.Log.Infoln("[kube-peers] Added myself to peer list", list)
weave := weaveapi.NewClient(os.Getenv("WEAVE_HTTP_ADDR"), common.Log)
err = reclaimRemovedPeers(weave, cml, peers, peerName)
+8 -8
View File
@@ -95,13 +95,12 @@ if [ -z "$PEERNAME" ]; then
exit 2
fi
# Check if peer reclaim is in use - we don't want to delete persisted data on an upgrade
if /usr/bin/weaveutil get-db-flag "$DB_PREFIX" peer-reclaim >/dev/null ; then
# If this peer name is not stored in the list, either we are a
# brand-new peer or we were removed by another peer while temporarily
# absent. In order to avoid a CRDT clash for the latter case, clean up
if /home/weave/kube-peers -check-peer-new -peer-name="$PEERNAME" -log-level=debug ; then
if [ -f ${DB_PREFIX}data.db ]; then
# If we have persisted data and peer reclaim is in use
if [ -f ${DB_PREFIX}data.db ]; then
if /usr/bin/weaveutil get-db-flag "$DB_PREFIX" peer-reclaim >/dev/null ; then
# If this peer name is not stored in the list then we were removed by another peer.
if /home/weave/kube-peers -check-peer-new -peer-name="$PEERNAME" -log-level=debug ; then
# In order to avoid a CRDT clash, clean up
echo "Peer not in list; removing persisted data" >&2
rm -f ${DB_PREFIX}data.db
fi
@@ -133,7 +132,8 @@ post_start_actions() {
export HOST_ROOT
/home/weave/weave --local setup-cni
/home/weave/kube-peers -reclaim -node-name="$HOSTNAME" -peer-name="$PEERNAME" -log-level=debug
# Attempt to run the reclaim process, but don't halt the script if it fails
/home/weave/kube-peers -reclaim -node-name="$HOSTNAME" -peer-name="$PEERNAME" -log-level=debug || true
# Expose the weave network so host processes can communicate with pods
/home/weave/weave --local expose $WEAVE_EXPOSE_IP