Browse Source

Merge pull request #3657 from xiang90/fix_remove

etcdserver: skip updating attr if the member does not exist
Xiang Li 10 years ago
parent
commit
32dd4d5de3
2 changed files with 8 additions and 4 deletions
  1. 4 3
      etcdserver/cluster.go
  2. 4 1
      etcdserver/server.go

+ 4 - 3
etcdserver/cluster.go

@@ -324,20 +324,21 @@ func (c *cluster) RemoveMember(id types.ID) {
 	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()
 	defer c.Unlock()
 	if m, ok := c.members[id]; ok {
 		m.Attributes = attr
-		return
+		return true
 	}
 	_, ok := c.removed[id]
 	if ok {
-		plog.Debugf("skipped updating attributes of removed member %s", id)
+		plog.Warningf("skipped updating attributes of removed member %s", id)
 	} else {
 		plog.Panicf("error updating attributes of unknown member %s", id)
 	}
 	// TODO: update store in this function
+	return false
 }
 
 func (c *cluster) UpdateRaftAttributes(id types.ID, raftAttr RaftAttributes) {

+ 4 - 1
etcdserver/server.go

@@ -878,7 +878,10 @@ func (s *EtcdServer) applyRequest(r pb.Request) Response {
 				if err := json.Unmarshal([]byte(r.Val), &attr); err != nil {
 					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") {
 				s.cluster.SetVersion(semver.Must(semver.NewVersion(r.Val)))