Skip to content
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

[server] make gRPC clients viable in non-HTTP/2-compatible environments #20565

Merged
merged 2 commits into from
Jan 30, 2025

Conversation

filiptronicek
Copy link
Member

@filiptronicek filiptronicek commented Jan 29, 2025

Description

This PR makes a couple of related changes:

  • most notably, whenever determining what client an API request should use, we always prefer the jsonRPC client if it's available and the request is a server-side-streaming request --> this should eliminate our HTTP/2 problems, hopefully
  • removes the use of disableWebsocketPrebuildUpdates, and instead introduces a by-organization subscription for prebuild updates. This makes the listening much more efficient (requiring way fewer listeners) and scales well even with thousands of projects. Permission-wise, it relies on the organization's read_prebuild permission.

Related Issue(s)

Fixes CLC-1106

How to test

  1. Sign up for https://ft-stream-websockets.preview.gitpod-dev.com/workspaces
  2. Try running a prebuild. It should stream updates via a websocket, but you should get other API requests to the prebuild service through gRPC.

@@ -17,7 +17,7 @@ schema: |-

permission make_admin = installation->admin + organization->installation_admin

// administrate is for changes such as blocking or verifiying, i.e. things that only admins can do on user
// administrate is for changes such as blocking or verifying, i.e. things that only admins can do on user
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's not change this if not needed, I'm 95% sure it will trigger a spicedb rollover which I'd like to avoid, because it has the tendency to take long time to cycle and not behave well in the meantim.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh right, good point! Will revert to not cause unnecessary trouble

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in bda0663 (#20565)

@@ -39,6 +39,7 @@ export class PrebuildUpdater {
const span = TraceContext.startSpan("updatePrebuiltWorkspace", ctx);
try {
const prebuild = await this.workspaceDB.trace({ span }).findPrebuildByWorkspaceID(status.metadata!.metaId!);
const workspace = await this.workspaceDB.trace({ span }).findById(workspaceId);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a bit weird that PrebuiltWorkspace has a projectId but no organizationId... 😬 But it is what it is I guess.

Copy link
Member

@geropl geropl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code LGTM, tested and works! ✔️

minus the nits commented

Co-authored-by: Gero Posmyk-Leinemann <[email protected]>
Tool: gitpod/catfood.gitpod.cloud
@@ -241,7 +187,8 @@ function createServiceClient<T extends ServiceType>(
}
return (async function* () {
try {
const client = await resolveClient();
// for server streaming, we prefer jsonRPC
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for future reference: the only streaming methods we implement in our public api v1 are:

  • WorkspaceService.WatchWorkspaceStatus
  • PrebuildService.WatchPrebuild

@roboquat roboquat merged commit 9b574a9 into main Jan 30, 2025
20 checks passed
@roboquat roboquat deleted the ft/stream-websockets branch January 30, 2025 12:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants