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

Use serverUID for web scp target #23124

Merged
merged 7 commits into from
Mar 15, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 2 additions & 11 deletions lib/client/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -1850,7 +1850,7 @@ func PlayFile(ctx context.Context, tarFile io.Reader, sid string) error {

// ExecuteSCP executes SCP command. It executes scp.Command using
// lower-level API integrations that mimic SCP CLI command behavior
func (tc *TeleportClient) ExecuteSCP(ctx context.Context, cmd scp.Command) (err error) {
func (tc *TeleportClient) ExecuteSCP(ctx context.Context, serverAddr string, cmd scp.Command) (err error) {
avatus marked this conversation as resolved.
Show resolved Hide resolved
ctx, span := tc.Tracer.Start(
ctx,
"teleportClient/ExecuteSCP",
Expand All @@ -1869,19 +1869,10 @@ func (tc *TeleportClient) ExecuteSCP(ctx context.Context, cmd scp.Command) (err
}
defer proxyClient.Close()

// which nodes are we executing this commands on?
nodeAddrs, err := tc.getTargetNodes(ctx, proxyClient)
if err != nil {
return trace.Wrap(err)
}
if len(nodeAddrs) == 0 {
return trace.BadParameter("no target host specified")
}

nodeClient, err := tc.ConnectToNode(
ctx,
proxyClient,
NodeDetails{Addr: nodeAddrs[0], Namespace: tc.Namespace, Cluster: tc.SiteName},
NodeDetails{Addr: serverAddr + ":0", Namespace: tc.Namespace, Cluster: tc.SiteName},
Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah I'm not sure what the :0 is or why it's necessary. Once you figure it out, a comment is probably warranted.

Copy link
Contributor Author

@avatus avatus Mar 15, 2023

Choose a reason for hiding this comment

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

Add a comment!

tc.Config.HostLogin,
)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions lib/web/files.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func (f *fileTransfer) download(req fileTransferRequest, httpReq *http.Request,
return trace.Wrap(err)
}

err = tc.ExecuteSCP(httpReq.Context(), cmd)
err = tc.ExecuteSCP(httpReq.Context(), req.server, cmd)
Copy link
Contributor

Choose a reason for hiding this comment

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

if not too much trouble, can we rename server to serverID?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No trouble at all! Fixed. much more clear this way.

if err != nil {
return trace.Wrap(err)
}
Expand All @@ -130,7 +130,7 @@ func (f *fileTransfer) upload(req fileTransferRequest, httpReq *http.Request) er
return trace.Wrap(err)
}

err = tc.ExecuteSCP(httpReq.Context(), cmd)
err = tc.ExecuteSCP(httpReq.Context(), req.server, cmd)
if err != nil {
return trace.Wrap(err)
}
Expand Down