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 going away
  • Loading branch information
Emyrk committed May 8, 2023
commit 98a7740255ef6a3f28ff8bfdf8dcf7db8ed76e2d
11 changes: 6 additions & 5 deletions enterprise/wsproxy/wsproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,11 +250,12 @@ func New(ctx context.Context, opts *Options) (*Server, error) {

func (s *Server) Close() error {
s.cancel()
go func() {
// Do this in a go routine to not block the close. This is allowed
// to fail, it is just a courtesy to the dashboard.
_ = s.SDKClient.WorkspaceProxyGoingAway(context.Background())
}()

// A timeout to prevent the SDK from blocking the server shutdown.
tmp, cancel := context.WithTimeout(context.Background(), 3*time.Second)
defer cancel()
_ = s.SDKClient.WorkspaceProxyGoingAway(tmp)

return s.AppServer.Close()
}

Expand Down
4 changes: 2 additions & 2 deletions site/src/api/typesGenerated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1485,12 +1485,12 @@ export const ProvisionerTypes: ProvisionerType[] = ["echo", "terraform"]

// From codersdk/workspaceproxy.go
export type ProxyHealthStatus =
| "reachable"
| "ok"
| "unhealthy"
| "unreachable"
| "unregistered"
export const ProxyHealthStatuses: ProxyHealthStatus[] = [
"reachable",
"ok",
"unhealthy",
"unreachable",
"unregistered",
Expand Down