Skip to content

Gitlab runner update #26003

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

Merged
merged 4 commits into from
May 24, 2017
Merged

Gitlab runner update #26003

merged 4 commits into from
May 24, 2017

Conversation

bachp
Copy link
Member

@bachp bachp commented May 22, 2017

Motivation for this change

Update to latest upstream release.
Also apply the patch from 1.11 to 9.2.0

Things done
  • Tested using sandboxing
    (nix.useSandbox on NixOS,
    or option build-use-sandbox in nix.conf
    on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • Linux
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.

Sorry, something went wrong.

bachp added 3 commits May 22, 2017 23:26

Verified

This commit was signed with the committer’s verified signature.

Verified

This commit was signed with the committer’s verified signature.

Verified

This commit was signed with the committer’s verified signature.
@mention-bot
Copy link

@bachp, thanks for your PR! By analyzing the history of the files in this pull request, we identified @fpletz to be a potential reviewer.

@@ -32,6 +32,8 @@ buildGoPackage rec {
sha256 = "0n8hcj2b1pb95x4bd7fb9ri43vgc4h2dj2v3iiziw2imqjyphfx4";
};

patches = [ ./v1-fix-shell-path.patch ];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, that patch really applies cleanly to 9.x? Should've tried that. Thanks! 😄

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes there has been no change to that file ;) Thanks for the patch anyway 👍

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My problem with that dirty patch is that it breaks gitlab-runner from nixpkgs for non-NixOS environments. I'm trying to convince some colleagues who are proficient in go to implement shell path lookup through the PATH environment variable. So we hopefully get a proper fix upstream soon. :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exec's LookPath seems to do what we need here. in case it errors (e.g. b.Shell not found in $PATH), it falls back to the original logic.
far from the perfect solution, but a quick fix for the patch could look something like this:

diff --git a/shells/bash.go b/shells/bash.go
index 839b7781..2b478e1e 100644
--- a/shells/bash.go
+++ b/shells/bash.go
@@ -7,6 +7,7 @@ import (
 	"gitlab.com/gitlab-org/gitlab-ci-multi-runner/common"
 	"gitlab.com/gitlab-org/gitlab-ci-multi-runner/helpers"
 	"io"
+	"os/exec"
 	"path"
 	"runtime"
 	"strconv"
@@ -208,7 +209,11 @@ func (b *BashShell) GetConfiguration(info common.ShellScriptInfo) (script *commo
 	if info.User != "" {
 		script.Command = "su"
 		if runtime.GOOS == "linux" {
-			script.Arguments = append(script.Arguments, "-s", "/bin/"+b.Shell)
+			shellPath, err := exec.LookPath(b.Shell)
+			if err != nil {
+				shellPath = "/bin/"+b.Shell
+			}
+			script.Arguments = append(script.Arguments, "-s", shellPath)
 		}
 		script.Arguments = append(script.Arguments, info.User)
 		script.Arguments = append(script.Arguments, "-c", shellCommand)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@elseym Looks reasonable. Are you willing to push this to gitlab runner upstream?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bachp eventually, yes. changes like this one belong upstream. imma look into it and open a 'merge request' soon :)
for now, let's just use the patch.

Verified

This commit was signed with the committer’s verified signature.
…on NixOS

It now tries to find the shell via path first and then falls back to the original
behavior.
@bachp
Copy link
Member Author

bachp commented May 23, 2017

@elseym @fpletz I changed the patch according to your inputs.

@fpletz
Copy link
Member

fpletz commented May 24, 2017

Thanks!

@fpletz fpletz merged commit d69c296 into NixOS:master May 24, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants