From 26d69329e87e343b84a132a4754068aca66ad132 Mon Sep 17 00:00:00 2001 From: Brett Smith Date: Wed, 7 May 2014 11:28:16 -0400 Subject: [PATCH] crunch: Install Docker images on demand. Ward requested this to simplify the installation and testing procedure. This is sort of temporary scaffolding; we expect that in the future Docker images will be stored in, and read from, Keep. --- sdk/cli/bin/crunch-job | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/sdk/cli/bin/crunch-job b/sdk/cli/bin/crunch-job index 515aaa668d..14b1be9a99 100755 --- a/sdk/cli/bin/crunch-job +++ b/sdk/cli/bin/crunch-job @@ -501,6 +501,27 @@ if (!$have_slurm) # If this job requires a Docker image, install that. my $docker_bin = "/usr/bin/docker.io"; my $docker_image = $Job->{runtime_constraints}->{docker_image} || ""; +if ($docker_image) { + my $docker_pid = fork(); + if ($docker_pid == 0) + { + srun (["srun", "--nodelist=" . join(' ', @node)], + [$docker_bin, 'pull', $docker_image]); + exit ($?); + } + while (1) + { + last if $docker_pid == waitpid (-1, WNOHANG); + freeze_if_want_freeze ($docker_pid); + select (undef, undef, undef, 0.1); + } + # If the Docker image was specified as a hash, pull will fail. + # Ignore that error. We'll see what happens when we try to run later. + if (($? != 0) && ($docker_image !~ /^[0-9a-fA-F]{5,}$/)) + { + croak("Installing Docker image $docker_image returned exit code $?"); + } +} foreach (qw (script script_version script_parameters runtime_constraints)) { -- 2.30.2