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

[ws-manager] Introduce workspace classes #9238

Merged
merged 3 commits into from
Apr 29, 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
2 changes: 0 additions & 2 deletions .werft/jobs/build/installer/post-process.sh
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,6 @@ while [ "$documentIndex" -le "$DOCS" ]; do
| jq --arg REGISTRY_FACADE_HOST "$REGISTRY_FACADE_HOST" '.manager.registryFacadeHost = $REGISTRY_FACADE_HOST' \
| jq ".manager.wsdaemon.port = $WS_DAEMON_PORT" > /tmp/"$NAME"-cm-overrides.json

yq w -i -j /tmp/"$NAME"-cm-overrides.json manager.podTemplate.defaultPath /workspace-templates/default.yaml

touch /tmp/"$NAME"-cm-overrides.yaml
# write a yaml file with the json as a multiline string
yq w -i /tmp/"$NAME"-cm-overrides.yaml "data.[config.json]" -- "$(< /tmp/"$NAME"-cm-overrides.json)"
Expand Down
3 changes: 3 additions & 0 deletions components/ws-daemon-api/daemon.proto
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ message InitWorkspaceRequest {
// remote_storage_disabled disables any support for remote storage operations, specifically backups and snapshots.
// When any such operation is attempted, a FAILED_PRECONDITION error will be the result.
bool remote_storage_disabled = 7;

// storage_quota_bytes enforces a storage quate for the workspace if set to a value != 0
int64 storage_quota_bytes = 8;
}

// WorkspaceMetadata is data associated with a workspace that's required for other parts of the system to function
Expand Down
14 changes: 13 additions & 1 deletion components/ws-daemon-api/go/daemon.pb.go

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

25 changes: 14 additions & 11 deletions components/ws-daemon-api/typescript/src/daemon_pb.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import * as jspb from "google-protobuf";
import * as content_service_api_initializer_pb from "@gitpod/content-service/lib";

export class InitWorkspaceRequest extends jspb.Message {
export class InitWorkspaceRequest extends jspb.Message {
getId(): string;
setId(value: string): InitWorkspaceRequest;

Expand All @@ -34,6 +34,8 @@ export class InitWorkspaceRequest extends jspb.Message {
setContentManifest(value: Uint8Array | string): InitWorkspaceRequest;
getRemoteStorageDisabled(): boolean;
setRemoteStorageDisabled(value: boolean): InitWorkspaceRequest;
getStorageQuotaBytes(): number;
setStorageQuotaBytes(value: number): InitWorkspaceRequest;

serializeBinary(): Uint8Array;
toObject(includeInstance?: boolean): InitWorkspaceRequest.AsObject;
Expand All @@ -53,10 +55,11 @@ export namespace InitWorkspaceRequest {
fullWorkspaceBackup: boolean,
contentManifest: Uint8Array | string,
remoteStorageDisabled: boolean,
storageQuotaBytes: number,
}
}

export class WorkspaceMetadata extends jspb.Message {
export class WorkspaceMetadata extends jspb.Message {
getOwner(): string;
setOwner(value: string): WorkspaceMetadata;
getMetaId(): string;
Expand All @@ -79,7 +82,7 @@ export namespace WorkspaceMetadata {
}
}

export class InitWorkspaceResponse extends jspb.Message {
export class InitWorkspaceResponse extends jspb.Message {

serializeBinary(): Uint8Array;
toObject(includeInstance?: boolean): InitWorkspaceResponse.AsObject;
Expand All @@ -96,7 +99,7 @@ export namespace InitWorkspaceResponse {
}
}

export class WaitForInitRequest extends jspb.Message {
export class WaitForInitRequest extends jspb.Message {
getId(): string;
setId(value: string): WaitForInitRequest;

Expand All @@ -116,7 +119,7 @@ export namespace WaitForInitRequest {
}
}

export class WaitForInitResponse extends jspb.Message {
export class WaitForInitResponse extends jspb.Message {

serializeBinary(): Uint8Array;
toObject(includeInstance?: boolean): WaitForInitResponse.AsObject;
Expand All @@ -133,7 +136,7 @@ export namespace WaitForInitResponse {
}
}

export class TakeSnapshotRequest extends jspb.Message {
export class TakeSnapshotRequest extends jspb.Message {
getId(): string;
setId(value: string): TakeSnapshotRequest;
getReturnImmediately(): boolean;
Expand All @@ -156,7 +159,7 @@ export namespace TakeSnapshotRequest {
}
}

export class TakeSnapshotResponse extends jspb.Message {
export class TakeSnapshotResponse extends jspb.Message {
getUrl(): string;
setUrl(value: string): TakeSnapshotResponse;

Expand All @@ -176,7 +179,7 @@ export namespace TakeSnapshotResponse {
}
}

export class DisposeWorkspaceRequest extends jspb.Message {
export class DisposeWorkspaceRequest extends jspb.Message {
getId(): string;
setId(value: string): DisposeWorkspaceRequest;
getBackup(): boolean;
Expand All @@ -202,7 +205,7 @@ export namespace DisposeWorkspaceRequest {
}
}

export class DisposeWorkspaceResponse extends jspb.Message {
export class DisposeWorkspaceResponse extends jspb.Message {

hasGitStatus(): boolean;
clearGitStatus(): void;
Expand All @@ -225,7 +228,7 @@ export namespace DisposeWorkspaceResponse {
}
}

export class BackupWorkspaceRequest extends jspb.Message {
export class BackupWorkspaceRequest extends jspb.Message {
getId(): string;
setId(value: string): BackupWorkspaceRequest;

Expand All @@ -245,7 +248,7 @@ export namespace BackupWorkspaceRequest {
}
}

export class BackupWorkspaceResponse extends jspb.Message {
export class BackupWorkspaceResponse extends jspb.Message {
getUrl(): string;
setUrl(value: string): BackupWorkspaceResponse;

Expand Down
32 changes: 31 additions & 1 deletion components/ws-daemon-api/typescript/src/daemon_pb.js
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,8 @@ proto.wsdaemon.InitWorkspaceRequest.toObject = function(includeInstance, msg) {
initializer: (f = msg.getInitializer()) && content$service$api_initializer_pb.WorkspaceInitializer.toObject(includeInstance, f),
fullWorkspaceBackup: jspb.Message.getBooleanFieldWithDefault(msg, 4, false),
contentManifest: msg.getContentManifest_asB64(),
remoteStorageDisabled: jspb.Message.getBooleanFieldWithDefault(msg, 7, false)
remoteStorageDisabled: jspb.Message.getBooleanFieldWithDefault(msg, 7, false),
storageQuotaBytes: jspb.Message.getFieldWithDefault(msg, 8, 0)
};

if (includeInstance) {
Expand Down Expand Up @@ -366,6 +367,10 @@ proto.wsdaemon.InitWorkspaceRequest.deserializeBinaryFromReader = function(msg,
var value = /** @type {boolean} */ (reader.readBool());
msg.setRemoteStorageDisabled(value);
break;
case 8:
var value = /** @type {number} */ (reader.readInt64());
msg.setStorageQuotaBytes(value);
break;
default:
reader.skipField();
break;
Expand Down Expand Up @@ -439,6 +444,13 @@ proto.wsdaemon.InitWorkspaceRequest.serializeBinaryToWriter = function(message,
f
);
}
f = message.getStorageQuotaBytes();
if (f !== 0) {
writer.writeInt64(
8,
f
);
}
};


Expand Down Expand Up @@ -612,6 +624,24 @@ proto.wsdaemon.InitWorkspaceRequest.prototype.setRemoteStorageDisabled = functio
};


/**
* optional int64 storage_quota_bytes = 8;
* @return {number}
*/
proto.wsdaemon.InitWorkspaceRequest.prototype.getStorageQuotaBytes = function() {
return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 8, 0));
};


/**
* @param {number} value
* @return {!proto.wsdaemon.InitWorkspaceRequest} returns this
*/
proto.wsdaemon.InitWorkspaceRequest.prototype.setStorageQuotaBytes = function(value) {
return jspb.Message.setProto3IntField(this, 8, value);
};





Expand Down
4 changes: 0 additions & 4 deletions components/ws-daemon/pkg/content/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"github.com/gitpod-io/gitpod/common-go/util"
cntntcfg "github.com/gitpod-io/gitpod/content-service/api/config"
"github.com/gitpod-io/gitpod/ws-daemon/api"
"github.com/gitpod-io/gitpod/ws-daemon/pkg/quota"
"golang.org/x/xerrors"
)

Expand All @@ -29,9 +28,6 @@ type Config struct {
// TmpDir is the temp working diretory for creating tar files during upload
TmpDir string `json:"tempDir"`

// Limit limits the size of a sandbox
WorkspaceSizeLimit quota.Size `json:"workspaceSizeLimit"`

// Storage is some form of permanent file store to which we back up workspaces
Storage cntntcfg.StorageConfig `json:"storage"`

Expand Down
7 changes: 4 additions & 3 deletions components/ws-daemon/pkg/content/hooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ func workspaceLifecycleHooks(cfg Config, kubernetesNamespace string, workspaceEx
session.WorkspaceInitializing: {
hookSetupRemoteStorage(cfg),
hookSetupWorkspaceLocation,
hookInstallQuota(xfs, cfg.WorkspaceSizeLimit),
hookInstallQuota(xfs),
startIWS,
},
session.WorkspaceReady: {
hookSetupRemoteStorage(cfg),
hookInstallQuota(xfs, cfg.WorkspaceSizeLimit),
hookInstallQuota(xfs),
startIWS,
},
session.WorkspaceDisposed: {
Expand Down Expand Up @@ -93,11 +93,12 @@ func hookSetupWorkspaceLocation(ctx context.Context, ws *session.Workspace) erro
}

// hookInstallQuota enforces filesystem quota on the workspace location (if the filesystem supports it)
func hookInstallQuota(xfs *quota.XFS, size quota.Size) session.WorkspaceLivecycleHook {
func hookInstallQuota(xfs *quota.XFS) session.WorkspaceLivecycleHook {
return func(ctx context.Context, ws *session.Workspace) error {
if xfs == nil {
return nil
}
size := quota.Size(ws.StorageQuota)
if size == 0 {
return nil
}
Expand Down
1 change: 1 addition & 0 deletions components/ws-daemon/pkg/content/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ func (s *WorkspaceService) creator(req *api.InitWorkspaceRequest) session.Worksp
FullWorkspaceBackup: req.FullWorkspaceBackup,
ContentManifest: req.ContentManifest,
RemoteStorageDisabled: req.RemoteStorageDisabled,
StorageQuota: int(req.StorageQuotaBytes),

ServiceLocDaemon: filepath.Join(s.config.WorkingArea, ServiceDirName(req.Id)),
ServiceLocNode: filepath.Join(s.config.WorkingAreaNode, ServiceDirName(req.Id)),
Expand Down
1 change: 1 addition & 0 deletions components/ws-daemon/pkg/internal/session/workspace.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ type Workspace struct {
ServiceLocDaemon string `json:"serviceLocDaemon"`

RemoteStorageDisabled bool `json:"remoteStorageDisabled,omitempty"`
StorageQuota int `json:"storageQuota,omitempty"`

XFSProjectID int `json:"xfsProjectID"`

Expand Down
6 changes: 6 additions & 0 deletions components/ws-manager-api/core.proto
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,9 @@ message WorkspaceSpec {

// ide_image is the name of the Docker image used as IDE
IDEImage ide_image = 8;

// class names the class of this workspace
string class = 9;
}

// PortSpec describes a networking port exposed on a workspace
Expand Down Expand Up @@ -493,6 +496,9 @@ message StartWorkspaceSpec {

// ide_image is the Docker image name of the IDE image
IDEImage ide_image = 12;

// Class denotes the class of the workspace we ought to start
string class = 13;
}

// WorkspaceFeatureFlag enable non-standard behaviour in workspaces
Expand Down
Loading