mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
etcdserver: add cluster id check for hashKVHandler
Signed-off-by: caojiamingalan <alan.c.19971111@gmail.com> Signed-off-by: Marek Siarkowicz <siarkowicz@google.com>
This commit is contained in:
committed by
Marek Siarkowicz
parent
7ed8970e2d
commit
04cfb4c660
@@ -54,7 +54,7 @@ var (
|
||||
RaftSnapshotPrefix = path.Join(RaftPrefix, "snapshot")
|
||||
|
||||
errIncompatibleVersion = errors.New("incompatible version")
|
||||
errClusterIDMismatch = errors.New("cluster ID mismatch")
|
||||
ErrClusterIDMismatch = errors.New("cluster ID mismatch")
|
||||
)
|
||||
|
||||
type peerGetter interface {
|
||||
@@ -508,7 +508,7 @@ func checkClusterCompatibilityFromHeader(lg *zap.Logger, localID types.ID, heade
|
||||
zap.String("remote-peer-server-minimum-cluster-version", remoteMinClusterVs),
|
||||
zap.String("remote-peer-cluster-id", gcid),
|
||||
)
|
||||
return errClusterIDMismatch
|
||||
return ErrClusterIDMismatch
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -648,7 +648,7 @@ func (cr *streamReader) dial(t streamType) (io.ReadCloser, error) {
|
||||
}
|
||||
return nil, errIncompatibleVersion
|
||||
|
||||
case errClusterIDMismatch.Error():
|
||||
case ErrClusterIDMismatch.Error():
|
||||
if cr.lg != nil {
|
||||
cr.lg.Warn(
|
||||
"request sent was ignored by remote peer due to cluster ID mismatch",
|
||||
@@ -656,10 +656,10 @@ func (cr *streamReader) dial(t streamType) (io.ReadCloser, error) {
|
||||
zap.String("remote-peer-cluster-id", resp.Header.Get("X-Etcd-Cluster-ID")),
|
||||
zap.String("local-member-id", cr.tr.ID.String()),
|
||||
zap.String("local-member-cluster-id", cr.tr.ClusterID.String()),
|
||||
zap.Error(errClusterIDMismatch),
|
||||
zap.Error(ErrClusterIDMismatch),
|
||||
)
|
||||
}
|
||||
return nil, errClusterIDMismatch
|
||||
return nil, ErrClusterIDMismatch
|
||||
|
||||
default:
|
||||
return nil, fmt.Errorf("unhandled error %q when precondition failed", string(b))
|
||||
|
||||
@@ -94,7 +94,7 @@ func checkPostResponse(lg *zap.Logger, resp *http.Response, body []byte, req *ht
|
||||
)
|
||||
}
|
||||
return errIncompatibleVersion
|
||||
case errClusterIDMismatch.Error():
|
||||
case ErrClusterIDMismatch.Error():
|
||||
if lg != nil {
|
||||
lg.Error(
|
||||
"request sent was ignored due to cluster ID mismatch",
|
||||
@@ -103,7 +103,7 @@ func checkPostResponse(lg *zap.Logger, resp *http.Response, body []byte, req *ht
|
||||
zap.String("local-member-cluster-id", req.Header.Get("X-Etcd-Cluster-ID")),
|
||||
)
|
||||
}
|
||||
return errClusterIDMismatch
|
||||
return ErrClusterIDMismatch
|
||||
default:
|
||||
return fmt.Errorf("unhandled error %q when precondition failed", string(body))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user