Skip to content

Migrate WorkspaceService snapshot methods #19204

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 3 commits into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
34 changes: 34 additions & 0 deletions components/dashboard/src/service/json-rpc-workspace-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ import {
StopWorkspaceRequest,
StopWorkspaceResponse,
AdmissionLevel,
CreateWorkspaceSnapshotRequest,
CreateWorkspaceSnapshotResponse,
WaitForWorkspaceSnapshotRequest,
WaitForWorkspaceSnapshotResponse,
} from "@gitpod/public-api/lib/gitpod/v1/workspace_pb";
import { converter } from "./public-api";
import { getGitpodService } from "./service";
Expand Down Expand Up @@ -359,4 +363,34 @@ export class JsonRpcWorkspaceClient implements PromiseClient<typeof WorkspaceSer
response.workspaceClasses = list.map((i) => converter.toWorkspaceClass(i));
return response;
}

async createWorkspaceSnapshot(
req: PartialMessage<CreateWorkspaceSnapshotRequest>,
_options?: CallOptions | undefined,
): Promise<CreateWorkspaceSnapshotResponse> {
if (!req.workspaceId) {
throw new ApplicationError(ErrorCodes.BAD_REQUEST, "workspaceId is required");
}
const snapshotId = await getGitpodService().server.takeSnapshot({
workspaceId: req.workspaceId,
dontWait: true,
});
return new CreateWorkspaceSnapshotResponse({
snapshot: converter.toWorkspaceSnapshot({
id: snapshotId,
originalWorkspaceId: req.workspaceId,
}),
});
}

async waitForWorkspaceSnapshot(
req: PartialMessage<WaitForWorkspaceSnapshotRequest>,
_options?: CallOptions | undefined,
): Promise<WaitForWorkspaceSnapshotResponse> {
if (!req.snapshotId || !uuidValidate(req.snapshotId)) {
throw new ApplicationError(ErrorCodes.BAD_REQUEST, "snapshotId is required");
}
await getGitpodService().server.waitForSnapshot(req.snapshotId);
return new WaitForWorkspaceSnapshotResponse();
}
}
37 changes: 37 additions & 0 deletions components/public-api/gitpod/v1/workspace.proto
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,13 @@ service WorkspaceService {
// GetWorkspaceEditorCredentials returns an credentials that is used in editor
// to encrypt and decrypt secrets
rpc GetWorkspaceEditorCredentials(GetWorkspaceEditorCredentialsRequest) returns (GetWorkspaceEditorCredentialsResponse) {}

// CreateWorkspaceSnapshot creates a snapshot of the workspace that can be
// shared with others.
rpc CreateWorkspaceSnapshot(CreateWorkspaceSnapshotRequest) returns (CreateWorkspaceSnapshotResponse) {}

// WaitWorkspaceSnapshot waits for the snapshot to be available or failed.
rpc WaitForWorkspaceSnapshot(WaitForWorkspaceSnapshotRequest) returns (WaitForWorkspaceSnapshotResponse) {}
}

message GetWorkspaceRequest {
Expand Down Expand Up @@ -753,3 +760,33 @@ message WorkspaceClass {
// is_default indicates if this workspace class is the default one
bool is_default = 4;
}

message CreateWorkspaceSnapshotRequest {
// workspace_id specifies the workspace to create snapshot
//
// +required
string workspace_id = 1;
}

message CreateWorkspaceSnapshotResponse {
WorkspaceSnapshot snapshot = 1;
}

message WaitForWorkspaceSnapshotRequest {
// snapshot_id specifies the snapshot to wait for
//
// +required
string snapshot_id = 1;
}

message WaitForWorkspaceSnapshotResponse {}

message WorkspaceSnapshot {
// id is the unique identifier of the snapshot
string id = 1;

// workspace_id is the source workspace id of snapshot
string workspace_id = 2;

google.protobuf.Timestamp creation_time = 3;
}
50 changes: 50 additions & 0 deletions components/public-api/go/v1/v1connect/workspace.connect.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading