Skip to content

[server] better handle workspacePageClose endpoint response status and log ctx #11817

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 1 commit into from
Aug 3, 2022

Conversation

mustard-mh
Copy link
Contributor

@mustard-mh mustard-mh commented Aug 2, 2022

Description

In previous PR, we did not handle the json-rpc response status #11643 (comment) of server instance and sharing workspace access #11643 (comment), this PR will handle it and add proper log context #11643 (comment)

We removed accessGuard of sharing, see reason in How to test section

Related Issue(s)

Fixes #

How to test

Check if it will process with sharing workspace or not

No need to test with sharing, since sharing workspace have no update permission on instance which server sendHeartbeat required. This is as expected.

export class SharedWorkspaceAccessGuard implements ResourceAccessGuard {
async canAccess(resource: GuardedResource, operation: ResourceAccessOp): Promise<boolean> {
switch (resource.kind) {
case "workspace":
return operation == "get" && resource.subject.shareable === true;
case "workspaceInstance":
return operation == "get" && !!resource.workspace.shareable;
default:
return false;
}
}
}

await this.guardAccess({ kind: "workspaceInstance", subject: wsi, workspace: ws }, "update");

Can't test with response status code since all errors thrown in send heartbeat ends with "does not exist".

if (e.message && typeof e.message === "string" && (e.message as String).endsWith("does not exist")) {

Release Notes

NONE

Documentation

Werft options:

  • /werft with-preview

@mustard-mh mustard-mh requested a review from a team August 2, 2022 18:11
@werft-gitpod-dev-com
Copy link

started the job as gitpod-build-hw-hb-s-2.1 because the annotations in the pull request description changed
(with .werft/ from main)

@roboquat roboquat added the size/M label Aug 2, 2022
@github-actions github-actions bot added the team: webapp Issue belongs to the WebApp team label Aug 2, 2022
@mustard-mh mustard-mh marked this pull request as draft August 2, 2022 18:11
@mustard-mh mustard-mh force-pushed the hw/hb-s-2 branch 4 times, most recently from ed52e6e to 87770c7 Compare August 3, 2022 03:49
@mustard-mh mustard-mh changed the title [server] better handling of response status and log ctx [server] better handle workspacePageClose endpoint response status and log ctx Aug 3, 2022
@@ -291,33 +292,29 @@ export class UserController {
router.post(
"/auth/workspacePageClose/:instanceID",
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
const logCtx: LogContext = { instanceId: req.params.instanceID };
Copy link
Member

Choose a reason for hiding this comment

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

🧡

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 changes LGTM! 👍

Copy link
Contributor

@iQQBot iQQBot left a comment

Choose a reason for hiding this comment

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

LGTM

@mustard-mh mustard-mh marked this pull request as ready for review August 3, 2022 08:47
@roboquat roboquat merged commit 204cdb5 into main Aug 3, 2022
@roboquat roboquat deleted the hw/hb-s-2 branch August 3, 2022 08:47
@roboquat roboquat added deployed: webapp Meta team change is running in production deployed Change is completely running in production labels Aug 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deployed: webapp Meta team change is running in production deployed Change is completely running in production release-note-none size/M team: webapp Issue belongs to the WebApp team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants