|
@@ -22,6 +22,7 @@ import (
|
|
|
"path"
|
|
"path"
|
|
|
|
|
|
|
|
"github.com/coreos/etcd/pkg/types"
|
|
"github.com/coreos/etcd/pkg/types"
|
|
|
|
|
+ "github.com/coreos/etcd/raft"
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
// ServerConfig holds the configuration of etcd as taken from the command line or discovery.
|
|
// ServerConfig holds the configuration of etcd as taken from the command line or discovery.
|
|
@@ -36,14 +37,21 @@ type ServerConfig struct {
|
|
|
Transport *http.Transport
|
|
Transport *http.Transport
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// Verify sanity-checks the config struct and returns an error for things that
|
|
|
|
|
-// should never happen.
|
|
|
|
|
-func (c *ServerConfig) Verify() error {
|
|
|
|
|
|
|
+// VerifyBootstrapConfig sanity-checks the initial config and returns an error
|
|
|
|
|
+// for things that should never happen.
|
|
|
|
|
+func (c *ServerConfig) VerifyBootstrapConfig() error {
|
|
|
|
|
+ if c.DiscoveryURL == "" && c.ClusterState != ClusterStateValueNew {
|
|
|
|
|
+ return fmt.Errorf("initial cluster state unset and no wal or discovery URL found")
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
// Make sure the cluster at least contains the local server.
|
|
// Make sure the cluster at least contains the local server.
|
|
|
m := c.Cluster.FindName(c.Name)
|
|
m := c.Cluster.FindName(c.Name)
|
|
|
if m == nil {
|
|
if m == nil {
|
|
|
return fmt.Errorf("could not find name %v in cluster", c.Name)
|
|
return fmt.Errorf("could not find name %v in cluster", c.Name)
|
|
|
}
|
|
}
|
|
|
|
|
+ if m.ID == raft.None {
|
|
|
|
|
+ return fmt.Errorf("could not use %x as member id", raft.None)
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
// No identical IPs in the cluster peer list
|
|
// No identical IPs in the cluster peer list
|
|
|
urlMap := make(map[string]bool)
|
|
urlMap := make(map[string]bool)
|
|
@@ -67,8 +75,3 @@ func (c *ServerConfig) ID() uint64 { return c.Cluster.FindName(c.Name).ID }
|
|
|
func (c *ServerConfig) ShouldDiscover() bool {
|
|
func (c *ServerConfig) ShouldDiscover() bool {
|
|
|
return c.DiscoveryURL != ""
|
|
return c.DiscoveryURL != ""
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
-// IsBootstrap returns true if a bootstrap method is provided.
|
|
|
|
|
-func (c *ServerConfig) IsBootstrap() bool {
|
|
|
|
|
- return c.DiscoveryURL != "" || c.ClusterState == ClusterStateValueNew
|
|
|
|
|
-}
|
|
|