From ea97e2e73dfe8b89ffdaafb1f9c83a8cd4f2919c Mon Sep 17 00:00:00 2001 From: Alan Donovan Date: Mon, 30 Aug 2021 18:15:37 -0400 Subject: [PATCH 1/2] remove sleep 1s --- cmd/ghcs/ssh.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/cmd/ghcs/ssh.go b/cmd/ghcs/ssh.go index 84964829a..23f49c1d1 100644 --- a/cmd/ghcs/ssh.go +++ b/cmd/ghcs/ssh.go @@ -6,7 +6,6 @@ import ( "fmt" "os" "strings" - "time" "github.com/github/ghcs/api" "github.com/github/ghcs/cmd/ghcs/output" @@ -155,8 +154,6 @@ func setupSSH(ctx context.Context, logger *output.Logger, terminal *liveshare.Te return fmt.Errorf("error closing stream: %v", err) } - time.Sleep(1 * time.Second) - return nil } From 15dab395a519bee18c9b2a2f7bd7cebafc578b1b Mon Sep 17 00:00:00 2001 From: Alan Donovan Date: Mon, 30 Aug 2021 18:23:55 -0400 Subject: [PATCH 2/2] in Start, ignore HTTP 503 with reason 7 EnvironmentNotShutdown --- api/api.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/api/api.go b/api/api.go index a8f6ea724..bb3eba489 100644 --- a/api/api.go +++ b/api/api.go @@ -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