blob: c13cb7d54fa0d49728662eac0dbfa7273213a4ea [file] [edit]
package actions
import (
"errors"
"os/exec"
"strings"
)
// ShouldRetryGcloudComputeSsh returns true for errors that are retryable for gcloud compute ssh commands.
//
// Errors containing the words "timed out", or with exit status 255 (ssh timeout) are considered retryable.
func ShouldRetryGcloudComputeSsh(err error) bool {
if strings.Contains(err.Error(), "timed out") {
return true
}
// Exit code 255 is standard for SSH failures. Other codes indicate gcloud CLI errors.
if exitErr, ok := errors.AsType[*exec.ExitError](err); ok && exitErr.ExitCode() == 255 {
return true
}
return false
}