Skip to content
Merged
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
15 changes: 13 additions & 2 deletions ssh/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (

const (
// sshWaitPollInterval is the interval between SSH readiness polls.
sshWaitPollInterval = 2 * time.Second
sshWaitPollInterval = 200 * time.Millisecond

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

// Probe immediately before starting the ticker to avoid wasting
// up to one full poll interval when SSH is already ready.
probeCount := 1
if err := c.probe(ctx); err == nil {
span.SetAttributes(attribute.Int("ssh.probes_total", probeCount))
slog.Info("SSH is ready",
"host", c.host,
"port", c.port,
)
return nil
}

ticker := time.NewTicker(sshWaitPollInterval)
defer ticker.Stop()

probeCount := 0
for {
select {
case <-ctx.Done():
Expand Down
Loading