Skip to content

Commit 326b1ee

Browse files
committed
ssh: improve logging for pure SSH protocol
Let's improve the logging for the pure SSH protocol so that when we have a problem, it's easier for users to use the trace output to figure out what's wrong.
1 parent 91947ab commit 326b1ee

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

ssh/connection.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"github.com/git-lfs/git-lfs/v3/config"
77
"github.com/git-lfs/git-lfs/v3/subprocess"
88
"github.com/git-lfs/pktline"
9+
"github.com/rubyist/tracerx"
910
)
1011

1112
type SSHTransfer struct {
@@ -35,6 +36,7 @@ func NewSSHTransfer(osEnv config.Environment, gitEnv config.Environment, meta *S
3536
}
3637

3738
func startConnection(id int, osEnv config.Environment, gitEnv config.Environment, meta *SSHMetadata, operation string) (*PktlineConnection, bool, error) {
39+
tracerx.Printf("spawning pure SSH connection")
3840
exe, args, multiplexing := GetLFSExeAndArgs(osEnv, gitEnv, meta, "git-lfs-transfer", operation, true)
3941
cmd, err := subprocess.ExecCommand(exe, args...)
4042
if err != nil {
@@ -71,6 +73,7 @@ func startConnection(id int, osEnv config.Environment, gitEnv config.Environment
7173
w.Close()
7274
cmd.Wait()
7375
}
76+
tracerx.Printf("pure SSH connection successful")
7477
return conn, multiplexing, err
7578
}
7679

@@ -121,6 +124,7 @@ func (tr *SSHTransfer) setConnectionCount(n int) error {
121124
count := len(tr.conn)
122125
if n < count {
123126
for _, item := range tr.conn[n:count] {
127+
tracerx.Printf("terminating pure SSH connection (%d -> %d)", count, n)
124128
if err := item.End(); err != nil {
125129
return err
126130
}
@@ -130,6 +134,7 @@ func (tr *SSHTransfer) setConnectionCount(n int) error {
130134
for i := count; i < n; i++ {
131135
conn, _, err := startConnection(i, tr.osEnv, tr.gitEnv, tr.meta, tr.operation)
132136
if err != nil {
137+
tracerx.Printf("failed to spawn pure SSH connection: %s", err)
133138
return err
134139
}
135140
tr.conn = append(tr.conn, conn)
@@ -139,5 +144,6 @@ func (tr *SSHTransfer) setConnectionCount(n int) error {
139144
}
140145

141146
func (tr *SSHTransfer) Shutdown() error {
147+
tracerx.Printf("shutting down pure SSH connection")
142148
return tr.SetConnectionCount(0)
143149
}

0 commit comments

Comments
 (0)