Skip to content
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

[vnet] refactor AppProvider for Windows implementation #51216

Merged
merged 8 commits into from
Jan 24, 2025

Conversation

nklaassen
Copy link
Contributor

@nklaassen nklaassen commented Jan 18, 2025

Part of RFD 195.

This PR refactors the way that the VNet client applications (Connect and tsh vnet) provide teleport clients and other functionality to the VNet library. The goal is to move toward an interface that can be implemented locally OR over gRPC so that the VNet Windows service can interact with the client application from another process.

The current implementation (prior to this change) has both clients implementing an interface called vnet.AppProvider. In this PR, each client now implements vnet.ClientApplication. vnet.localAppProvider now wraps vnet.ClientApplication to implement the now-unexported vnet.appProvider. In a following PR, I will add a vnet.remoteAppProvider that also implements this interface but interacts with the client application over gRPC.

This is basically a rewrite of lib/vnet/app_resolver.go so the diff may not be very useful there, but the new code on its own should be reviewable.

The parent PR #51215 adds the necessary proto files.

@nklaassen nklaassen added no-changelog Indicates that a PR does not require a changelog entry vnet backport/branch/v17 labels Jan 18, 2025
@nklaassen nklaassen requested a review from ravicious January 18, 2025 02:00
@github-actions github-actions bot requested review from hugoShaka and vapopov January 18, 2025 02:00
@github-actions github-actions bot added size/md tsh tsh - Teleport's command line tool for logging into nodes running Teleport. labels Jan 18, 2025
lib/vnet/local_app_provider.go Outdated Show resolved Hide resolved
// Don't return an unexpected error so we can try to find the app in different clusters or forward the
// request upstream.
log.InfoContext(ctx, "Failed to list application servers", "error", err)
return nil, errNoTCPHandler
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since on error this method always logs err and then returns errNoTCPHandler, could we instead move this behavior up, always return plain err from resolveAppInfoForCluster and document why we're not using trace.Wrap?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for calling it out because on taking another look, after we know there's a matching app, i think this function should actually be returning the errors. updated to do so

Comment on lines 20 to 26
// ClientApplication is the common interface implemented by each VNet client
// application: Connect and tsh. It provides methods to list user profiles, get
// cluster clients, issue app certificates, and report metrics and errors.
type ClientApplication interface {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ClientApplication is one of those names that at first seems weird, but makes sense once you understand what's happening. Though I have to say that the ClientApplicationService proto service seems to have a slightly better comment. It explicitly mentions the admin process, so I think it makes it easier to understand why this thing is named "client application".

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated the comment, hopefully it's more clear

@ravicious
Copy link
Member

ravicious commented Jan 22, 2025

Side note, I really like git's colormoved option for PRs like this one. It's able to explicitly show me which lines were merely moved from somewhere else vs which ones were added.

https://gravitational.slack.com/archives/C08HF8E9F/p1705320635896619
https://matklad.github.io/2023/12/31/git-things.html

@nklaassen
Copy link
Contributor Author

friendly ping @hugoShaka or @vapopov, not necessarily looking for you guys to do a deep dive on vnet and understand everything that's changing here but i need another review on the code

@public-teleport-github-review-bot public-teleport-github-review-bot bot removed the request for review from hugoShaka January 22, 2025 22:28
Base automatically changed from nklaassen/vnet-protos to master January 23, 2025 22:55
@nklaassen nklaassen force-pushed the nklaassen/refactor-appprovider branch from a3a4c20 to 53684bd Compare January 23, 2025 23:01
@nklaassen nklaassen enabled auto-merge January 23, 2025 23:02
@nklaassen nklaassen added this pull request to the merge queue Jan 24, 2025
Merged via the queue into master with commit c8d8c21 Jan 24, 2025
41 checks passed
@nklaassen nklaassen deleted the nklaassen/refactor-appprovider branch January 24, 2025 00:29
@public-teleport-github-review-bot

@nklaassen See the table below for backport results.

Branch Result
branch/v17 Failed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/branch/v17 no-changelog Indicates that a PR does not require a changelog entry size/md tsh tsh - Teleport's command line tool for logging into nodes running Teleport. vnet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants