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

Add desktop IDE image support in registry-facade and ws-manager #6364

Merged
merged 2 commits into from
Oct 26, 2021
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
5 changes: 4 additions & 1 deletion components/ee/ws-scheduler/pkg/scaler/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,10 @@ func (wspd *WorkspaceManagerPrescaleDriver) startGhostWorkspaces(ctx context.Con
Email: "[email protected]",
Username: "gitpod-ghost",
},
IdeImage: wspd.Config.IDEImage,
DeprecatedIdeImage: wspd.Config.IDEImage,
IdeImage: &api.IDEImage{
WebRef: wspd.Config.IDEImage,
},
Initializer: &csapi.WorkspaceInitializer{
Spec: &csapi.WorkspaceInitializer_Empty{
Empty: &csapi.EmptyInitializer{},
Expand Down
13 changes: 8 additions & 5 deletions components/image-builder-mk3/pkg/orchestrator/orchestrator.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,11 +357,14 @@ func (o *Orchestrator) Build(req *protocol.BuildRequest, resp protocol.ImageBuil
Owner: buildWorkspaceOwnerID,
},
Spec: &wsmanapi.StartWorkspaceSpec{
CheckoutLocation: ".",
Initializer: initializer,
Timeout: maxBuildRuntime.String(),
WorkspaceImage: o.Config.BuilderImage,
IdeImage: o.Config.BuilderImage,
CheckoutLocation: ".",
Initializer: initializer,
Timeout: maxBuildRuntime.String(),
WorkspaceImage: o.Config.BuilderImage,
DeprecatedIdeImage: o.Config.BuilderImage,
IdeImage: &wsmanapi.IDEImage{
WebRef: o.Config.BuilderImage,
},
WorkspaceLocation: contextPath,
Envvars: []*wsmanapi.EnvironmentVariable{
{Name: "BOB_TARGET_REF", Value: wsrefstr},
Expand Down
69 changes: 40 additions & 29 deletions components/registry-facade-api/go/imagespec.pb.go

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

4 changes: 2 additions & 2 deletions components/registry-facade-api/go/provider.pb.go

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

2 changes: 2 additions & 0 deletions components/registry-facade-api/imagespec.proto
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ message ImageSpec {
string ide_ref = 2;
// content_layer describe the last few layers which provide the workspace's content
repeated ContentLayer content_layer = 3;
// desktop_ide_ref point to an image denotign the desktop IDE to use
string desktop_ide_ref = 4;
}

// ContentLayer is a layer that provides a workspace's content
Expand Down
12 changes: 12 additions & 0 deletions components/registry-facade/pkg/registry/layersource.go
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,9 @@ func (src *SpecMappedImagedSource) Envs(ctx context.Context, spec *api.ImageSpec
if err != nil {
return nil, err
}
if lsrc == nil {
return []EnvModifier{}, nil
}
return lsrc.Envs(ctx, spec)
}

Expand All @@ -403,6 +406,9 @@ func (src *SpecMappedImagedSource) GetLayer(ctx context.Context, spec *api.Image
if err != nil {
return nil, err
}
if lsrc == nil {
return []AddonLayer{}, nil
}
return lsrc.GetLayer(ctx, spec)
}

Expand All @@ -412,6 +418,9 @@ func (src *SpecMappedImagedSource) HasBlob(ctx context.Context, spec *api.ImageS
if err != nil {
return false
}
if lsrc == nil {
return false
}
return lsrc.HasBlob(ctx, spec, dgst)
}

Expand All @@ -431,6 +440,9 @@ func (src *SpecMappedImagedSource) getDelegate(ctx context.Context, spec *api.Im
if err != nil {
return nil, err
}
if ref == "" {
return nil, nil
}

if s, ok := src.cache.Get(ref); ok {
return s.(LayerSource), nil
Expand Down
9 changes: 9 additions & 0 deletions components/registry-facade/pkg/registry/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,15 @@ func NewRegistry(cfg config.Config, newResolver ResolverProvider, reg prometheus
}
layerSources = append(layerSources, ideLayerSource)

desktopIdeRefSource := func(s *api.ImageSpec) (ref string, err error) {
return s.DesktopIdeRef, nil
}
desktopIdeLayerSource, err := NewSpecMappedImageSource(newResolver, desktopIdeRefSource)
if err != nil {
return nil, err
}
layerSources = append(layerSources, desktopIdeLayerSource)

log.Info("preparing static layer")
staticLayer := NewRevisioningLayerSource(CompositeLayerSource{})
layerSources = append(layerSources, staticLayer)
Expand Down
6 changes: 4 additions & 2 deletions components/server/src/workspace/workspace-starter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { IAnalyticsWriter } from '@gitpod/gitpod-protocol/lib/analytics';
import { log } from '@gitpod/gitpod-protocol/lib/util/logging';
import { TraceContext } from "@gitpod/gitpod-protocol/lib/util/tracing";
import { BuildRegistryAuth, BuildRegistryAuthSelective, BuildRegistryAuthTotal, BuildRequest, BuildResponse, BuildSource, BuildSourceDockerfile, BuildSourceReference, BuildStatus, ImageBuilderClientProvider, ResolveBaseImageRequest, ResolveWorkspaceImageRequest } from "@gitpod/image-builder/lib";
import { StartWorkspaceSpec, WorkspaceFeatureFlag, StartWorkspaceResponse } from "@gitpod/ws-manager/lib";
import { StartWorkspaceSpec, WorkspaceFeatureFlag, StartWorkspaceResponse, IDEImage } from "@gitpod/ws-manager/lib";
import { WorkspaceManagerClientProvider } from "@gitpod/ws-manager/lib/client-provider";
import { AdmissionLevel, EnvironmentVariable, GitSpec, PortSpec, PortVisibility, StartWorkspaceRequest, WorkspaceMetadata, WorkspaceType } from "@gitpod/ws-manager/lib/core_pb";
import * as crypto from 'crypto';
Expand Down Expand Up @@ -723,7 +723,9 @@ export class WorkspaceStarter {
spec.setGit(this.createGitSpec(workspace, user));
spec.setPortsList(ports);
spec.setInitializer((await initializerPromise).initializer);
spec.setIdeImage(ideImage);
const startWorkspaceSpecIDEImage = new IDEImage();
startWorkspaceSpecIDEImage.setWebRef(ideImage);
spec.setIdeImage(startWorkspaceSpecIDEImage);
spec.setWorkspaceImage(instance.workspaceImage);
spec.setWorkspaceLocation(workspace.config.workspaceLocation || spec.getCheckoutLocation());
spec.setFeatureFlagsList(this.toWorkspaceFeatureFlags(featureFlags));
Expand Down
24 changes: 20 additions & 4 deletions components/ws-manager-api/core.proto
Original file line number Diff line number Diff line change
Expand Up @@ -268,13 +268,22 @@ message WorkspaceStatus {
WorkspaceAuthentication auth = 9;
}

// IDEImage configures the IDE images a workspace will use
message IDEImage {
// web_ref is a reference to an OCI image used for serving the web-based IDE
string web_ref = 1;
// desktop_ref is an optional reference to an OCI image used for serving desktop IDEs
string desktop_ref = 2;
}

// WorkspaceSpec is the specification of a workspace at runtime
message WorkspaceSpec {
// workspace_image is the name of the Docker image this workspace runs
string workspace_image = 1;

// ide_image is the name of the Docker image used as IDE
string ide_image = 2;
// deprecated_ide_image is a field present for backwards compatibility and the same
// as IDEImage.web_ref. If both fields are present, IDEImage.web_ref takes precedence.
string deprecated_ide_image = 2;

// headless marks this workspace a headless one - headless workspaces are not intended for users but for automation
bool headless = 3;
Expand All @@ -290,6 +299,9 @@ message WorkspaceSpec {

// The intervals in which a heartbeat must be received for the workspace not to time out
string timeout = 7;

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

// PortSpec describes a networking port exposed on a workspace
Expand Down Expand Up @@ -443,8 +455,9 @@ message StartWorkspaceSpec {
// workspace_image is the Docker image name of the workspace container
string workspace_image = 1;

// ide_image is the Docker image name of the IDE image
string ide_image = 2;
// deprecated_ide_image is a field present for backwards compatibility and the same
// as IDEImage.web_ref. If both fields are present, IDEImage.web_ref takes precedence.
string deprecated_ide_image = 2;

// feature_flags provide a means for starting variants of workspaces (e.g. a privileged one)
repeated WorkspaceFeatureFlag feature_flags = 3;
Expand Down Expand Up @@ -472,6 +485,9 @@ message StartWorkspaceSpec {

// admission controlls who can access the workspace and its ports.
AdmissionLevel admission = 11;

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

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