Skip to content

Commit 23a04e8

Browse files
JAORMXclaude
andcommitted
Reduce SSH poll interval to 200ms with immediate probe
Change sshWaitPollInterval from 2s to 200ms and probe immediately on entry before starting the ticker. This avoids wasting up to one full poll interval when SSH becomes ready between ticks. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent bef1230 commit 23a04e8

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

ssh/client.go

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424

2525
const (
2626
// sshWaitPollInterval is the interval between SSH readiness polls.
27-
sshWaitPollInterval = 2 * time.Second
27+
sshWaitPollInterval = 200 * time.Millisecond
2828

2929
// defaultSSHTimeout is the default timeout for SSH connection attempts.
3030
defaultSSHTimeout = 10 * time.Second
@@ -232,10 +232,21 @@ func (c *Client) WaitForReady(ctx context.Context) error {
232232
"user", c.user,
233233
)
234234

235+
// Probe immediately before starting the ticker to avoid wasting
236+
// up to one full poll interval when SSH is already ready.
237+
probeCount := 1
238+
if err := c.probe(ctx); err == nil {
239+
span.SetAttributes(attribute.Int("ssh.probes_total", probeCount))
240+
slog.Info("SSH is ready",
241+
"host", c.host,
242+
"port", c.port,
243+
)
244+
return nil
245+
}
246+
235247
ticker := time.NewTicker(sshWaitPollInterval)
236248
defer ticker.Stop()
237249

238-
probeCount := 0
239250
for {
240251
select {
241252
case <-ctx.Done():

0 commit comments

Comments
 (0)