From 571633105560b1f5922b1e7a0db9140d9cdadfcf Mon Sep 17 00:00:00 2001 From: JenTing Hsiao Date: Fri, 26 Aug 2022 05:07:03 +0000 Subject: [PATCH 1/2] Chown all files and folders after git checkout Signed-off-by: JenTing Hsiao --- components/content-service/pkg/initializer/git.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/components/content-service/pkg/initializer/git.go b/components/content-service/pkg/initializer/git.go index 3f0f1916aace5a..2eade19f4cb469 100644 --- a/components/content-service/pkg/initializer/git.go +++ b/components/content-service/pkg/initializer/git.go @@ -110,7 +110,11 @@ func (ws *GitInitializer) Run(ctx context.Context, mappings []archive.IDMapping) return src, xerrors.Errorf("git initializer gitClone: %w", err) } - if ws.Chown { + defer func() { + span.SetTag("Chown", ws.Chown) + if !ws.Chown { + return + } // TODO (aledbf): refactor to remove the need of manual chown args := []string{"-R", "-L", "gitpod", ws.Location} cmd := exec.Command("chown", args...) @@ -124,7 +128,8 @@ func (ws *GitInitializer) Run(ctx context.Context, mappings []archive.IDMapping) } return } - } + }() + if err := ws.realizeCloneTarget(ctx); err != nil { return src, xerrors.Errorf("git initializer clone: %w", err) } From 3787f5c7184eab0819bb4d69d476b8dab420282f Mon Sep 17 00:00:00 2001 From: JenTing Hsiao Date: Fri, 26 Aug 2022 08:16:36 +0000 Subject: [PATCH 2/2] Revert "[supervisor] fix chown of /workspace when using PVC" This reverts commit 370ba5eb9277883ac160429a1f7710529b412dfa. --- components/supervisor/pkg/supervisor/supervisor.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/components/supervisor/pkg/supervisor/supervisor.go b/components/supervisor/pkg/supervisor/supervisor.go index 6e4a974ee1a260..f2b8a229cfcc65 100644 --- a/components/supervisor/pkg/supervisor/supervisor.go +++ b/components/supervisor/pkg/supervisor/supervisor.go @@ -1325,11 +1325,9 @@ func startContentInit(ctx context.Context, cfg *Config, wg *sync.WaitGroup, cst fn := "/workspace/.gitpod/content.json" fnReady := "/workspace/.gitpod/ready" - doChown := true if _, err := os.Stat("/.workspace/.gitpod/content.json"); !os.IsNotExist(err) { fn = "/.workspace/.gitpod/content.json" fnReady = "/.workspace/.gitpod/ready" - doChown = false // cannot chown when using PVC as it is owned by 133332 user log.Info("Detected content.json in /.workspace folder, assuming PVC feature enabled") } @@ -1378,7 +1376,7 @@ func startContentInit(ctx context.Context, cfg *Config, wg *sync.WaitGroup, cst log.Info("supervisor: running content service executor with content descriptor") var src csapi.WorkspaceInitSource - src, err = executor.Execute(ctx, "/workspace", contentFile, doChown) + src, err = executor.Execute(ctx, "/workspace", contentFile, true) if err != nil { return }