[closes #4378] Add keyspace visibility filtering to vtgates#4420
Merged
demmer merged 14 commits intovitessio:masterfrom Dec 14, 2018
Merged
Conversation
added 2 commits
December 4, 2018 14:28
### Summary This was added in order to support spining up a vtgate within a cell that has a limited access to the keyspaces inside that cell. It was added instead of modifying the existing `filter_tablets` behavior because bringing in the `|<shard-or-keyrange>` syntax didn't make sense based on the desired behavior. `filter_tablets` and `keyspaces_to_watch` were made mutually exclusive to prevent situations where the flags required different keyspaces which would have implied a non-obvious behavior (or had to fail anyway). Implementation was relatively straight-forward: I added a new srvtopo.Server that can filter the keyspaces returned and passed to the callback for WatchSrvVSchema as well as tests. If a call is made to get the underlying topo.Server is returned, e.g., calls to a server Conn's ListDir will not be have any filtering applied. ### Testing Automated: Unit tests for the new filtering `srvtopo.Server` impl Manual: Using the vagrant setup I spun up a cluster with: 2 keyspaces: aaa_keyspace, test_keyspace 10 vttablets: 5 fronting each keyspace 1 vtgate, 1vtctld - when not watching a specific keyspace showed both keyspaces on `show vitess_keyspaces` - when `keyspaces_to_watch=test_keyspace` was set only `test_keyspace` was returned for `show vitess_keyspaces`; `select now() from dual;` was functional Signed-off-by: Richard Bailey <rbailey@slack-corp.com>
Signed-off-by: Richard Bailey <rbailey@slack-corp.com>
added 2 commits
December 4, 2018 15:44
Signed-off-by: Richard Bailey <rbailey@slack-corp.com>
…gate.go. Signed-off-by: Richard Bailey <rbailey@slack-corp.com>
demmer
requested changes
Dec 6, 2018
Member
demmer
left a comment
There was a problem hiding this comment.
Overall looking good -- some suggestions on naming and organization and maybe a better approach to testing
added 2 commits
December 5, 2018 18:38
Signed-off-by: Richard Bailey <rbailey@slack-corp.com>
f3de7be to
950de57
Compare
…ssthrough Signed-off-by: Richard Bailey <rbailey@slack-corp.com>
950de57 to
461e7a0
Compare
Signed-off-by: Richard Bailey <rbailey@slack-corp.com>
…at instead of real code so that tests are easier to reason about Signed-off-by: Richard Bailey <rbailey@slack-corp.com>
c85e082 to
744c6b5
Compare
stop using init in filtering server test Signed-off-by: Richard Bailey <rbailey@slack-corp.com>
demmer
requested changes
Dec 13, 2018
Member
demmer
left a comment
There was a problem hiding this comment.
Looking good overall - just the minor cleanup and one slightly more substantive change that I mentioned.
added 4 commits
December 13, 2018 13:03
…server. tl;dr is that the TopoServer is only used for vschema updates but also assumes that it has a full copy of the vschema so using it like that would result in losing other keyspaces. A full explanation as to why is in vitessio#4420 (comment) Signed-off-by: Richard Bailey <rbailey@slack-corp.com>
…te being attached to a generic accessor function Signed-off-by: Richard Bailey <rbailey@slack-corp.com>
Signed-off-by: Richard Bailey <rbailey@slack-corp.com>
Signed-off-by: Richard Bailey <rbailey@slack-corp.com>
9de060f to
a72b957
Compare
Author
|
Pending CI passing this should be good to review again. I updated the summary to reflect the actual state of the change. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #4378
Summary
This was added in order to support running up a vtgate within a cell that has a limited access to the keyspaces inside that cell. A new flag was introduced instead of modifying the existing
tablet_filtersbehavior because bringing along the|<shard-or-keyrange>syntax didn't make sense based on the desired behavior.tablet_filtersandkeyspaces_to_watchwere made mutually exclusive to prevent situations where the flags required different keyspaces which would have suggested a non-obvious behavior (or had to fail anyway).Implementation
srvtopo.Serverimplementation that removes unwatched keyspaces from its resultstopo.Serverto prevent corrupting global SrvVSchema (c.f. this explainer from @demmer)GetSrvTopoto handle the error coming backIt additionally comes with a super thin implementation of a srvtopo.Server for tests.
Open Questions
With
GetTopoServernow returning an error I updated vschema_manager.go to cache a single reference to the topo server instead of getting a new one on each use to minimize error handling.In theory this could be problematic if the server pointer changes during this call but I wasn't able to identify any code that does that (and the get call isn't synchronized so it seems super unlikely).
Testing
Automated: Unit tests for the new filtering
srvtopo.Serverimpl,vagrant-scriptsh/test.shpassesManual:
Using the vagrant setup I spun up a cluster with:
2 keyspaces: aaa_keyspace, test_keyspace
10 vttablets: 5 fronting each keyspace
1 vtgate, 1vtctld
show vitess_keyspaceskeyspaces_to_watch=test_keyspacewas set onlytest_keyspacewas returned forshow vitess_keyspaces;select now() from dual;was functional