Skip to content

Commit

Permalink
Remove v2 store apply logic
Browse files Browse the repository at this point in the history
  • Loading branch information
serathius committed Nov 19, 2023
1 parent 1bade2c commit 6bddfb1
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 939 deletions.
166 changes: 0 additions & 166 deletions server/etcdserver/apply_v2.go

This file was deleted.

58 changes: 2 additions & 56 deletions server/etcdserver/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ type ServerV2 interface {
Leader() types.ID

// Do takes a V2 request and attempts to fulfill it, returning a Response.
Do(ctx context.Context, r pb.Request) (Response, error)
ClientCertAuthEnabled() bool
}

Expand Down Expand Up @@ -247,8 +246,6 @@ type EtcdServer struct {
v2store v2store.Store
snapshotter *snap.Snapshotter

applyV2 ApplierV2

uberApply apply.UberApplier

applyWait wait.WaitTime
Expand Down Expand Up @@ -338,7 +335,6 @@ func NewServer(cfg config.ServerConfig) (srv *EtcdServer, err error) {
}
serverID.With(prometheus.Labels{"server_id": b.cluster.nodeID.String()}).Set(1)
srv.cluster.SetVersionChangedNotifier(srv.clusterVersionChanged)
srv.applyV2 = NewApplierV2(cfg.Logger, srv.v2store, srv.cluster)

srv.be = b.storage.backend.be
srv.beHooks = b.storage.backend.beHooks
Expand Down Expand Up @@ -1897,22 +1893,12 @@ func (s *EtcdServer) applyEntryNormal(e *raftpb.Entry) {
}

var raftReq pb.InternalRaftRequest
if !pbutil.MaybeUnmarshal(&raftReq, e.Data) { // backward compatible
var r pb.Request
rp := &r
pbutil.MustUnmarshal(rp, e.Data)
s.lg.Debug("applyEntryNormal", zap.Stringer("V2request", rp))
s.w.Trigger(r.ID, s.applyV2Request((*RequestV2)(rp), shouldApplyV3))
if !pbutil.MaybeUnmarshal(&raftReq, e.Data) || raftReq.V2 != nil {
s.lg.Error("Unsupported v2 entry encountered. Skipping...")
return
}
s.lg.Debug("applyEntryNormal", zap.Stringer("raftReq", &raftReq))

if raftReq.V2 != nil {
req := (*RequestV2)(raftReq.V2)
s.w.Trigger(req.ID, s.applyV2Request(req, shouldApplyV3))
return
}

id := raftReq.ID
if id == 0 {
if raftReq.Header == nil {
Expand Down Expand Up @@ -2267,46 +2253,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()

Expand Down
Loading

0 comments on commit 6bddfb1

Please sign in to comment.