-
Notifications
You must be signed in to change notification settings - Fork 64
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
SELinux labels in batch changes #570
Comments
Thanks for reporting! Have you tried the volume-based workspaces? If you have Agree on the error message. In order to fix that, though, we'll probably need to do dry run to check. I'll bring this up in our team sync. |
Nice! I didn't know about
|
Fantastic! And also agree on the troubleshooting guide: this one should be in there. I think until now we've wanted to see how well |
Adding it to the troubleshooting page here: https://github.com/sourcegraph/sourcegraph/pull/23068 |
Thanks! I don't know if you want to keep this issue open (for tracking change to the error message that src-cli prints) or not. The doc update works for me, so feel free to close issue when needed. |
Actually, it looks like the volume command only works after I run my modified version (that changes the SELinux labels on host). I see |
Interesting! So what exactly did you modify? Adding the Does using a different temp dir work? You can use the |
Yes, exactly. This is the change I made: diff --git a/internal/batches/executor/run_steps.go b/internal/batches/executor/run_steps.go
index fe3fdc1..db6376f 100644
--- a/internal/batches/executor/run_steps.go
+++ b/internal/batches/executor/run_steps.go
@@ -281,11 +281,11 @@ func executeSingleStep(
"--init",
"--cidfile", cidFile,
"--workdir", scriptWorkDir,
- "--mount", fmt.Sprintf("type=bind,source=%s,target=%s,ro", runScriptFile, containerTemp),
+ "-v", fmt.Sprintf("%s:%s:ro,Z", runScriptFile, containerTemp),
}, workspaceOpts...)
for target, source := range filesToMount {
- args = append(args, "--mount", fmt.Sprintf("type=bind,source=%s,target=%s,ro", source.Name(), target))
+ args = append(args, "-v", fmt.Sprintf("%s:%s:ro,Z", source.Name(), target))
}
for k, v := range env {
diff --git a/internal/batches/workspace/bind_workspace.go b/internal/batches/workspace/bind_workspace.go
index f7281c0..4d70776 100644
--- a/internal/batches/workspace/bind_workspace.go
+++ b/internal/batches/workspace/bind_workspace.go
@@ -117,8 +117,8 @@ func (w *dockerBindWorkspace) Close(ctx context.Context) error {
func (w *dockerBindWorkspace) DockerRunOpts(ctx context.Context, target string) ([]string, error) {
return []string{
- "--mount",
- fmt.Sprintf("type=bind,source=%s,target=%s", w.dir, target),
+ "-v",
+ fmt.Sprintf("%s:%s:Z", w.dir, target),
}, nil
}
|
Changing the temporary directory with When I try to run the change against a git repository that I haven't used yet, I get the error even with |
Yeah, src-cli caches results heavily in order to make iterating faster. So, just confirming: if you run
it still produces the error? |
Yes. With
Command-line log
Command-line log
Command-line log
Command-line log
|
Thanks so much! We'll look into this as soon as we can. In the meantime it sounds like you're at least unblocked from trying it out - even though it involved building your own version 😓 |
We discussed this issue and we are going to backlog it for now, given that we have big milestones for this quarter that we need to focus on, and given there is a workaround (thanks for that!). We're keeping it on our radar, though, thanks for reporting. I updated the documentation to make that clear. |
On Fedora 34 I get an error like the following (with src-cli 3.30.0):
when running the hello world batch change. SELinux blocks the Docker bind mount.
src-cli uses Docker arguments like
--mount type=bind,source=/tmp/205206724,target=/tmp/tmp.MLPLgP,ro
for mounting. If I replace them with/tmp/205206724:/tmp/tmp.MLPLgP:ro,Z
then the mount succeeds. I have replaced those occurrences in my local copy of src-cli and now it works.However, we need to be careful with using the
Z
option as it modifies the SELinux labels on the host, see https://docs.docker.com/storage/bind-mounts/#configure-the-selinux-labelIf all the files that src-cli mounts are temporary files then it should probably be okay to use it.
I have not tried to run rootless docker yet, so I don't know if that would fix the issue.
In any case even if it is decided not add the Z flag to src-cli, the error message could be better.
What do you think about it?
The text was updated successfully, but these errors were encountered: