| 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 | |
| } |