Skip to content

Commit

Permalink
Testing: add retries for Windows Core ssh issues (#1514)
Browse files Browse the repository at this point in the history
  • Loading branch information
martijnvans authored and franciscovalentecastro committed Nov 21, 2023
1 parent 1570ecb commit d6a056f
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion integration_test/gce/gce_testing.go
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,11 @@ func IsWindows(platform string) bool {
return strings.HasPrefix(platform, "windows-") || strings.HasPrefix(platform, "sql-")
}

// IsWindowsCore returns whether the given platform is a version of Windows core.
func IsWindowsCore(platform string) bool {
return strings.HasPrefix(platform, "windows-") && strings.HasSuffix(platform, "-core")
}

// PlatformKind returns "linux" or "windows" based on the given platform.
func PlatformKind(platform string) string {
if IsWindows(platform) {
Expand Down Expand Up @@ -1332,6 +1337,8 @@ func CreateInstance(origCtx context.Context, logger *log.Logger, options VMOptio
strings.Contains(err.Error(), "Internal error") ||
// Instance creation can also fail due to service unavailability.
strings.Contains(err.Error(), "currently unavailable") ||
// windows-*-core instances sometimes fail to be ssh-able: b/305721001
(IsWindowsCore(options.Platform) && strings.Contains(err.Error(), windowsStartupFailedMessage)) ||
// SLES instances sometimes fail to be ssh-able: b/186426190
(IsSUSE(options.Platform) && strings.Contains(err.Error(), startupFailedMessage)) ||
strings.Contains(err.Error(), prepareSLESMessage)
Expand Down Expand Up @@ -1705,6 +1712,8 @@ func FetchMetadata(ctx context.Context, logger *log.Logger, vm *VM) (map[string]
const (
// Retry errors that look like b/186426190.
startupFailedMessage = "waitForStartLinux() failed: waiting for startup timed out"
// Retry errors that look like b/305721001.
windowsStartupFailedMessage = "waitForStartWindows() failed: ran out of attempts waiting for dummy command to run."
)

func waitForStartWindows(ctx context.Context, logger *log.Logger, vm *VM) error {
Expand All @@ -1723,7 +1732,7 @@ func waitForStartWindows(ctx context.Context, logger *log.Logger, vm *VM) error

backoffPolicy := backoff.WithContext(backoff.NewConstantBackOff(vmInitBackoffDuration), ctx)
if err := backoff.Retry(printFoo, backoffPolicy); err != nil {
return fmt.Errorf("waitForStartWindows() failed: ran out of attempts waiting for dummy command to run. err=%v", err)
return fmt.Errorf("%s err=%v", windowsStartupFailedMessage, err)
}
return nil
}
Expand Down

0 comments on commit d6a056f

Please sign in to comment.