Merge pull request #103 from github/fix-EnvironmentNotShutdown

in Start, ignore HTTP 503 with reason 7 EnvironmentNotShutdown
This commit is contained in:
Alan Donovan 2021-08-31 09:18:45 -04:00 committed by GitHub
commit dc40d99096

View file

@ -274,11 +274,17 @@ func (a *API) StartCodespace(ctx context.Context, token string, codespace *Codes
}
if resp.StatusCode != http.StatusOK {
// Error response is numeric code and/or string message, not JSON.
// Error response is typically a numeric code (not an error message, nor JSON).
if len(b) > 100 {
b = append(b[:97], "..."...)
}
return fmt.Errorf("failed to start codespace: %s", b)
if resp.StatusCode == http.StatusServiceUnavailable && strings.TrimSpace(string(b)) == "7" {
// HTTP 503 with error code 7 (EnvironmentNotShutdown) is benign.
// Ignore it.
} else {
return fmt.Errorf("failed to start codespace: %s", b)
}
}
return nil