mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Remove code for setting cluster version via V2 API
Signed-off-by: Marek Siarkowicz <siarkowicz@google.com>
This commit is contained in:
parent
1bade2c347
commit
b4fd31f254
@ -2267,46 +2267,6 @@ func (s *EtcdServer) monitorCompactHash() {
|
||||
}
|
||||
}
|
||||
|
||||
func (s *EtcdServer) updateClusterVersionV2(ver string) {
|
||||
lg := s.Logger()
|
||||
|
||||
if s.cluster.Version() == nil {
|
||||
lg.Info(
|
||||
"setting up initial cluster version using v2 API",
|
||||
zap.String("cluster-version", version.Cluster(ver)),
|
||||
)
|
||||
} else {
|
||||
lg.Info(
|
||||
"updating cluster version using v2 API",
|
||||
zap.String("from", version.Cluster(s.cluster.Version().String())),
|
||||
zap.String("to", version.Cluster(ver)),
|
||||
)
|
||||
}
|
||||
|
||||
req := pb.Request{
|
||||
Method: "PUT",
|
||||
Path: membership.StoreClusterVersionKey(),
|
||||
Val: ver,
|
||||
}
|
||||
|
||||
ctx, cancel := context.WithTimeout(s.ctx, s.Cfg.ReqTimeout())
|
||||
_, err := s.Do(ctx, req)
|
||||
cancel()
|
||||
|
||||
switch err {
|
||||
case nil:
|
||||
lg.Info("cluster version is updated", zap.String("cluster-version", version.Cluster(ver)))
|
||||
return
|
||||
|
||||
case errors.ErrStopped:
|
||||
lg.Warn("aborting cluster version update; server is stopped", zap.Error(err))
|
||||
return
|
||||
|
||||
default:
|
||||
lg.Warn("failed to update cluster version", zap.Error(err))
|
||||
}
|
||||
}
|
||||
|
||||
func (s *EtcdServer) updateClusterVersionV3(ver string) {
|
||||
lg := s.Logger()
|
||||
|
||||
|
@ -21,7 +21,6 @@ import (
|
||||
"math"
|
||||
"net/http"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"sync"
|
||||
@ -1631,53 +1630,6 @@ func TestPublishV3Retry(t *testing.T) {
|
||||
<-ch
|
||||
}
|
||||
|
||||
func TestUpdateVersion(t *testing.T) {
|
||||
n := newNodeRecorder()
|
||||
ch := make(chan any, 1)
|
||||
// simulate that request has gone through consensus
|
||||
ch <- Response{}
|
||||
w := wait.NewWithResponse(ch)
|
||||
ctx, cancel := context.WithCancel(context.TODO())
|
||||
srv := &EtcdServer{
|
||||
lgMu: new(sync.RWMutex),
|
||||
lg: zaptest.NewLogger(t),
|
||||
memberId: 1,
|
||||
Cfg: config.ServerConfig{Logger: zaptest.NewLogger(t), TickMs: 1, SnapshotCatchUpEntries: DefaultSnapshotCatchUpEntries},
|
||||
r: *newRaftNode(raftNodeConfig{lg: zaptest.NewLogger(t), Node: n}),
|
||||
attributes: membership.Attributes{Name: "node1", ClientURLs: []string{"http://node1.com"}},
|
||||
cluster: &membership.RaftCluster{},
|
||||
w: w,
|
||||
reqIDGen: idutil.NewGenerator(0, time.Time{}),
|
||||
SyncTicker: &time.Ticker{},
|
||||
|
||||
ctx: ctx,
|
||||
cancel: cancel,
|
||||
}
|
||||
srv.updateClusterVersionV2("2.0.0")
|
||||
|
||||
action := n.Action()
|
||||
if len(action) != 1 {
|
||||
t.Fatalf("len(action) = %d, want 1", len(action))
|
||||
}
|
||||
if action[0].Name != "Propose" {
|
||||
t.Fatalf("action = %s, want Propose", action[0].Name)
|
||||
}
|
||||
data := action[0].Params[0].([]byte)
|
||||
var r pb.Request
|
||||
if err := r.Unmarshal(data); err != nil {
|
||||
t.Fatalf("unmarshal request error: %v", err)
|
||||
}
|
||||
if r.Method != "PUT" {
|
||||
t.Errorf("method = %s, want PUT", r.Method)
|
||||
}
|
||||
if wpath := path.Join(StoreClusterPrefix, "version"); r.Path != wpath {
|
||||
t.Errorf("path = %s, want %s", r.Path, wpath)
|
||||
}
|
||||
if r.Val != "2.0.0" {
|
||||
t.Errorf("val = %s, want %s", r.Val, "2.0.0")
|
||||
}
|
||||
}
|
||||
|
||||
func TestUpdateVersionV3(t *testing.T) {
|
||||
n := newNodeRecorder()
|
||||
ch := make(chan any, 1)
|
||||
|
Loading…
x
Reference in New Issue
Block a user