fix SINGULARITYENV_PATH#1389
fix SINGULARITYENV_PATH#1389GodloveD wants to merge 12 commits intoapptainer:development-2.xfrom GodloveD:fix-SINGULARITYENV_PATH
Conversation
|
Conceptually, it looks good to me! |
| @@ -0,0 +1,12 @@ | |||
| MAINTAINERCLEANFILES = Makefile.in | |||
| DISTCLEANFILES = Makefile | |||
| CLEANFILES = core.* *~ *.la | |||
| noinst_LTLIBRARIES = libinternal.la | ||
| libinternal_la_SOURCES = 11_udsep.c | ||
|
|
||
| EXTRA_DIST = 11_udsep.c |
There was a problem hiding this comment.
Just to add in here as well... Change this to:
EXTRA_DIST = 11_udsep.h
|
|
||
| singularity_message(VERBOSE2, "Creating empty /.singularity.d/env/11-user_defined_SINGULARITYENV_PATH.sh in %s\n", containerdir); | ||
| singularity_priv_escalate(); | ||
| if ( ( fileput(joinpath(containerdir, "/.singularity.d/env/11-user_defined_SINGULARITYENV_PATH.sh"), "") ) !=0 ) { |
There was a problem hiding this comment.
If overlayfs is not supported or not enabled in singularity.conf and if image is not writable, test will always fail
|
@GodloveD I just comment about a concern for creation of the environment file into container when there is no overlay or if overlay is disabled in configuration file. The other option for most setup is to copy /.singularity.d/env folder into session folder, add the environment file into session/env and bind it into container over /.singularity.d/env |
cclerget
left a comment
There was a problem hiding this comment.
Potential problem with overlayfs presence
|
Thank you for the thorough review @cclerget! I'll work to update this so that it works without overlayfs. |
…ms that lack overlay support. Also added utility to recursively copy directories.
|
Heya @cclerget I've tested this on CentOS6 and it seems to be working as expected now. Let me know what you think. Thanks! |
|
This is giving correct behaviour for me in all 3 situations. No Dockerfile custom path, No SINGULARITYENV_PATH No Dockerfile custom path, Set SINGULARITYENV_PATH Dockerfile custom path, No SINGULARITYENV_PATH Dockerfile custom path, Set SINGULARITYENV_PATH Also confirmed this behaviour on a .img built under a previous version of Singularity. |
dtrudg
left a comment
There was a problem hiding this comment.
Have tested the latest version of this PR and confirm it works as expected to handle Dockerfile and SINGULARITYENV_PATH paths on new and pre-existing containers.
|
I also tested this PR on EL6 and EL7 along the same lines as @dctrud and can confirm that the PR fixes the issue. Thank you! |
|
Hey everyone, Apologies for my latent involvement but I just saw this now, and I have some strong feelings about this. Singularity was creating containers with a "bug" in how we dealt with overriding the contained PATH. A contained environment should be 100% reproducible (to the fullest extent of the realm of possibilities) which means, a container image that has a bug, should be consistent about reproducing that bug between Singularity versions. This means it should be fixed at the build stage so new containers are reproducibly working. Another issue I have with this implementation is that it injects a runtime based modification into the inner-workings of how the contained "driver" subsystem works. This "driver" subsystem is how the Singularity runtime interfaces with the container runtime ( I have ideas on how to make this much better for Singularity v3, but I have not had the chance to articulate or code them yet. At this point, the best way to solve this issue is to provide a fix for new containers being created and not try to kludge for existing (broken) containers. I realize this is not ideal for some people, but from the architectural and consistency perspectives, it is the right way to handle. Greg |
|
Thanks for the comment @gmkurtzer. If we go this route instead of fixing the container at build time we will also need to maintain a similar workflow in future versions. After talking with @gmkurtzer and thinking it over a bit I agree that this is not a good way to fix the issue and we should not try to fix containers that have already been built at runtime. Sorry @moskalenko. I think I'm just going to go ahead and implement a method for overwriting, prepending, or appending to the container path at runtime with env vars like you suggested in #1363 @moskalenko. But this is only going to work for newly created containers. I'll submit a new PR shortly. |
|
This PR is closed in favour of the approach implemented in #1430 |
Description of the Pull Request (PR):
In the days of yore, a user could specify a value of
SINGULARITYENV_PATHand this would be prepended to thePATHinside their container at runtime. Some time ago, this option was broken by the addition of a file in/.singularity.d/envcalled10-docker.shwhich overwrites the base path set in c with whatever path is set in Docker. This is necessary because the user may have added custom paths to the container in the Docker file. But it breaksSINGULARITYENV_PATH.This is a tough problem. The
10-docker.shfile should overwrite thePATHand afterward, any value ofSINGULARITYENV_PATHshould be prepended to the result. But by the time10-docker.shis running, we have already entered the container and anySINGULARITYENV_PATHvariable is long gone. The issue is even more problematic because a bunch of containers already exist that have the10-docker.shfile in their meta-data.This PR fixes the problem by adding an ephemeral file to
/.singularity.d/envat runtime on demand. If, (and only if) a user hasSINGULARITYENV_PATHset to some path in their environment it will be added to a new file called11-user_defined_SINGULARITYENV_PATH.shto be sourced following10-docker. This file will not actually be added to the container (of course) and will disappear upon exit.For example, if the user does this:
They will get this:
Because of this:
This fixes or addresses the following GitHub issues:
Checkoff for all PRs:
make testAttn: @singularityware-admin