mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Merge pull request #13809 from kkkkun/cleanup-deprecated-commands
Removing deprecated commands in etcdctl & etcdutl
This commit is contained in:
@@ -16,6 +16,11 @@ See [code changes](https://github.com/etcd-io/etcd/compare/v3.5.0...v3.6.0).
|
||||
### Deprecations
|
||||
|
||||
- Deprecated [V2 discovery](https://etcd.io/docs/v3.5/dev-internal/discovery_protocol/).
|
||||
- Removed [etcdctl defrag --data-dir](https://github.com/etcd-io/etcd/pull/13793).
|
||||
- Removed [etcdctl snapshot status](https://github.com/etcd-io/etcd/pull/13809).
|
||||
- Removed [etcdctl snapshot restore](https://github.com/etcd-io/etcd/pull/13809).
|
||||
- Removed [etcdutl snapshot save](https://github.com/etcd-io/etcd/pull/13809).
|
||||
|
||||
|
||||
### etcdctl v3
|
||||
|
||||
|
||||
@@ -968,84 +968,12 @@ Save a snapshot to "snapshot.db":
|
||||
|
||||
### SNAPSHOT RESTORE [options] \<filename\>
|
||||
|
||||
Note: Deprecated. Use `etcdutl snapshot restore` instead. To be removed in v3.6.
|
||||
Removed in v3.6. Use `etcdutl snapshot restore` instead.
|
||||
|
||||
SNAPSHOT RESTORE creates an etcd data directory for an etcd cluster member from a backend database snapshot and a new cluster configuration. Restoring the snapshot into each member for a new cluster configuration will initialize a new etcd cluster preloaded by the snapshot data.
|
||||
|
||||
#### Options
|
||||
|
||||
The snapshot restore options closely resemble to those used in the `etcd` command for defining a cluster.
|
||||
|
||||
- data-dir -- Path to the data directory. Uses \<name\>.etcd if none given.
|
||||
|
||||
- wal-dir -- Path to the WAL directory. Uses data directory if none given.
|
||||
|
||||
- initial-cluster -- The initial cluster configuration for the restored etcd cluster.
|
||||
|
||||
- initial-cluster-token -- Initial cluster token for the restored etcd cluster.
|
||||
|
||||
- initial-advertise-peer-urls -- List of peer URLs for the member being restored.
|
||||
|
||||
- name -- Human-readable name for the etcd cluster member being restored.
|
||||
|
||||
- skip-hash-check -- Ignore snapshot integrity hash value (required if copied from data directory)
|
||||
|
||||
#### Output
|
||||
|
||||
A new etcd data directory initialized with the snapshot.
|
||||
|
||||
#### Example
|
||||
|
||||
Save a snapshot, restore into a new 3 node cluster, and start the cluster:
|
||||
```
|
||||
./etcdctl snapshot save snapshot.db
|
||||
|
||||
# restore members
|
||||
bin/etcdctl snapshot restore snapshot.db --initial-cluster-token etcd-cluster-1 --initial-advertise-peer-urls http://127.0.0.1:12380 --name sshot1 --initial-cluster 'sshot1=http://127.0.0.1:12380,sshot2=http://127.0.0.1:22380,sshot3=http://127.0.0.1:32380'
|
||||
bin/etcdctl snapshot restore snapshot.db --initial-cluster-token etcd-cluster-1 --initial-advertise-peer-urls http://127.0.0.1:22380 --name sshot2 --initial-cluster 'sshot1=http://127.0.0.1:12380,sshot2=http://127.0.0.1:22380,sshot3=http://127.0.0.1:32380'
|
||||
bin/etcdctl snapshot restore snapshot.db --initial-cluster-token etcd-cluster-1 --initial-advertise-peer-urls http://127.0.0.1:32380 --name sshot3 --initial-cluster 'sshot1=http://127.0.0.1:12380,sshot2=http://127.0.0.1:22380,sshot3=http://127.0.0.1:32380'
|
||||
|
||||
# launch members
|
||||
bin/etcd --name sshot1 --listen-client-urls http://127.0.0.1:2379 --advertise-client-urls http://127.0.0.1:2379 --listen-peer-urls http://127.0.0.1:12380 &
|
||||
bin/etcd --name sshot2 --listen-client-urls http://127.0.0.1:22379 --advertise-client-urls http://127.0.0.1:22379 --listen-peer-urls http://127.0.0.1:22380 &
|
||||
bin/etcd --name sshot3 --listen-client-urls http://127.0.0.1:32379 --advertise-client-urls http://127.0.0.1:32379 --listen-peer-urls http://127.0.0.1:32380 &
|
||||
```
|
||||
|
||||
### SNAPSHOT STATUS \<filename\>
|
||||
|
||||
Note: Deprecated. Use `etcdutl snapshot restore` instead. To be removed in v3.6.
|
||||
|
||||
SNAPSHOT STATUS lists information about a given backend database snapshot file.
|
||||
|
||||
#### Output
|
||||
|
||||
##### Simple format
|
||||
|
||||
Prints a humanized table of the database hash, revision, total keys, and size.
|
||||
|
||||
##### JSON format
|
||||
|
||||
Prints a line of JSON encoding the database hash, revision, total keys, and size.
|
||||
|
||||
#### Examples
|
||||
```bash
|
||||
./etcdctl snapshot status file.db
|
||||
# cf1550fb, 3, 3, 25 kB
|
||||
```
|
||||
|
||||
```bash
|
||||
./etcdctl --write-out=json snapshot status file.db
|
||||
# {"hash":3474280699,"revision":3,"totalKey":3,"totalSize":24576}
|
||||
```
|
||||
|
||||
```bash
|
||||
./etcdctl --write-out=table snapshot status file.db
|
||||
+----------+----------+------------+------------+
|
||||
| HASH | REVISION | TOTAL KEYS | TOTAL SIZE |
|
||||
+----------+----------+------------+------------+
|
||||
| cf1550fb | 3 | 3 | 25 kB |
|
||||
+----------+----------+------------+------------+
|
||||
```
|
||||
Removed in v3.6. Use `etcdutl snapshot status` instead.
|
||||
|
||||
### MOVE-LEADER \<hexadecimal-transferee-id\>
|
||||
|
||||
|
||||
@@ -17,30 +17,13 @@ package command
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
snapshot "go.etcd.io/etcd/client/v3/snapshot"
|
||||
"go.etcd.io/etcd/etcdutl/v3/etcdutl"
|
||||
"go.etcd.io/etcd/pkg/v3/cobrautl"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
const (
|
||||
defaultName = "default"
|
||||
defaultInitialAdvertisePeerURLs = "http://localhost:2380"
|
||||
)
|
||||
|
||||
var (
|
||||
restoreCluster string
|
||||
restoreClusterToken string
|
||||
restoreDataDir string
|
||||
restoreWalDir string
|
||||
restorePeerURLs string
|
||||
restoreName string
|
||||
skipHashCheck bool
|
||||
)
|
||||
|
||||
// NewSnapshotCommand returns the cobra command for "snapshot".
|
||||
func NewSnapshotCommand() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
@@ -48,8 +31,6 @@ func NewSnapshotCommand() *cobra.Command {
|
||||
Short: "Manages etcd node snapshots",
|
||||
}
|
||||
cmd.AddCommand(NewSnapshotSaveCommand())
|
||||
cmd.AddCommand(NewSnapshotRestoreCommand())
|
||||
cmd.AddCommand(newSnapshotStatusCommand())
|
||||
return cmd
|
||||
}
|
||||
|
||||
@@ -61,39 +42,6 @@ func NewSnapshotSaveCommand() *cobra.Command {
|
||||
}
|
||||
}
|
||||
|
||||
func newSnapshotStatusCommand() *cobra.Command {
|
||||
return &cobra.Command{
|
||||
Use: "status <filename>",
|
||||
Short: "[deprecated] Gets backend snapshot status of a given file",
|
||||
Long: `When --write-out is set to simple, this command prints out comma-separated status lists for each endpoint.
|
||||
The items in the lists are hash, revision, total keys, total size.
|
||||
|
||||
Moved to 'etcdctl snapshot status ...'
|
||||
`,
|
||||
Run: snapshotStatusCommandFunc,
|
||||
}
|
||||
}
|
||||
|
||||
func NewSnapshotRestoreCommand() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "restore <filename> [options]",
|
||||
Short: "Restores an etcd member snapshot to an etcd directory",
|
||||
Run: snapshotRestoreCommandFunc,
|
||||
Long: "Moved to `etcdctl snapshot restore ...`\n",
|
||||
}
|
||||
cmd.Flags().StringVar(&restoreDataDir, "data-dir", "", "Path to the data directory")
|
||||
cmd.Flags().StringVar(&restoreWalDir, "wal-dir", "", "Path to the WAL directory (use --data-dir if none given)")
|
||||
cmd.Flags().StringVar(&restoreCluster, "initial-cluster", initialClusterFromName(defaultName), "Initial cluster configuration for restore bootstrap")
|
||||
cmd.Flags().StringVar(&restoreClusterToken, "initial-cluster-token", "etcd-cluster", "Initial cluster token for the etcd cluster during restore bootstrap")
|
||||
cmd.Flags().StringVar(&restorePeerURLs, "initial-advertise-peer-urls", defaultInitialAdvertisePeerURLs, "List of this member's peer URLs to advertise to the rest of the cluster")
|
||||
cmd.Flags().StringVar(&restoreName, "name", defaultName, "Human-readable name for this member")
|
||||
cmd.Flags().BoolVar(&skipHashCheck, "skip-hash-check", false, "Ignore snapshot integrity hash value (required if copied from data directory)")
|
||||
cmd.MarkFlagDirname("data-dir")
|
||||
cmd.MarkFlagDirname("wal-dir")
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
||||
func snapshotSaveCommandFunc(cmd *cobra.Command, args []string) {
|
||||
if len(args) != 1 {
|
||||
err := fmt.Errorf("snapshot save expects one argument")
|
||||
@@ -123,22 +71,3 @@ func snapshotSaveCommandFunc(cmd *cobra.Command, args []string) {
|
||||
fmt.Printf("Server version %s\n", version)
|
||||
}
|
||||
}
|
||||
|
||||
func snapshotStatusCommandFunc(cmd *cobra.Command, args []string) {
|
||||
fmt.Fprintf(os.Stderr, "Deprecated: Use `etcdutl snapshot status` instead.\n\n")
|
||||
etcdutl.SnapshotStatusCommandFunc(cmd, args)
|
||||
}
|
||||
|
||||
func snapshotRestoreCommandFunc(cmd *cobra.Command, args []string) {
|
||||
fmt.Fprintf(os.Stderr, "Deprecated: Use `etcdutl snapshot restore` instead.\n\n")
|
||||
etcdutl.SnapshotRestoreCommandFunc(restoreCluster, restoreClusterToken, restoreDataDir, restoreWalDir,
|
||||
restorePeerURLs, restoreName, skipHashCheck, args)
|
||||
}
|
||||
|
||||
func initialClusterFromName(name string) string {
|
||||
n := name
|
||||
if name == "" {
|
||||
n = defaultName
|
||||
}
|
||||
return fmt.Sprintf("%s=http://localhost:2380", n)
|
||||
}
|
||||
|
||||
@@ -67,17 +67,18 @@ A new etcd data directory initialized with the snapshot.
|
||||
|
||||
Save a snapshot, restore into a new 3 node cluster, and start the cluster:
|
||||
```
|
||||
./etcdutl snapshot save snapshot.db
|
||||
# save snapshot
|
||||
./etcdctl snapshot save snapshot.db
|
||||
|
||||
# restore members
|
||||
bin/etcdutl snapshot restore snapshot.db --initial-cluster-token etcd-cluster-1 --initial-advertise-peer-urls http://127.0.0.1:12380 --name sshot1 --initial-cluster 'sshot1=http://127.0.0.1:12380,sshot2=http://127.0.0.1:22380,sshot3=http://127.0.0.1:32380'
|
||||
bin/etcdutl snapshot restore snapshot.db --initial-cluster-token etcd-cluster-1 --initial-advertise-peer-urls http://127.0.0.1:22380 --name sshot2 --initial-cluster 'sshot1=http://127.0.0.1:12380,sshot2=http://127.0.0.1:22380,sshot3=http://127.0.0.1:32380'
|
||||
bin/etcdutl snapshot restore snapshot.db --initial-cluster-token etcd-cluster-1 --initial-advertise-peer-urls http://127.0.0.1:32380 --name sshot3 --initial-cluster 'sshot1=http://127.0.0.1:12380,sshot2=http://127.0.0.1:22380,sshot3=http://127.0.0.1:32380'
|
||||
./etcdutl snapshot restore snapshot.db --initial-cluster-token etcd-cluster-1 --initial-advertise-peer-urls http://127.0.0.1:12380 --name sshot1 --initial-cluster 'sshot1=http://127.0.0.1:12380,sshot2=http://127.0.0.1:22380,sshot3=http://127.0.0.1:32380'
|
||||
./etcdutl snapshot restore snapshot.db --initial-cluster-token etcd-cluster-1 --initial-advertise-peer-urls http://127.0.0.1:22380 --name sshot2 --initial-cluster 'sshot1=http://127.0.0.1:12380,sshot2=http://127.0.0.1:22380,sshot3=http://127.0.0.1:32380'
|
||||
./etcdutl snapshot restore snapshot.db --initial-cluster-token etcd-cluster-1 --initial-advertise-peer-urls http://127.0.0.1:32380 --name sshot3 --initial-cluster 'sshot1=http://127.0.0.1:12380,sshot2=http://127.0.0.1:22380,sshot3=http://127.0.0.1:32380'
|
||||
|
||||
# launch members
|
||||
bin/etcd --name sshot1 --listen-client-urls http://127.0.0.1:2379 --advertise-client-urls http://127.0.0.1:2379 --listen-peer-urls http://127.0.0.1:12380 &
|
||||
bin/etcd --name sshot2 --listen-client-urls http://127.0.0.1:22379 --advertise-client-urls http://127.0.0.1:22379 --listen-peer-urls http://127.0.0.1:22380 &
|
||||
bin/etcd --name sshot3 --listen-client-urls http://127.0.0.1:32379 --advertise-client-urls http://127.0.0.1:32379 --listen-peer-urls http://127.0.0.1:32380 &
|
||||
./etcd --name sshot1 --listen-client-urls http://127.0.0.1:2379 --advertise-client-urls http://127.0.0.1:2379 --listen-peer-urls http://127.0.0.1:12380 &
|
||||
./etcd --name sshot2 --listen-client-urls http://127.0.0.1:22379 --advertise-client-urls http://127.0.0.1:22379 --listen-peer-urls http://127.0.0.1:22380 &
|
||||
./etcd --name sshot3 --listen-client-urls http://127.0.0.1:32379 --advertise-client-urls http://127.0.0.1:32379 --listen-peer-urls http://127.0.0.1:32380 &
|
||||
```
|
||||
|
||||
### SNAPSHOT STATUS \<filename\>
|
||||
@@ -124,21 +125,6 @@ Prints etcd version and API version.
|
||||
|
||||
#### Examples
|
||||
|
||||
```bash
|
||||
./etcdutl version
|
||||
# etcdutl version: 3.1.0-alpha.0+git
|
||||
# API version: 3.1
|
||||
```
|
||||
|
||||
### VERSION
|
||||
|
||||
Prints the version of etcdctl.
|
||||
|
||||
#### Output
|
||||
|
||||
Prints etcd version and API version.
|
||||
|
||||
#### Examples
|
||||
|
||||
```bash
|
||||
./etcdutl version
|
||||
|
||||
@@ -46,27 +46,11 @@ func NewSnapshotCommand() *cobra.Command {
|
||||
Use: "snapshot <subcommand>",
|
||||
Short: "Manages etcd node snapshots",
|
||||
}
|
||||
cmd.AddCommand(NewSnapshotSaveCommand())
|
||||
cmd.AddCommand(NewSnapshotRestoreCommand())
|
||||
cmd.AddCommand(newSnapshotStatusCommand())
|
||||
return cmd
|
||||
}
|
||||
|
||||
func NewSnapshotSaveCommand() *cobra.Command {
|
||||
return &cobra.Command{
|
||||
Use: "save <filename>",
|
||||
Short: "Stores an etcd node backend snapshot to a given file",
|
||||
Hidden: true,
|
||||
DisableFlagsInUseLine: true,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
cobrautl.ExitWithError(cobrautl.ExitBadArgs,
|
||||
fmt.Errorf("In order to download snapshot use: "+
|
||||
"`etcdctl snapshot save ...`"))
|
||||
},
|
||||
Deprecated: "Use `etcdctl snapshot save` to download snapshot",
|
||||
}
|
||||
}
|
||||
|
||||
func newSnapshotStatusCommand() *cobra.Command {
|
||||
return &cobra.Command{
|
||||
Use: "status <filename>",
|
||||
|
||||
@@ -62,7 +62,6 @@ func snapshotTest(cx ctlCtx) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestCtlV3SnapshotCorrupt(t *testing.T) { testCtl(t, snapshotCorruptTest) }
|
||||
func TestCtlV3SnapshotCorruptEtcdutl(t *testing.T) { testCtl(t, snapshotCorruptTest, withEtcdutl()) }
|
||||
|
||||
func snapshotCorruptTest(cx ctlCtx) {
|
||||
@@ -98,7 +97,6 @@ func snapshotCorruptTest(cx ctlCtx) {
|
||||
}
|
||||
|
||||
// This test ensures that the snapshot status does not modify the snapshot file
|
||||
func TestCtlV3SnapshotStatusBeforeRestore(t *testing.T) { testCtl(t, snapshotStatusBeforeRestoreTest) }
|
||||
func TestCtlV3SnapshotStatusBeforeRestoreEtcdutl(t *testing.T) {
|
||||
testCtl(t, snapshotStatusBeforeRestoreTest, withEtcdutl())
|
||||
}
|
||||
@@ -136,6 +134,7 @@ func ctlV3SnapshotSave(cx ctlCtx, fpath string) error {
|
||||
}
|
||||
|
||||
func getSnapshotStatus(cx ctlCtx, fpath string) (snapshot.Status, error) {
|
||||
cx.etcdutl = true
|
||||
cmdArgs := append(cx.PrefixArgsUtl(), "--write-out", "json", "snapshot", "status", fpath)
|
||||
|
||||
proc, err := e2e.SpawnCmd(cmdArgs, nil)
|
||||
@@ -159,7 +158,6 @@ func getSnapshotStatus(cx ctlCtx, fpath string) (snapshot.Status, error) {
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func TestIssue6361(t *testing.T) { testIssue6361(t, false) }
|
||||
func TestIssue6361etcdutl(t *testing.T) { testIssue6361(t, true) }
|
||||
|
||||
// TestIssue6361 ensures new member that starts with snapshot correctly
|
||||
|
||||
Reference in New Issue
Block a user