Skip to content

chore: Implement workspace proxy going away (graceful shutdown) #7459

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
May 11, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix linting
  • Loading branch information
Emyrk committed May 8, 2023
commit 42f81542add98575b0691430fece89106db03f3c
2 changes: 1 addition & 1 deletion enterprise/coderd/coderd.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func New(ctx context.Context, options *Options) (*API, error) {
httpmw.ExtractWorkspaceProxyParam(api.Database),
)

r.Get("/", api.getWorkspaceProxy)
r.Get("/", api.fetchWorkspaceProxy)
r.Delete("/", api.deleteWorkspaceProxy)
})
})
Expand Down
2 changes: 1 addition & 1 deletion enterprise/coderd/workspaceproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ func (api *API) workspaceProxies(rw http.ResponseWriter, r *http.Request) {
// @Param workspaceproxy path string true "Proxy ID or name" format(uuid)
// @Success 200 {object} codersdk.WorkspaceProxy
// @Router /workspaceproxies/{workspaceproxy} [get]
func (api *API) getWorkspaceProxy(rw http.ResponseWriter, r *http.Request) {
func (api *API) fetchWorkspaceProxy(rw http.ResponseWriter, r *http.Request) {
var (
ctx = r.Context()
proxy = httpmw.WorkspaceProxyParam(r)
Expand Down
4 changes: 2 additions & 2 deletions enterprise/coderd/workspaceproxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ func TestRegions(t *testing.T) {
return false
}
return proxy.Status.Status == codersdk.ProxyHealthy
}, time.Second*10, time.Millisecond*100, "proxy never became healthy")
}, testutil.WaitShort, testutil.IntervalFast, "proxy never became healthy")

_ = proxy.Close()
// The proxy should tell the primary on close that is is no longer healthy.
Expand All @@ -231,7 +231,7 @@ func TestRegions(t *testing.T) {
return false
}
return proxy.Status.Status == codersdk.ProxyUnhealthy
}, time.Second*10, time.Millisecond*100, "proxy never became unhealthy after close")
}, testutil.WaitShort, testutil.IntervalFast, "proxy never became unhealthy after close")
})
}

Expand Down
1 change: 1 addition & 0 deletions enterprise/wsproxy/wsproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ func (s *Server) healthReport(rw http.ResponseWriter, r *http.Request) {
// app, so the webserver AND the proxy will be shut down at the same time.
if s.ctx.Err() != nil {
httpapi.Write(r.Context(), rw, http.StatusInternalServerError, "workspace proxy in middle of shutting down")
return
}

// Hit the build info to do basic version checking.
Expand Down