Skip to content

Commit

Permalink
etcdctl: Use minor versions for downgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
serathius committed Feb 22, 2022
1 parent c1c2f12 commit 42faf9f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
12 changes: 6 additions & 6 deletions etcdctl/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1116,10 +1116,10 @@ DOWNGRADE VALIDATE validate downgrade capability before starting downgrade.
#### Example

```bash
./etcdctl downgrade validate 3.5.0
Downgrade validate success, cluster version 3.6.0
./etcdctl downgrade validate 3.5
Downgrade validate success, cluster version 3.6

./etcdctl downgrade validate 3.4.0
./etcdctl downgrade validate 3.4
Error: etcdserver: invalid downgrade target version

```
Expand All @@ -1131,8 +1131,8 @@ DOWNGRADE ENABLE starts a downgrade action to cluster.
#### Example

```bash
./etcdctl downgrade enable 3.5.0
Downgrade enable success, cluster version 3.6.0
./etcdctl downgrade enable 3.5
Downgrade enable success, cluster version 3.6
```

### DOWNGRADE CANCEL \<TARGET_VERSION\>
Expand All @@ -1143,7 +1143,7 @@ DOWNGRADE CANCEL cancels the ongoing downgrade action to cluster.

```bash
./etcdctl downgrade cancel
Downgrade cancel success, cluster version 3.6.0
Downgrade cancel success, cluster version 3.5
```

## Concurrency commands
Expand Down
6 changes: 3 additions & 3 deletions etcdctl/ctlv3/command/printer_simple.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,13 +177,13 @@ func (s *simplePrinter) MoveLeader(leader, target uint64, r v3.MoveLeaderRespons
}

func (s *simplePrinter) DowngradeValidate(r v3.DowngradeResponse) {
fmt.Printf("Downgrade validate success, cluster version %s", r.Version)
fmt.Printf("Downgrade validate success, cluster version %s\n", r.Version)
}
func (s *simplePrinter) DowngradeEnable(r v3.DowngradeResponse) {
fmt.Printf("Downgrade enable success, cluster version %s", r.Version)
fmt.Printf("Downgrade enable success, cluster version %s\n", r.Version)
}
func (s *simplePrinter) DowngradeCancel(r v3.DowngradeResponse) {
fmt.Printf("Downgrade cancel success, cluster version %s", r.Version)
fmt.Printf("Downgrade cancel success, cluster version %s\n", r.Version)
}

func (s *simplePrinter) RoleAdd(role string, r v3.AuthRoleAddResponse) {
Expand Down
7 changes: 4 additions & 3 deletions server/etcdserver/v3_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"time"

pb "go.etcd.io/etcd/api/v3/etcdserverpb"
"go.etcd.io/etcd/api/v3/version"
"go.etcd.io/etcd/pkg/v3/traceutil"
"go.etcd.io/etcd/raft/v3"
"go.etcd.io/etcd/server/v3/auth"
Expand Down Expand Up @@ -922,7 +923,7 @@ func (s *EtcdServer) downgradeValidate(ctx context.Context, v string) (*pb.Downg
if cv == nil {
return nil, ErrClusterVersionUnavailable
}
resp.Version = cv.String()
resp.Version = version.Cluster(cv.String())
err = s.Version().DowngradeValidate(ctx, targetVersion)
if err != nil {
return nil, err
Expand All @@ -943,7 +944,7 @@ func (s *EtcdServer) downgradeEnable(ctx context.Context, r *pb.DowngradeRequest
lg.Warn("reject downgrade request", zap.Error(err))
return nil, err
}
resp := pb.DowngradeResponse{Version: s.ClusterVersion().String()}
resp := pb.DowngradeResponse{Version: version.Cluster(s.ClusterVersion().String())}
return &resp, nil
}

Expand All @@ -952,6 +953,6 @@ func (s *EtcdServer) downgradeCancel(ctx context.Context) (*pb.DowngradeResponse
if err != nil {
s.lg.Warn("failed to cancel downgrade", zap.Error(err))
}
resp := pb.DowngradeResponse{Version: s.ClusterVersion().String()}
resp := pb.DowngradeResponse{Version: version.Cluster(s.ClusterVersion().String())}
return &resp, nil
}

0 comments on commit 42faf9f

Please sign in to comment.