-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Topo: Add version support to GetTopologyPath #15933
Conversation
Signed-off-by: Matt Lord <[email protected]>
Review ChecklistHello reviewers! 👋 Please follow this checklist when reviewing this Pull Request. General
Tests
Documentation
New flags
If a workflow is added or modified:
Backward compatibility
|
Signed-off-by: Matt Lord <[email protected]>
Signed-off-by: Matt Lord <[email protected]>
Signed-off-by: Matt Lord <[email protected]>
Signed-off-by: Matt Lord <[email protected]>
Signed-off-by: Matt Lord <[email protected]>
Signed-off-by: Matt Lord <[email protected]>
Signed-off-by: Matt Lord <[email protected]>
Signed-off-by: Matt Lord <[email protected]>
f6b9100
to
7c7cb0e
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #15933 +/- ##
==========================================
- Coverage 68.45% 68.23% -0.22%
==========================================
Files 1562 1562
Lines 197057 197221 +164
==========================================
- Hits 134891 134573 -318
- Misses 62166 62648 +482 ☔ View full report in Codecov by Sentry. |
Signed-off-by: Matt Lord <[email protected]>
Signed-off-by: Matt Lord <[email protected]>
case CommonRoutingRulesFile: | ||
switch path.Base(dir) { | ||
case "keyspace": | ||
p = new(vschemapb.KeyspaceRoutingRules) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was needed as a follow-up to: #15807
This PR is also what allows you to easily revert to the previous value as we had toyed with the idea of returning the old and new values from the ApplyKeyspaceRoutingRules
command for this purpose.
I don't like the idea of doing something that only works with etcd. |
ZooKeeper does not support this feature generally AFAIK. It's also worth noting that etcd2 is the only implementation that is officially / fully supported AFAIK. IMO it's a nice feature to support where it's possible.
The etcd keyspace has a new revision each time the keyspace is changed. So you would see what the current version is for the key and you can step back from there. That's what I did in the examples in the PR description. So e.g. if you just made a change, you would use current version - 1 to see what value of the node/key was at the previous keyspace revision.
You'll get a an err: |
Ok, this seems reasonable given the answers to my questions. Will review. |
Signed-off-by: Matt Lord <[email protected]>
@deepthi actually... it seems like ZooKeeper does support versions — there are virtually no docs so I didn't find anything, but... (after fixing the local example in: e5bef58):
And we don't in fact get an error when trying to get the version:
So that's not right... I'll put this back in draft then and try to add zk2 and consul support. And at the very least, return an error as expected if it's not supported. |
Confirmed that ZooKeeper does not support getting a specific version of a node/key as it does not actually store multiple revisions/versions of a key: https://github.com/z-division/go-zookeeper/blob/v1.0.0/zk/conn.go#L1129-L1166 Rather the version in ZK is merely a counter that is incremented on each Set: https://github.com/z-division/go-zookeeper/blob/v1.0.0/zk/structs.go#L36 So for ZK2 we can only provide a clear and meaningful error from the client. The same is true for Consul. It does not store multiple versions/revisions of keys/nodes so it has no way to request them on a get: https://github.com/hashicorp/consul/blob/v1.18.2/api/kv.go#L69-L89 It only has the key's ModifyIndex which is also a change counter that is used for CAS: https://github.com/hashicorp/consul/blob/v1.18.2/api/kv.go#L25-L28 |
Signed-off-by: Matt Lord <[email protected]>
17481ed
to
81ef344
Compare
Signed-off-by: Matt Lord <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❤️
This also brings all of the vtctldclient docs up to date with: export COBRADOC_VERSION_PAIRS="get_topo_path_version:20.0" export VITESS_DIR=~/git/vitess make vtctldclient-docs Signed-off-by: Matt Lord <[email protected]>
Signed-off-by: Matt Lord <[email protected]>
Thank you for the review, @rohit-nayak-ps ! I've addressed your comments here: 3ff727c Thank you for the nudge! I wasn't happy with that function either and it gave me the push to refactor it. 🙂 |
Signed-off-by: Matt Lord <[email protected]>
Signed-off-by: Matt Lord <[email protected]>
@@ -2259,24 +2260,26 @@ func (s *VtctldServer) GetTopologyPath(ctx context.Context, req *vtctldatapb.Get | |||
span, ctx := trace.NewSpan(ctx, "VtctldServer.GetTopology") | |||
defer span.Finish() | |||
|
|||
// handle toplevel display: global, then one line per cell. | |||
if req.Path == "/" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: proto fields are all public by design, and it is fine to access them directly. There is no need to change all accesses to use a getter instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've gotten into the habit of using the proto getters as they are nil safe. In this case, for example, if req is nil it will return "" rather than have a nil pointer error.
This also brings all of the vtctldclient docs up to date with: export COBRADOC_VERSION_PAIRS="get_topo_path_version:20.0" export VITESS_DIR=~/git/vitess make vtctldclient-docs Signed-off-by: Matt Lord <[email protected]>
Description
This PR adds the ability to view older/previous versions of topology keys. This can be used to follow changes over time and to revert to previous values.
ℹ️ Notes:
etcd2topo
implementation. This is because etcd is the only topo server implementation that stores multiple versions/revisions of a key and allows you to request a specific one. For ZooKeeper and Consul we display the value — which is a modification counter — and return an intuitive error if you use the flag:Example usage:
Related Issue(s)
Checklist