Skip to content

Commit 78470a2

Browse files
sagor999roboquat
authored andcommitted
[content-service] chown after prebuild git ops when using pvc
1 parent 73928d9 commit 78470a2

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

components/content-service/pkg/initializer/prebuild.go

+22
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"errors"
1010
"fmt"
1111
"os"
12+
"os/exec"
1213
"path/filepath"
1314
"strings"
1415

@@ -17,6 +18,7 @@ import (
1718
"golang.org/x/xerrors"
1819

1920
"github.com/gitpod-io/gitpod/common-go/log"
21+
"github.com/gitpod-io/gitpod/common-go/process"
2022
"github.com/gitpod-io/gitpod/common-go/tracing"
2123
csapi "github.com/gitpod-io/gitpod/content-service/api"
2224
"github.com/gitpod-io/gitpod/content-service/pkg/archive"
@@ -152,5 +154,25 @@ func runGitInit(ctx context.Context, gInit *GitInitializer) (err error) {
152154

153155
log.Debug("prebuild initializer Git operations complete")
154156
}
157+
158+
defer func() {
159+
span.SetTag("Chown", gInit.Chown)
160+
if !gInit.Chown {
161+
return
162+
}
163+
// TODO (ptumik): need this for regular prebuild -> pvc workspace. Once fixed supervisor executor.execure() running with root we can remove this code.
164+
args := []string{"-R", "-L", "gitpod:gitpod", gInit.Location}
165+
cmd := exec.Command("chown", args...)
166+
res, cerr := cmd.CombinedOutput()
167+
if cerr != nil && !process.IsNotChildProcess(cerr) {
168+
err = git.OpFailedError{
169+
Args: args,
170+
ExecErr: cerr,
171+
Output: string(res),
172+
Subcommand: "chown",
173+
}
174+
return
175+
}
176+
}()
155177
return nil
156178
}

0 commit comments

Comments
 (0)