Skip to content

Commit 90cabbc

Browse files
authored
fix: reduce SSH dial timeout for faster Firecracker polling (#940)
Reduces SSH dial timeout in WaitForSSH polling to 2s (from 7s) for faster Firecracker boot detection. Adds DialTimeout field to Remote struct so non-polling paths (RemoteRun, SFTP) keep the 7s default and are unaffected on slow/high-latency routes.
1 parent 56370c7 commit 90cabbc

1 file changed

Lines changed: 14 additions & 8 deletions

File tree

‎internal/tools/remote-run.go‎

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,14 @@ const (
2323
)
2424

2525
type Remote struct {
26-
Username string
27-
IPAddress string
28-
SSHPort int
29-
PrivateKey string
30-
Passphrase string
31-
Spinner *ui.Spinner
32-
Client *ssh.Client
26+
Username string
27+
IPAddress string
28+
SSHPort int
29+
PrivateKey string
30+
Passphrase string
31+
Spinner *ui.Spinner
32+
Client *ssh.Client
33+
DialTimeout time.Duration // 0 means default (7s); set to a shorter value for fast-retry polling
3334
}
3435

3536
type RemoteRunConfig struct {
@@ -91,10 +92,14 @@ func (r *Remote) NewSSHConnection() error {
9192
}
9293
}
9394
// Authentication
95+
dialTimeout := r.DialTimeout
96+
if dialTimeout == 0 {
97+
dialTimeout = 7 * time.Second
98+
}
9499
config := &ssh.ClientConfig{
95100
User: r.Username,
96101
HostKeyCallback: ssh.InsecureIgnoreHostKey(),
97-
Timeout: time.Second * 7,
102+
Timeout: dialTimeout,
98103
Auth: []ssh.AuthMethod{
99104
ssh.PublicKeys(key),
100105
},
@@ -120,6 +125,7 @@ func (r *Remote) WaitForSSH(timeout string) {
120125

121126
timer := time.After(duration)
122127

128+
r.DialTimeout = 2 * time.Second
123129
for {
124130
select {
125131
case <-timer:

0 commit comments

Comments
 (0)
⌂ 换网址