mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Merge pull request #13519 from ahrtr/enhance_make_mirror_command
Add a new flag "--rev" to make-mirror command to support incremental mirror
This commit is contained in:
commit
19cb0a4252
@ -34,6 +34,7 @@ See [code changes](https://github.com/etcd-io/etcd/compare/v3.5.0...v3.6.0).
|
|||||||
- Add [`etcd --log-format`](https://github.com/etcd-io/etcd/pull/13339) flag to support log format.
|
- Add [`etcd --log-format`](https://github.com/etcd-io/etcd/pull/13339) flag to support log format.
|
||||||
- Add [`etcd --experimental-max-learners`](https://github.com/etcd-io/etcd/pull/13377) flag to allow configuration of learner max membership.
|
- Add [`etcd --experimental-max-learners`](https://github.com/etcd-io/etcd/pull/13377) flag to allow configuration of learner max membership.
|
||||||
- Add [`etcd --experimental-enable-lease-checkpoint-persist`](https://github.com/etcd-io/etcd/pull/13508) flag to handle upgrade from v3.5.2 clusters with this feature enabled.
|
- Add [`etcd --experimental-enable-lease-checkpoint-persist`](https://github.com/etcd-io/etcd/pull/13508) flag to handle upgrade from v3.5.2 clusters with this feature enabled.
|
||||||
|
- Add [`etcdctl make-mirror --rev`](https://github.com/etcd-io/etcd/pull/13519) flag to support incremental mirror.
|
||||||
- Fix [non mutating requests pass through quotaKVServer when NOSPACE](https://github.com/etcd-io/etcd/pull/13435)
|
- Fix [non mutating requests pass through quotaKVServer when NOSPACE](https://github.com/etcd-io/etcd/pull/13435)
|
||||||
- Fix [exclude the same alarm type activated by multiple peers](https://github.com/etcd-io/etcd/pull/13467).
|
- Fix [exclude the same alarm type activated by multiple peers](https://github.com/etcd-io/etcd/pull/13467).
|
||||||
- Fix [Provide a better liveness probe for when etcd runs as a Kubernetes pod](https://github.com/etcd-io/etcd/pull/13399)
|
- Fix [Provide a better liveness probe for when etcd runs as a Kubernetes pod](https://github.com/etcd-io/etcd/pull/13399)
|
||||||
|
@ -43,6 +43,7 @@ var (
|
|||||||
mmuser string
|
mmuser string
|
||||||
mmpassword string
|
mmpassword string
|
||||||
mmnodestprefix bool
|
mmnodestprefix bool
|
||||||
|
mmrev int64
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewMakeMirrorCommand returns the cobra command for "makeMirror".
|
// NewMakeMirrorCommand returns the cobra command for "makeMirror".
|
||||||
@ -54,6 +55,7 @@ func NewMakeMirrorCommand() *cobra.Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
c.Flags().StringVar(&mmprefix, "prefix", "", "Key-value prefix to mirror")
|
c.Flags().StringVar(&mmprefix, "prefix", "", "Key-value prefix to mirror")
|
||||||
|
c.Flags().Int64Var(&mmrev, "rev", 0, "Specify the kv revision to start to mirror")
|
||||||
c.Flags().StringVar(&mmdestprefix, "dest-prefix", "", "destination prefix to mirror a prefix to a different prefix in the destination cluster")
|
c.Flags().StringVar(&mmdestprefix, "dest-prefix", "", "destination prefix to mirror a prefix to a different prefix in the destination cluster")
|
||||||
c.Flags().BoolVar(&mmnodestprefix, "no-dest-prefix", false, "mirror key-values to the root of the destination cluster")
|
c.Flags().BoolVar(&mmnodestprefix, "no-dest-prefix", false, "mirror key-values to the root of the destination cluster")
|
||||||
c.Flags().StringVar(&mmcert, "dest-cert", "", "Identify secure client using this TLS certificate file for the destination cluster")
|
c.Flags().StringVar(&mmcert, "dest-cert", "", "Identify secure client using this TLS certificate file for the destination cluster")
|
||||||
@ -142,8 +144,16 @@ func makeMirror(ctx context.Context, c *clientv3.Client, dc *clientv3.Client) er
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
s := mirror.NewSyncer(c, mmprefix, 0)
|
startRev := mmrev - 1
|
||||||
|
if startRev < 0 {
|
||||||
|
startRev = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
s := mirror.NewSyncer(c, mmprefix, startRev)
|
||||||
|
|
||||||
|
// If a rev is provided, then do not sync the whole key space.
|
||||||
|
// Instead, just start watching the key space starting from the rev
|
||||||
|
if startRev == 0 {
|
||||||
rc, errc := s.SyncBase(ctx)
|
rc, errc := s.SyncBase(ctx)
|
||||||
|
|
||||||
// if remove destination prefix is false and destination prefix is empty set the value of destination prefix same as prefix
|
// if remove destination prefix is false and destination prefix is empty set the value of destination prefix same as prefix
|
||||||
@ -165,6 +175,7 @@ func makeMirror(ctx context.Context, c *clientv3.Client, dc *clientv3.Client) er
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
wc := s.SyncUpdates(ctx)
|
wc := s.SyncUpdates(ctx)
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@ import (
|
|||||||
func TestCtlV3MakeMirror(t *testing.T) { testCtl(t, makeMirrorTest) }
|
func TestCtlV3MakeMirror(t *testing.T) { testCtl(t, makeMirrorTest) }
|
||||||
func TestCtlV3MakeMirrorModifyDestPrefix(t *testing.T) { testCtl(t, makeMirrorModifyDestPrefixTest) }
|
func TestCtlV3MakeMirrorModifyDestPrefix(t *testing.T) { testCtl(t, makeMirrorModifyDestPrefixTest) }
|
||||||
func TestCtlV3MakeMirrorNoDestPrefix(t *testing.T) { testCtl(t, makeMirrorNoDestPrefixTest) }
|
func TestCtlV3MakeMirrorNoDestPrefix(t *testing.T) { testCtl(t, makeMirrorNoDestPrefixTest) }
|
||||||
|
func TestCtlV3MakeMirrorWithWatchRev(t *testing.T) { testCtl(t, makeMirrorWithWatchRev) }
|
||||||
|
|
||||||
func makeMirrorTest(cx ctlCtx) {
|
func makeMirrorTest(cx ctlCtx) {
|
||||||
var (
|
var (
|
||||||
@ -59,6 +60,18 @@ func makeMirrorNoDestPrefixTest(cx ctlCtx) {
|
|||||||
testMirrorCommand(cx, flags, kvs, kvs2, srcprefix, destprefix)
|
testMirrorCommand(cx, flags, kvs, kvs2, srcprefix, destprefix)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func makeMirrorWithWatchRev(cx ctlCtx) {
|
||||||
|
var (
|
||||||
|
flags = []string{"--prefix", "o_", "--no-dest-prefix", "--rev", "4"}
|
||||||
|
kvs = []kv{{"o_key1", "val1"}, {"o_key2", "val2"}, {"o_key3", "val3"}, {"o_key4", "val4"}}
|
||||||
|
kvs2 = []kvExec{{key: "key3", val: "val3"}, {key: "key4", val: "val4"}}
|
||||||
|
srcprefix = "o_"
|
||||||
|
destprefix = "key"
|
||||||
|
)
|
||||||
|
|
||||||
|
testMirrorCommand(cx, flags, kvs, kvs2, srcprefix, destprefix)
|
||||||
|
}
|
||||||
|
|
||||||
func testMirrorCommand(cx ctlCtx, flags []string, sourcekvs []kv, destkvs []kvExec, srcprefix, destprefix string) {
|
func testMirrorCommand(cx ctlCtx, flags []string, sourcekvs []kv, destkvs []kvExec, srcprefix, destprefix string) {
|
||||||
// set up another cluster to mirror with
|
// set up another cluster to mirror with
|
||||||
mirrorcfg := e2e.NewConfigAutoTLS()
|
mirrorcfg := e2e.NewConfigAutoTLS()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user