Skip to content

Commit

Permalink
Add CombinedLogger that can handle multiple Logger instances
Browse files Browse the repository at this point in the history
  • Loading branch information
janekbaraniewski authored and pascalbreuninger committed Dec 4, 2024
1 parent 77b2ad4 commit 3727786
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions cmd/ssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"encoding/base64"
"fmt"
"io"
"math"
"os"
"os/exec"
"path/filepath"
Expand All @@ -30,6 +31,8 @@ import (
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"golang.org/x/crypto/ssh"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/client-go/util/retry"
)

const (
Expand Down Expand Up @@ -647,11 +650,20 @@ func startWorkspaceCredentialServer(ctx context.Context, client *ssh.Client, use
args = append(args, "--runner")
command = fmt.Sprintf("%s %s", command, strings.Join(args, " "))

if err := devssh.Run(ctx, client, command, stdin, stdout, writer, nil); err != nil {
return fmt.Errorf("run credentials server: %w", err)
}

return nil
return retry.OnError(wait.Backoff{
Steps: math.MaxInt,
Duration: 500 * time.Millisecond,
Factor: 1,
Jitter: 0.1,
}, func(err error) bool {
if ctx.Err() != nil {
log.Infof("Context canceled, stopping credentials server: %v", ctx.Err())
return false
}
return true
}, func() error {
return devssh.Run(ctx, client, command, stdin, stdout, writer, nil)
})
}

func startLocalServer(ctx context.Context, allowGitCredentials, allowDockerCredentials bool, gitUsername, gitToken string, stdoutReader io.Reader, stdinWriter io.WriteCloser, log log.Logger) error {
Expand Down

0 comments on commit 3727786

Please sign in to comment.