Skip to content

Commit a7bd49f

Browse files
authored
[supervisor] Remove default image fetch to improve IDE startup performance (#18993)
* [supervisor] Remove default image fetch to improve IDE startup performance * fix build * address feedback
1 parent e059cb1 commit a7bd49f

File tree

7 files changed

+93
-342
lines changed

7 files changed

+93
-342
lines changed

components/gitpod-cli/cmd/init.go

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ import (
1919
"github.com/gitpod-io/gitpod/gitpod-cli/pkg/gitpod"
2020
"github.com/gitpod-io/gitpod/gitpod-cli/pkg/gitpodlib"
2121
"github.com/gitpod-io/gitpod/gitpod-cli/pkg/utils"
22+
protocol "github.com/gitpod-io/gitpod/gitpod-protocol"
23+
"github.com/gitpod-io/gitpod/supervisor/api"
2224
)
2325

2426
var (
@@ -55,7 +57,11 @@ Create a Gitpod configuration for this project.
5557
return err
5658
}
5759
if !interactive {
58-
defaultImage, err := getDefaultWorkspaceImage(ctx)
60+
wsInfo, err := gitpod.GetWSInfo(ctx)
61+
if err != nil {
62+
return fmt.Errorf("failed to get workspace info: %w", err)
63+
}
64+
defaultImage, err := getDefaultWorkspaceImage(ctx, wsInfo)
5965
if err != nil {
6066
fmt.Printf("failed to get organization default workspace image: %v\n", err)
6167
fmt.Println("fallback to gitpod default")
@@ -125,12 +131,22 @@ USER gitpod
125131
},
126132
}
127133

128-
func getDefaultWorkspaceImage(ctx context.Context) (string, error) {
129-
wsInfo, err := gitpod.GetWSInfo(ctx)
134+
func getDefaultWorkspaceImage(ctx context.Context, wsInfo *api.WorkspaceInfoResponse) (string, error) {
135+
client, err := gitpod.ConnectToServer(ctx, wsInfo, []string{
136+
"function:getDefaultWorkspaceImage",
137+
})
138+
if err != nil {
139+
return "", err
140+
}
141+
defer client.Close()
142+
143+
res, err := client.GetDefaultWorkspaceImage(ctx, &protocol.GetDefaultWorkspaceImageParams{
144+
WorkspaceID: wsInfo.WorkspaceId,
145+
})
130146
if err != nil {
131147
return "", err
132148
}
133-
return wsInfo.DefaultWorkspaceImage, nil
149+
return res.Image, nil
134150
}
135151

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

169185
if chce == 0 {
170-
defaultImage, err := getDefaultWorkspaceImage(ctx)
186+
wsInfo, err := gitpod.GetWSInfo(ctx)
187+
if err != nil {
188+
return fmt.Errorf("failed to get workspace info: %w", err)
189+
}
190+
defaultImage, err := getDefaultWorkspaceImage(ctx, wsInfo)
171191
if err != nil {
172192
return fmt.Errorf("failed to get organization default workspace image: %w", err)
173193
}

components/gitpod-cli/cmd/validate.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,10 @@ func runRebuild(ctx context.Context, supervisorClient *supervisor.SupervisorClie
8888
var dockerContext string
8989
switch img := gitpodConfig.Image.(type) {
9090
case nil:
91-
image = wsInfo.DefaultWorkspaceImage
91+
image, err = getDefaultWorkspaceImage(ctx, wsInfo)
92+
if err != nil {
93+
return err
94+
}
9295
fmt.Println("Using default workspace image:", image)
9396
case string:
9497
image = img

components/supervisor-api/go/info.pb.go

Lines changed: 33 additions & 45 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components/supervisor-api/info.proto

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ message WorkspaceInfoResponse {
101101
// configcat_enabled controls whether configcat is enabled
102102
bool configcat_enabled = 18;
103103

104-
// default_workspace_image is the default image of the workspace
105-
string default_workspace_image = 19;
104+
// DEPRECATED default_workspace_image is the default image of the workspace
105+
reserved 19;
106106
}
107107

108108
enum DebugWorkspaceType {

0 commit comments

Comments
 (0)