mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Check for peer before demotion.
This commit is contained in:
parent
c8d6b26dfd
commit
063f3b574c
@ -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)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user