From 543800a6bfdfc7485c7f466e11b0f569b0a8d971 Mon Sep 17 00:00:00 2001 From: Gyu-Ho Lee Date: Mon, 20 Mar 2017 15:41:29 -0700 Subject: [PATCH] etcdmain: handle StopNotify when ErrStopped aborted publish Fix https://github.com/coreos/etcd/issues/7512. If a server starts and aborts due to config error, it is possible to get stuck in ReadyNotify waits. This adds select case to get notified on stop channel. Signed-off-by: Gyu-Ho Lee --- etcdmain/etcd.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/etcdmain/etcd.go b/etcdmain/etcd.go index 236755eaf784..01acac3a1eb2 100644 --- a/etcdmain/etcd.go +++ b/etcdmain/etcd.go @@ -189,7 +189,11 @@ func startEtcd(cfg *embed.Config) (<-chan struct{}, <-chan error, error) { return nil, nil, err } osutil.RegisterInterruptHandler(e.Server.Stop) - <-e.Server.ReadyNotify() // wait for e.Server to join the cluster + select { + case <-e.Server.ReadyNotify(): // wait for e.Server to join the cluster + case <-e.Server.StopNotify(): // publish aborted from 'ErrStopped' + e.Server.HardStop() + } return e.Server.StopNotify(), e.Err(), nil }