etcdctl: add --from-key to watch command - #22383
Conversation
'get' and 'del' already support --from-key (watch keys >= the given key, byte-wise), via clientv3.WithFromKey(). The server already fully implements this for Watch too (see the RangeEnd sentinel handling in server/etcdserver/api/v3rpc/watch.go), and the client library already wires it through -- only the etcdctl 'watch' command itself was missing the flag. Signed-off-by: Avanish Garg <gargavanish@gmail.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: avanish-garg The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Hi @avanish-garg. Thanks for your PR. I'm waiting for a etcd-io member to verify that this patch is reasonable to test. If it is, they should reply with Regular contributors should join the org to skip this step. Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
Fixes #22381
Problem
etcdctl getandetcdctl delboth support--from-key(watch/get/delete all keys thatare byte-wise >= the given key), but
etcdctl watchdoesn't -- it can only watch an exactkey or a
--prefix.Change
--from-keyflag to thewatchcommand, mirroring the exact pattern alreadyused by
get/del(etcdctl/ctlv3/command/get_command.go,del_command.go).--prefix/--from-keymutual-exclusion checkget/delalready have.--from-keybehaves the sameas the existing
--prefixflag across repeated interactivewatchinvocations.tests/e2e/ctl_v3_watch_test.gomirroring the existing--prefixtest case, run against a real spawned etcd server with the built CLI.The server already fully implements this for Watch requests:
WithFromKey()'s sentinelvalue (
RangeEnd = []byte{0}) is already handled inserver/etcdserver/api/v3rpc/watch.gowith a comment saying "support >= key queries",and the client library (
clientv3.WithFromKey()) already documents itself as applying to'Get', 'Delete', 'Watch'. So this PR is purely additive CLI wiring -- no server or client
library changes needed.
Verified:
go build ./...,go vet ./etcdctl/...clean, existingTest_parseWatchArgsunit test still passes, new e2e test (
TestCtlV3Watch) passes against a real spawnedserver running the actual built
etcdctlbinary.