Skip to content

Commit aa33c8c

Browse files
committed
[inner-loop] run Isolated docker in debug workspace
1 parent 8eb9d8c commit aa33c8c

File tree

2 files changed

+53
-14
lines changed

2 files changed

+53
-14
lines changed

components/gitpod-cli/cmd/rebuild.go

Lines changed: 52 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -241,10 +241,28 @@ func runRebuild(ctx context.Context, supervisorClient *supervisor.SupervisorClie
241241
return err
242242
}
243243

244-
// we don't pass context on purporse to handle graceful shutdown
245-
// and output all logs properly below
246-
runCmd := exec.Command(
247-
dockerPath,
244+
type mnte struct {
245+
IsFile bool
246+
Target string
247+
Source string
248+
Permission os.FileMode
249+
}
250+
251+
prepareFS := []mnte{
252+
{Source: "/workspace"},
253+
{Source: "/.supervisor"},
254+
{Source: "/ide"},
255+
{Source: "/workspace/.gitpod-debug/.docker-root", Target: "/workspace/.docker-root", Permission: 0710},
256+
{Source: "/workspace/.gitpod-debug/.gitpod", Target: "/workspace/.gitpod", Permission: 0751},
257+
{Source: "/workspace/.gitpod-debug/.vscode-remote", Target: "/workspace/.vscode-remote", Permission: 0751},
258+
{Source: "/workspace/.gitpod-debug/.cache", Target: "/workspace/.cache", Permission: 0751},
259+
{Source: "/workspace/.gitpod-debug/.config", Target: "/workspace/.config", Permission: 0751},
260+
{Source: "/usr/bin/docker-up", IsFile: true},
261+
{Source: "/usr/bin/runc-facade", IsFile: true},
262+
{Source: "/usr/local/bin/docker-compose", IsFile: true},
263+
}
264+
265+
dockerArgs := []string{
248266
"run",
249267
"--rm",
250268
"--user", "root",
@@ -258,17 +276,38 @@ func runRebuild(ctx context.Context, supervisorClient *supervisor.SupervisorClie
258276
"-p", "25001:23001", // SSH
259277
// 23002 dekstop IDE port, but it is covered by debug workspace proxy
260278
"-p", "25003:23003", // debug workspace proxy
279+
}
261280

262-
// volumes
263-
"-v", "/workspace:/workspace",
264-
"-v", "/.supervisor:/.supervisor",
265-
"-v", "/var/run/docker.sock:/var/run/docker.sock",
266-
"-v", "/ide:/ide",
267-
// "-v", "/ide-desktop:/ide-desktop", // TODO fix desktop IDEs later
268-
// "-v", "/ide-desktop-plugins:/ide-desktop-plugins", // TODO refactor to keep all IDE deps under ide or ide-desktop
281+
for _, mnt := range prepareFS {
282+
fd, err := os.Stat(mnt.Source)
283+
if err != nil {
284+
if !os.IsNotExist(err) {
285+
return err
286+
}
287+
if mnt.IsFile {
288+
return err
289+
}
290+
err = os.MkdirAll(mnt.Source, mnt.Permission)
291+
if err != nil {
292+
return err
293+
}
294+
}
295+
if fd.IsDir() != !mnt.IsFile {
296+
return xerrors.Errorf("invalid file type for %s", mnt.Source)
297+
}
298+
if mnt.Target == "" {
299+
mnt.Target = mnt.Source
300+
}
301+
dockerArgs = append(dockerArgs, "-v", fmt.Sprintf("%s:%s", mnt.Source, mnt.Target))
302+
}
269303

270-
image,
271-
"/.supervisor/supervisor", "init",
304+
dockerArgs = append(dockerArgs, image, "/.supervisor/supervisor", "init")
305+
306+
// we don't pass context on purporse to handle graceful shutdown
307+
// and output all logs properly below
308+
runCmd := exec.Command(
309+
dockerPath,
310+
dockerArgs...,
272311
)
273312

274313
debugSupervisor, err := supervisor.New(ctx, &supervisor.SupervisorClientOption{

components/supervisor/pkg/supervisor/supervisor.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ func Run(options ...RunOption) {
398398
tasksSuccessChan := make(chan taskSuccess, 1)
399399
go taskManager.Run(ctx, &wg, tasksSuccessChan)
400400

401-
if !opts.RunGP && !cfg.isDebugWorkspace() {
401+
if !opts.RunGP {
402402
wg.Add(1)
403403
go socketActivationForDocker(ctx, &wg, termMux, cfg, telemetry)
404404
}

0 commit comments

Comments
 (0)