|
@@ -1,6 +1,8 @@
|
|
|
package server
|
|
package server
|
|
|
|
|
|
|
|
import (
|
|
import (
|
|
|
|
|
+ "fmt"
|
|
|
|
|
+
|
|
|
"github.com/coreos/etcd/log"
|
|
"github.com/coreos/etcd/log"
|
|
|
"github.com/coreos/etcd/third_party/github.com/coreos/raft"
|
|
"github.com/coreos/etcd/third_party/github.com/coreos/raft"
|
|
|
)
|
|
)
|
|
@@ -23,6 +25,11 @@ func (c *DemoteCommand) CommandName() string {
|
|
|
func (c *DemoteCommand) Apply(context raft.Context) (interface{}, error) {
|
|
func (c *DemoteCommand) Apply(context raft.Context) (interface{}, error) {
|
|
|
ps, _ := context.Server().Context().(*PeerServer)
|
|
ps, _ := context.Server().Context().(*PeerServer)
|
|
|
|
|
|
|
|
|
|
+ // Ignore this command if there is no peer.
|
|
|
|
|
+ if !ps.registry.PeerExists(c.Name) {
|
|
|
|
|
+ return nil, fmt.Errorf("peer does not exist: %s", c.Name)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
// Save URLs.
|
|
// Save URLs.
|
|
|
clientURL, _ := ps.registry.ClientURL(c.Name)
|
|
clientURL, _ := ps.registry.ClientURL(c.Name)
|
|
|
peerURL, _ := ps.registry.PeerURL(c.Name)
|
|
peerURL, _ := ps.registry.PeerURL(c.Name)
|