refactor tsh db#26182
Merged
GavinFrazar merged 1 commit intomasterfrom May 19, 2023
Merged
Conversation
ravicious
approved these changes
May 16, 2023
Member
ravicious
left a comment
There was a problem hiding this comment.
Good cleanup! 👍 I ran tsh db connect and tsh proxy db in a couple of variations to confirm that they still work as expected.
Base automatically changed from
gavinfrazar/fix-tsh-db-connect-cassandra
to
master
May 16, 2023 17:36
rosstimothy
reviewed
May 18, 2023
smallinsky
approved these changes
May 18, 2023
Contributor
Author
|
@hugoShaka needs group 2 approval, could you take a look? |
hugoShaka
approved these changes
May 19, 2023
* simplify and consolidate db info retrieval * avoid fetching the same database multiple times * simplify tsh db connect local proxy requirements
816c4c8 to
1464720
Compare
GavinFrazar
added a commit
that referenced
this pull request
May 20, 2023
backports #26182 to branch/v13. * simplify and consolidate db info retrieval * avoid fetching the same database multiple times * simplify tsh db connect local proxy requirements
Merged
GavinFrazar
added a commit
that referenced
this pull request
May 20, 2023
backport #26182 to branch/v12.
Merged
GavinFrazar
added a commit
that referenced
this pull request
May 22, 2023
backports #26182 to branch/v13. * simplify and consolidate db info retrieval * avoid fetching the same database multiple times * simplify tsh db connect local proxy requirements
GavinFrazar
added a commit
that referenced
this pull request
May 22, 2023
backport #26182 to branch/v12.
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.
This PR is a precursor to another PR for #22717 that I factored out.
The purpose of this PR is to simplify database info retrieval in
tsh db connect/proxy/loginand avoid fetching the same database more than once from the remote proxy.Motivation: I found myself having to add yet another place in the code that needed to check if a passed-in
types.Databaseis nil or fetch it, but since it was passed down, there was no good way to pass thetypes.Databaseback up without making a mess, and I wanted to avoid fetching the database multiple times (each fetch incurring a remote proxy dial and API call). Hence: this PR.The
getDatabaseInfofunction in particular was the main source of the problem before, because it did not guarantee returning a non-nilltypes.Database, so the code had to carefully check that it was non-nil or fetch it wherever that database was passed to.Instead, I created a wrapper type around
tlsca.RouteToDatabaseandtypes.Databasethat will only fetch the database for the route when needed, and saves the result so that we only ever dial the proxy once for it. Most of the PR is just renaming and plumbing that wrapper around.Stacked this PR on top of another PR for a minor bugfix: #26181