mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
etcdserver: skip updating attr if the member does not exist
This commit is contained in:
parent
21179d929f
commit
98e30ca7c2
@ -324,20 +324,21 @@ func (c *cluster) RemoveMember(id types.ID) {
|
|||||||
c.removed[id] = true
|
c.removed[id] = true
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *cluster) UpdateAttributes(id types.ID, attr Attributes) {
|
func (c *cluster) UpdateAttributes(id types.ID, attr Attributes) bool {
|
||||||
c.Lock()
|
c.Lock()
|
||||||
defer c.Unlock()
|
defer c.Unlock()
|
||||||
if m, ok := c.members[id]; ok {
|
if m, ok := c.members[id]; ok {
|
||||||
m.Attributes = attr
|
m.Attributes = attr
|
||||||
return
|
return true
|
||||||
}
|
}
|
||||||
_, ok := c.removed[id]
|
_, ok := c.removed[id]
|
||||||
if ok {
|
if ok {
|
||||||
plog.Debugf("skipped updating attributes of removed member %s", id)
|
plog.Warningf("skipped updating attributes of removed member %s", id)
|
||||||
} else {
|
} else {
|
||||||
plog.Panicf("error updating attributes of unknown member %s", id)
|
plog.Panicf("error updating attributes of unknown member %s", id)
|
||||||
}
|
}
|
||||||
// TODO: update store in this function
|
// TODO: update store in this function
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *cluster) UpdateRaftAttributes(id types.ID, raftAttr RaftAttributes) {
|
func (c *cluster) UpdateRaftAttributes(id types.ID, raftAttr RaftAttributes) {
|
||||||
|
@ -851,7 +851,10 @@ func (s *EtcdServer) applyRequest(r pb.Request) Response {
|
|||||||
if err := json.Unmarshal([]byte(r.Val), &attr); err != nil {
|
if err := json.Unmarshal([]byte(r.Val), &attr); err != nil {
|
||||||
plog.Panicf("unmarshal %s should never fail: %v", r.Val, err)
|
plog.Panicf("unmarshal %s should never fail: %v", r.Val, err)
|
||||||
}
|
}
|
||||||
s.cluster.UpdateAttributes(id, attr)
|
ok := s.cluster.UpdateAttributes(id, attr)
|
||||||
|
if !ok {
|
||||||
|
return Response{}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if r.Path == path.Join(StoreClusterPrefix, "version") {
|
if r.Path == path.Join(StoreClusterPrefix, "version") {
|
||||||
s.cluster.SetVersion(semver.Must(semver.NewVersion(r.Val)))
|
s.cluster.SetVersion(semver.Must(semver.NewVersion(r.Val)))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user