Skip to content

regenerate usage-api #12294

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 23, 2022
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
19 changes: 13 additions & 6 deletions components/server/src/workspace/workspace-starter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ import { AttributionId } from "@gitpod/gitpod-protocol/lib/attribution";
import { CachingBillingServiceClientProvider } from "@gitpod/usage-api/lib/usage/v1/sugar";
import { Timestamp } from "google-protobuf/google/protobuf/timestamp_pb";
import { BillingMode } from "@gitpod/gitpod-protocol/lib/billing-mode";
import { System } from "@gitpod/usage-api/lib/usage/v1/billing_pb";

export interface StartWorkspaceOptions {
rethrow?: boolean;
Expand Down Expand Up @@ -545,7 +546,7 @@ export class WorkspaceStarter {
const billingMode = await this.billingModes.getBillingMode(parsedAttributionId, creationTime);
if (billingMode && billingMode.mode === "chargebee") {
const billingClient = this.billingServiceClientProvider.getDefault();
await billingClient.setBilledSession(instance.id, timestamped, "chargebee");
await billingClient.setBilledSession(instance.id, timestamped, System.SYSTEM_CHARGEBEE);
}
}
}
Expand Down Expand Up @@ -1435,17 +1436,23 @@ export class WorkspaceStarter {
}
}

let volumeSnapshotId = ""
let volumeSnapshotId = "";
// always pick lastValidWorkspaceInstanceId if it is valid, otherwise workspace will be restored from prebuild
// even if there was workspace backup available
if (lastValidWorkspaceInstanceId != "") {
volumeSnapshotId = lastValidWorkspaceInstanceId
} else if ((SnapshotContext.is(workspace.context) || WithPrebuild.is(workspace.context)) && !!workspace.context.snapshotBucketId) {
volumeSnapshotId = workspace.context.snapshotBucketId
volumeSnapshotId = lastValidWorkspaceInstanceId;
} else if (
(SnapshotContext.is(workspace.context) || WithPrebuild.is(workspace.context)) &&
!!workspace.context.snapshotBucketId
) {
volumeSnapshotId = workspace.context.snapshotBucketId;
}

let volumeSnapshotInfo = new VolumeSnapshotInfo();
const volumeSnapshots = volumeSnapshotId != "" ? await this.workspaceDb.trace(traceCtx).findVolumeSnapshotById(volumeSnapshotId) : undefined;
const volumeSnapshots =
volumeSnapshotId != ""
? await this.workspaceDb.trace(traceCtx).findVolumeSnapshotById(volumeSnapshotId)
: undefined;
if (volumeSnapshots !== undefined) {
log.info("starting workspace with volume snapshot info", {
lastInstanceId: lastValidWorkspaceInstanceId,
Expand Down
186 changes: 123 additions & 63 deletions components/usage-api/go/v1/billing.pb.go

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

12 changes: 9 additions & 3 deletions components/usage-api/typescript/src/usage/v1/billing_pb.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@ export class SetBilledSessionRequest extends jspb.Message {
clearFrom(): void;
getFrom(): google_protobuf_timestamp_pb.Timestamp | undefined;
setFrom(value?: google_protobuf_timestamp_pb.Timestamp): SetBilledSessionRequest;
getSystem(): string;
setSystem(value: string): SetBilledSessionRequest;
getSystem(): System;
setSystem(value: System): SetBilledSessionRequest;

serializeBinary(): Uint8Array;
toObject(includeInstance?: boolean): SetBilledSessionRequest.AsObject;
Expand All @@ -191,7 +191,7 @@ export namespace SetBilledSessionRequest {
export type AsObject = {
instanceId: string,
from?: google_protobuf_timestamp_pb.Timestamp.AsObject,
system: string,
system: System,
}
}

Expand All @@ -211,3 +211,9 @@ export namespace SetBilledSessionResponse {
export type AsObject = {
}
}

export enum System {
SYSTEM_UNKNOWN = 0,
SYSTEM_CHARGEBEE = 1,
SYSTEM_STRIPE = 2,
}
Loading