File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ import (
2424
2525const (
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 ():
You can’t perform that action at this time.
0 commit comments