| 399 | } |
| 400 | |
| 401 | func shouldRetrySSH(err error) bool { |
| 402 | if err == nil { |
| 403 | return false |
| 404 | } |
| 405 | msg := strings.ToLower(err.Error()) |
| 406 | |
| 407 | // Network and connection errors |
| 408 | if messageContainsAny(msg, |
| 409 | "connection refused", |
| 410 | "no route to host", |
| 411 | "operation timed out", |
| 412 | "i/o timeout", |
| 413 | "connection reset", |
| 414 | "kex_exchange_identification", |
| 415 | "connection closed", |
| 416 | "handshake failed", |
| 417 | "kex", |
| 418 | ) { |
| 419 | return true |
| 420 | } |
| 421 | |
| 422 | // Auth errors are retried because keys may still be propagating to the instance |
| 423 | if messageContainsAny(msg, |
| 424 | "unable to authenticate", |
| 425 | "no supported methods remain", |
| 426 | ) { |
| 427 | return true |
| 428 | } |
| 429 | return false |
| 430 | } |
| 431 | |
| 432 | func sleepWithContext(ctx context.Context, d time.Duration) error { |
| 433 | if ctx == nil { |