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
dockerTools: fixes extraCommands for mkRootLayer. #40947
Conversation
Thanks for your investigation! I think your patch is not working since the Regarding the regression test, you could also reproduce with this expression (which is maybe more close to the issue since is not related to
At run time, we could check these files exist:
|
(Changed as WIP as I will verify the images later) Thanks for the comments! |
Oh wow, thanks for the tip on how to write a more proper test. I'm not used to docker, so I didn't know what and how to test. It's an elegant and simple way to check if the commands ran. I'm not sure whether the I have, once again, checked the new test with and without the change. It does fail before my new fix, and does pass after the new fix. I tested it also with the old fix, and it failed, so you were right! The PR has been updated accordingly. |
nixos/tests/docker-tools.nix
Outdated
contents = [ pkgs.coreutils ]; | ||
# The parens here are to create problematic bash to embed and eval. In case | ||
# this is *embedded* into the script (with nix expansion) the initial quotes | ||
# will close the string and the following parens are unexpected |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can also mention the issue you've opened
let runAsRootScript = shellScript "run-as-root.sh" runAsRoot; | ||
let | ||
runAsRootScript = shellScript "run-as-root.sh" runAsRoot; | ||
extraCommandsScript = shellScript "extracommands.sh" extraCommands; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you call it extra-commands.sh
since run-as-root.sh
is "dashed"
Thanks for you changes. There are just some minor comments. |
The extraCommands was, previously, simply put in the body of the script using nix expansion `${extraCommands}` (which looks exactly like bash expansion!). This causes issues like in NixOS#34779 where scripts will eventually create invalid bash. The solution is to use a script like `run-as-root`. * * * Fixes NixOS#34779
Updated with the relevant changes. |
nixos/tests/docker-tools.nix
Outdated
@@ -16,6 +16,17 @@ import ./make-test.nix ({ pkgs, ... }: { | |||
}; | |||
}; | |||
|
|||
runAsRootExtraCommands = pkgs.dockerTools.buildImage { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Arf, sorry, I haven't seen this image was in this file:/ Could you either move it to docker/examples.nix
or in a
let runAsRootExtraCommands =...
in import ./make-test.nix....
No worries, I want this to be as best as possible. Though I hope now all is well :) |
@GrahamcOfBorg test docker-tools |
Success on aarch64-linux Attempted: tests.docker-tools No partial log is available. |
Success on x86_64-linux (full log) Attempted: tests.docker-tools Partial log (click to expand)
|
Thanks! |
The extraCommands was, previously, simply put in the body of the script
using nix expansion
${extraCommands}
(which looks exactly like bashexpansion!).
This causes issues like in #34779 where scripts will eventually create
invalid bash.
The solution used was to use
$extraCommands
the waymkPureLayer
does, by using the variable from the environment instead of expanding
it inside the script.
Fixes #34779
Motivation for this change
See #34779, this fixes it.
Things done
build-use-sandbox
innix.conf
on non-NixOS)nix-shell -p nox --run "nox-review wip"
./result/bin/
)This was verified using this:
nix-build -I nixpkgs=/path/to/checkout/of/nixpkgs repro.nix
Using this
repro.nix
:This is now verified in a nixos test
Apply the test before the fix to verify the test tests for regression.
cc @nlewo (who seemed to work on the docker tooling a bunch)