Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions pkg/client/clientimplementation/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@ import (
)

type StartServicesDaemonOptions struct {
DevPodConfig *config.Config
Client client.DaemonClient
SSHClient *ssh.Client
User string
Log log.Logger
ForwardPorts bool
ExtraPorts []string
DevPodConfig *config.Config
Client client.DaemonClient
SSHClient *ssh.Client
User string
Log log.Logger
ForwardPorts bool
ExtraPorts []string
GitSSHSigningKey string
}

type credentialConfig struct {
Expand Down Expand Up @@ -54,6 +55,7 @@ func StartServicesDaemon(ctx context.Context, opts StartServicesDaemonOptions) e
ConfigureDockerCredentials: credConfig.docker,
ConfigureGitCredentials: credConfig.git,
ConfigureGitSSHSignatureHelper: credConfig.gitSSHSignature,
GitSSHSigningKey: opts.GitSSHSigningKey,
Log: opts.Log,
},
)
Expand Down
15 changes: 8 additions & 7 deletions pkg/ide/opener/opener.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,13 +236,14 @@ func makeDaemonStartFunc(
err = clientimplementation.StartServicesDaemon(
ctx,
clientimplementation.StartServicesDaemonOptions{
DevPodConfig: params.DevPodConfig,
Client: daemonClient,
SSHClient: toolClient,
User: params.User,
Log: params.Log,
ForwardPorts: forwardPorts,
ExtraPorts: extraPorts,
DevPodConfig: params.DevPodConfig,
Client: daemonClient,
SSHClient: toolClient,
User: params.User,
Log: params.Log,
ForwardPorts: forwardPorts,
ExtraPorts: extraPorts,
GitSSHSigningKey: params.GitSSHSigningKey,
},
)
if err != nil {
Expand Down
14 changes: 10 additions & 4 deletions pkg/tunnel/browser.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ type BrowserTunnelParams struct {
func StartBrowserTunnel(p BrowserTunnelParams) error {
if p.AuthSockID != "" {
go func() {
if err := SetupBackhaul(p.Client, p.AuthSockID, p.Logger); err != nil {
if err := SetupBackhaul(p.Ctx, p.Client, p.AuthSockID, p.Logger); err != nil {
p.Logger.Error("Failed to setup backhaul SSH connection: ", err)
}
}()
Expand Down Expand Up @@ -120,7 +120,12 @@ func runBrowserTunnelServices(
}

// SetupBackhaul sets up a long-running SSH connection for backhaul.
func SetupBackhaul(client client2.BaseWorkspaceClient, authSockID string, logger log.Logger) error {
func SetupBackhaul(
ctx context.Context,
client client2.BaseWorkspaceClient,
authSockID string,
logger log.Logger,
) error {
execPath, err := os.Executable()
if err != nil {
return err
Expand All @@ -136,7 +141,7 @@ func SetupBackhaul(client client2.BaseWorkspaceClient, authSockID string, logger
}

//nolint:gosec // execPath is the current binary, arguments are controlled
backhaulCmd := exec.Command(
backhaulCmd := exec.CommandContext(ctx,
execPath,
"ssh",
"--agent-forwarding=true",
Expand All @@ -149,7 +154,7 @@ func SetupBackhaul(client client2.BaseWorkspaceClient, authSockID string, logger
client.Workspace(),
"--log-output=raw",
"--command",
"while true; do sleep 6000000; done",
"while true; do sleep 6000000; done", // sleep infinity is not available on all systems
)

if logger.GetLevel() == logrus.DebugLevel {
Expand All @@ -159,6 +164,7 @@ func SetupBackhaul(client client2.BaseWorkspaceClient, authSockID string, logger
logger.Info("Setting up backhaul SSH connection")

writer := logger.Writer(logrus.InfoLevel, false)
defer func() { _ = writer.Close() }()

backhaulCmd.Stdout = writer
backhaulCmd.Stderr = writer
Expand Down