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

content-service: fix incorrect user:group after git operation #12422

Merged
merged 2 commits into from
Aug 26, 2022
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
9 changes: 7 additions & 2 deletions components/content-service/pkg/initializer/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -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...)
Expand All @@ -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)
}
Expand Down
4 changes: 1 addition & 3 deletions components/supervisor/pkg/supervisor/supervisor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}

Expand Down Expand Up @@ -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
}
Expand Down