[vtadmin-api] Add static file service discovery implementation#7229
Merged
rohit-nayak-ps merged 4 commits intovitessio:masterfrom Dec 28, 2020
Merged
Conversation
Signed-off-by: Sara Bee <855595+doeg@users.noreply.github.com>
…VTGates in discovery_static_file_test.go Signed-off-by: Sara Bee <855595+doeg@users.noreply.github.com>
e041d75 to
0a7df91
Compare
dkhenry
approved these changes
Dec 28, 2020
Contributor
dkhenry
left a comment
There was a problem hiding this comment.
Looks good to me. If you do have two two requests I would make are
- Add in a full example json as a comment in the main implementation file.
- Add in malformed json to one of the tests.
Contributor
Author
@dkhenry Oh both really good suggestions! Thank you, I will do this. :D |
Signed-off-by: Sara Bee <855595+doeg@users.noreply.github.com>
Signed-off-by: Sara Bee <855595+doeg@users.noreply.github.com>
7 tasks
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.
Signed-off-by: Sara Bee 855595+doeg@users.noreply.github.com
Description
Two changes in this PR:
:15991in./docker/local/run.shso that vtadmin (running outside of Docker) can issue requestsThe best part is that now we can run vtadmin-api and vtadmin-web locally, using a local Vitess (in Docker or otherwise). 🎉 So we can add data fetching (and real data) to vtadmin-web 😈 finally the fun begins.
We can enhance this later on by watching the cluster config file(s) for changes so updates don't require a restart of vtadmin-api.
Many thanks as always to @ajm188 for answering my eight million golang questions! 💛
Running it locally
First, you'll want to run Vitess itself locally. 😸 I always run Vitess using Docker but this works fine with uncontainerized local Vitess too.
(@shlomi-noach, thank you again for the fix in #7213!)
Second, you'll need to create an empty vtgate credentials file to avoid the gRPC dialer bug mentioned in #7187. Location and filename don't matter since you'll be passing this in as a flag; I put mine at
/Users/sarabee/id1-grpc_vtgate_credentials.json:{ "Username": "", "Password": "" }Third, you'll want to create a cluster configuration file. This is the "static file" part of "static file service discovery". Assuming you're using the standard local Vitess set-up, you can steal this file as-is. (It comes with an entry for a bogus vtgate host to demonstrate that tagging works.) Again, filename and location don't matter since we'll be passing in the path as a flag; I put mine at
/Users/sarabee/vtadmin-cluster1.json.{ "vtgates": [ { "host": { "hostname": "127.0.0.1:15991" }, "tags": ["pool:pool1", "cell:zone1", "extra:tag"] }, { "host": { "hostname": "127.0.0.1:15992" }, "tags": ["dead-dove-do-not-eat"] } ] }Fourth, build this branch if you haven't already:
Fifth, start up vtadmin-api but make sure to update the filepaths for the vtgate creds file and static service discovery file you created above!
./bin/vtadmin \ --addr ":15999" \ --cluster-defaults "vtsql-credentials-path-tmpl=/Users/sarabee/id1-grpc_vtgate_credentials.json" \ --cluster "name=cluster1,id=id1,discovery=staticFile,discovery-staticFile-path=/Users/sarabee/vtadmin-cluster1.json,vtsql-discovery-tags=cell:zone1"Sixth and finally, we can curl vtadmin-api and get a valid response! 🎉
$ curl 127.0.0.1:15999/api/tablets {"result":{"tablets":[{"cluster":{"id":"id1","name":"cluster1"},"tablet":{"alias":{"cell":"zone1","uid":100},"hostname":"2780467e90c9","keyspace":"commerce","shard":"0","type":1,"master_term_start_time":{"seconds":1609176750}},"state":1},{"cluster":{"id":"id1","name":"cluster1"},"tablet":{"alias":{"cell":"zone1","uid":101},"hostname":"2780467e90c9","keyspace":"commerce","shard":"0","type":2},"state":1},{"cluster":{"id":"id1","name":"cluster1"},"tablet":{"alias":{"cell":"zone1","uid":102},"hostname":"2780467e90c9","keyspace":"commerce","shard":"0","type":3},"state":1}]},"ok":true}Related Issue(s)
Checklist
Deployment Notes
N/A since vtadmin isn't in the deployment path :D
Impacted Areas in Vitess
Components that this PR will affect: