mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Merge pull request #3556 from xiang90/better_error_logging
etcdmain: better logging when user forget to set initial flags
This commit is contained in:
commit
6188933c81
@ -40,7 +40,8 @@ const (
|
|||||||
clusterStateFlagNew = "new"
|
clusterStateFlagNew = "new"
|
||||||
clusterStateFlagExisting = "existing"
|
clusterStateFlagExisting = "existing"
|
||||||
|
|
||||||
defaultName = "default"
|
defaultName = "default"
|
||||||
|
defaultInitialAdvertisePeerURLs = "http://localhost:2380,http://localhost:7001"
|
||||||
|
|
||||||
// maxElectionMs specifies the maximum value of election timeout.
|
// maxElectionMs specifies the maximum value of election timeout.
|
||||||
// More details are listed in ../Documentation/tuning.md#time-parameters.
|
// More details are listed in ../Documentation/tuning.md#time-parameters.
|
||||||
@ -162,7 +163,7 @@ func NewConfig() *config {
|
|||||||
fs.UintVar(&cfg.ElectionMs, "election-timeout", 1000, "Time (in milliseconds) for an election to timeout.")
|
fs.UintVar(&cfg.ElectionMs, "election-timeout", 1000, "Time (in milliseconds) for an election to timeout.")
|
||||||
|
|
||||||
// clustering
|
// clustering
|
||||||
fs.Var(flags.NewURLsValue("http://localhost:2380,http://localhost:7001"), "initial-advertise-peer-urls", "List of this member's peer URLs to advertise to the rest of the cluster")
|
fs.Var(flags.NewURLsValue(defaultInitialAdvertisePeerURLs), "initial-advertise-peer-urls", "List of this member's peer URLs to advertise to the rest of the cluster")
|
||||||
fs.Var(flags.NewURLsValue("http://localhost:2379,http://localhost:4001"), "advertise-client-urls", "List of this member's client URLs to advertise to the rest of the cluster")
|
fs.Var(flags.NewURLsValue("http://localhost:2379,http://localhost:4001"), "advertise-client-urls", "List of this member's client URLs to advertise to the rest of the cluster")
|
||||||
fs.StringVar(&cfg.durl, "discovery", "", "Discovery service used to bootstrap the initial cluster")
|
fs.StringVar(&cfg.durl, "discovery", "", "Discovery service used to bootstrap the initial cluster")
|
||||||
fs.Var(cfg.fallback, "discovery-fallback", fmt.Sprintf("Valid values include %s", strings.Join(cfg.fallback.Values, ", ")))
|
fs.Var(cfg.fallback, "discovery-fallback", fmt.Sprintf("Valid values include %s", strings.Join(cfg.fallback.Values, ", ")))
|
||||||
|
@ -24,6 +24,7 @@ import (
|
|||||||
"path"
|
"path"
|
||||||
"reflect"
|
"reflect"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/coreos/etcd/Godeps/_workspace/src/github.com/coreos/go-systemd/daemon"
|
"github.com/coreos/etcd/Godeps/_workspace/src/github.com/coreos/go-systemd/daemon"
|
||||||
@ -146,6 +147,19 @@ func Main() {
|
|||||||
plog.Errorf("please check (cURL) the discovery token for more information.")
|
plog.Errorf("please check (cURL) the discovery token for more information.")
|
||||||
plog.Errorf("please do not reuse the discovery token and generate a new one to bootstrap the cluster.")
|
plog.Errorf("please do not reuse the discovery token and generate a new one to bootstrap the cluster.")
|
||||||
default:
|
default:
|
||||||
|
if strings.Contains(err.Error(), "include") && strings.Contains(err.Error(), "--initial-cluster") {
|
||||||
|
plog.Infof("%v", err)
|
||||||
|
if cfg.initialCluster == initialClusterFromName(cfg.name) {
|
||||||
|
plog.Infof("forgot to set --initial-cluster flag?")
|
||||||
|
}
|
||||||
|
if types.URLs(cfg.apurls).String() == defaultInitialAdvertisePeerURLs {
|
||||||
|
plog.Infof("forgot to set --initial-advertise-peer-urls flag?")
|
||||||
|
}
|
||||||
|
if cfg.initialCluster == initialClusterFromName(cfg.name) && len(cfg.durl) == 0 {
|
||||||
|
plog.Infof("if you want to use discovery service, please set --discovery flag.")
|
||||||
|
}
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
plog.Fatalf("%v", err)
|
plog.Fatalf("%v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -102,7 +102,7 @@ func (c *ServerConfig) verifyLocalMember(strict bool) error {
|
|||||||
urls.Sort()
|
urls.Sort()
|
||||||
if strict {
|
if strict {
|
||||||
if !netutil.URLStringsEqual(apurls, urls.StringSlice()) {
|
if !netutil.URLStringsEqual(apurls, urls.StringSlice()) {
|
||||||
return fmt.Errorf("advertise URLs of %q do not match in --initial-advertise-peer-urls %s and --initial-cluster %s", c.Name, apurls, urls.StringSlice())
|
return fmt.Errorf("--initial-cluster must include %s=%s given --initial-advertise-peer-urls=%s", c.Name, apurls, apurls)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
Loading…
x
Reference in New Issue
Block a user