Skip to content

[supervisor] Remove default image fetch to improve IDE startup performance #18993

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
Nov 2, 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
30 changes: 25 additions & 5 deletions components/gitpod-cli/cmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import (
"github.com/gitpod-io/gitpod/gitpod-cli/pkg/gitpod"
"github.com/gitpod-io/gitpod/gitpod-cli/pkg/gitpodlib"
"github.com/gitpod-io/gitpod/gitpod-cli/pkg/utils"
protocol "github.com/gitpod-io/gitpod/gitpod-protocol"
"github.com/gitpod-io/gitpod/supervisor/api"
)

var (
Expand Down Expand Up @@ -55,7 +57,11 @@ Create a Gitpod configuration for this project.
return err
}
if !interactive {
defaultImage, err := getDefaultWorkspaceImage(ctx)
wsInfo, err := gitpod.GetWSInfo(ctx)
if err != nil {
return fmt.Errorf("failed to get workspace info: %w", err)
}
defaultImage, err := getDefaultWorkspaceImage(ctx, wsInfo)
if err != nil {
fmt.Printf("failed to get organization default workspace image: %v\n", err)
fmt.Println("fallback to gitpod default")
Expand Down Expand Up @@ -125,12 +131,22 @@ USER gitpod
},
}

func getDefaultWorkspaceImage(ctx context.Context) (string, error) {
wsInfo, err := gitpod.GetWSInfo(ctx)
func getDefaultWorkspaceImage(ctx context.Context, wsInfo *api.WorkspaceInfoResponse) (string, error) {
client, err := gitpod.ConnectToServer(ctx, wsInfo, []string{
"function:getDefaultWorkspaceImage",
})
if err != nil {
return "", err
}
defer client.Close()

res, err := client.GetDefaultWorkspaceImage(ctx, &protocol.GetDefaultWorkspaceImageParams{
WorkspaceID: wsInfo.WorkspaceId,
})
if err != nil {
return "", err
}
return wsInfo.DefaultWorkspaceImage, nil
return res.Image, nil
}

func isRequired(input string) error {
Expand Down Expand Up @@ -167,7 +183,11 @@ func askForDockerImage(ctx context.Context, cfg *gitpodlib.GitpodFile) error {
}

if chce == 0 {
defaultImage, err := getDefaultWorkspaceImage(ctx)
wsInfo, err := gitpod.GetWSInfo(ctx)
if err != nil {
return fmt.Errorf("failed to get workspace info: %w", err)
}
defaultImage, err := getDefaultWorkspaceImage(ctx, wsInfo)
if err != nil {
return fmt.Errorf("failed to get organization default workspace image: %w", err)
}
Expand Down
5 changes: 4 additions & 1 deletion components/gitpod-cli/cmd/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,10 @@ func runRebuild(ctx context.Context, supervisorClient *supervisor.SupervisorClie
var dockerContext string
switch img := gitpodConfig.Image.(type) {
case nil:
image = wsInfo.DefaultWorkspaceImage
image, err = getDefaultWorkspaceImage(ctx, wsInfo)
if err != nil {
return err
}
fmt.Println("Using default workspace image:", image)
case string:
image = img
Expand Down
78 changes: 33 additions & 45 deletions components/supervisor-api/go/info.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/supervisor-api/info.proto
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ message WorkspaceInfoResponse {
// configcat_enabled controls whether configcat is enabled
bool configcat_enabled = 18;

// default_workspace_image is the default image of the workspace
string default_workspace_image = 19;
// DEPRECATED default_workspace_image is the default image of the workspace
reserved 19;
}

enum DebugWorkspaceType {
Expand Down
Loading