Skip to content

Commit

Permalink
apply patch to openmpi to allow running as root inside Docker
Browse files Browse the repository at this point in the history
  • Loading branch information
simonbyrne committed Aug 12, 2019
1 parent 3db6043 commit 70c57a9
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ include:
- apt-get install --yes --no-install-recommends ssh
- curl https://download.open-mpi.org/release/open-mpi/v${OPENMPI_VER}/openmpi-${OPENMPI_VER_FULL}.tar.gz --output openmpi.tar.gz
- tar xf openmpi.tar.gz
- patch -p1 -d openmpi-${OPENMPI_VER_FULL} < conf/ompi_rootenv.patch
- pushd openmpi-${OPENMPI_VER_FULL}
- ./configure --with-cuda --prefix=${HOME}/mpi
- make -j
Expand Down
28 changes: 28 additions & 0 deletions conf/ompi_rootenv.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
Allow override environment variables to work. This is required for running as root inside a docker container (e.g. Gitlab CI)

See https://github.com/open-mpi/ompi/pull/5597#issuecomment-520612783
--- a/orte/tools/orterun/orterun.c
+++ b/orte/tools/orterun/orterun.c
@@ -143,6 +143,14 @@ int orterun(int argc, char *argv[])
* exit with a giant warning flag
*/
if (0 == geteuid() && !orte_cmd_options.run_as_root) {
+ char *r1, *r2;
+ if (NULL != (r1 = getenv("OMPI_ALLOW_RUN_AS_ROOT")) &&
+ NULL != (r2 = getenv("OMPI_ALLOW_RUN_AS_ROOT_CONFIRM"))) {
+ if (0 == strcmp(r1, "1") && 0 == strcmp(r2, "1")) {
+ goto moveon;
+ }
+ }
+
fprintf(stderr, "--------------------------------------------------------------------------\n");
if (NULL != orte_cmd_options.help) {
fprintf(stderr, "%s cannot provide the help message when run as root.\n", orte_basename);
@@ -160,6 +168,7 @@ int orterun(int argc, char *argv[])
exit(1);
}

+ moveon:
/* setup to listen for commands sent specifically to me, even though I would probably
* be the one sending them! Unfortunately, since I am a participating daemon,
* there are times I need to send a command to "all daemons", and that means *I* have

0 comments on commit 70c57a9

Please sign in to comment.