From 3559fcf3b360fdf6e5c547f5878694b1e37826ef Mon Sep 17 00:00:00 2001 From: Leo Antunes Date: Sat, 6 Jul 2019 22:41:58 +0200 Subject: [PATCH] also skip /etc/hosts on termination if disabled --- main.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index a58be3a..2658172 100644 --- a/main.go +++ b/main.go @@ -45,6 +45,7 @@ func main() { incomingSigs := make(chan os.Signal, 1) signal.Notify(incomingSigs, syscall.SIGTERM, os.Interrupt) + logrus.Debug("waiting for cluster events") for { select { case nodes := <-nodec: @@ -71,8 +72,10 @@ func main() { case <-incomingSigs: logrus.Info("terminating...") cluster.leave() - if err := writeToEtcHosts(nil); err != nil { - logrus.Errorf("could not remove stale hosts entries: %s", err) + if !config.NoEtcHosts { + if err := writeToEtcHosts(nil); err != nil { + logrus.Errorf("could not remove stale hosts entries: %s", err) + } } if err := wg.downInterface(); err != nil { logrus.Errorf("could not down interface: %s", err)