From d4fbfb8cfb5c92c329706095cdaa103ef37c9a8f Mon Sep 17 00:00:00 2001 From: nic-chen Date: Mon, 24 Oct 2022 00:24:58 +0800 Subject: [PATCH 1/2] fix: add a warning message on startup if the server name is default Signed-off-by: nic-chen --- server/etcdmain/etcd.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/server/etcdmain/etcd.go b/server/etcdmain/etcd.go index 5906cdc4614..d82019161e4 100644 --- a/server/etcdmain/etcd.go +++ b/server/etcdmain/etcd.go @@ -90,6 +90,10 @@ func startEtcdOrProxyV2(args []string) { lg.Info("failed to detect default host", zap.Error(dhErr)) } + if cfg.ec.Name == embed.DefaultName { + lg.Warn("the server is using default name, which might cause error that failed the startup.") + } + if cfg.ec.Dir == "" { cfg.ec.Dir = fmt.Sprintf("%v.etcd", cfg.ec.Name) lg.Warn( From 191fb306efe3174ccfa23d022d98d86730a94594 Mon Sep 17 00:00:00 2001 From: nic-chen Date: Thu, 27 Oct 2022 08:23:22 +0800 Subject: [PATCH 2/2] fix: apply review suggestion Signed-off-by: nic-chen --- server/embed/config.go | 9 +++++++++ server/etcdmain/etcd.go | 4 ---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/server/embed/config.go b/server/embed/config.go index 587cf642b31..080295fe0ab 100644 --- a/server/embed/config.go +++ b/server/embed/config.go @@ -765,6 +765,15 @@ func (cfg *Config) Validate() error { return fmt.Errorf("--experimental-compact-hash-check-time must be >0 (set to %v)", cfg.ExperimentalCompactHashCheckTime) } + // If `--name` isn't configured, then multiple members may have the same "default" name. + // When adding a new member with the "default" name as well, etcd may regards its peerURL + // as one additional peerURL of the existing member which has the same "default" name, + // because each member can have multiple client or peer URLs. + // Please refer to https://github.com/etcd-io/etcd/issues/13757 + if cfg.Name == DefaultName { + cfg.logger.Warn("the server is using default name, which might cause error that failed the startup.") + } + return nil } diff --git a/server/etcdmain/etcd.go b/server/etcdmain/etcd.go index d82019161e4..5906cdc4614 100644 --- a/server/etcdmain/etcd.go +++ b/server/etcdmain/etcd.go @@ -90,10 +90,6 @@ func startEtcdOrProxyV2(args []string) { lg.Info("failed to detect default host", zap.Error(dhErr)) } - if cfg.ec.Name == embed.DefaultName { - lg.Warn("the server is using default name, which might cause error that failed the startup.") - } - if cfg.ec.Dir == "" { cfg.ec.Dir = fmt.Sprintf("%v.etcd", cfg.ec.Name) lg.Warn(