Skip to content

Commit

Permalink
Initial support for new hostbin startup mode
Browse files Browse the repository at this point in the history
  • Loading branch information
mplegendre committed Apr 1, 2014
1 parent 4c83074 commit 1dd436a
Show file tree
Hide file tree
Showing 33 changed files with 1,512 additions and 125 deletions.
3 changes: 3 additions & 0 deletions config.h.in
Expand Up @@ -51,6 +51,9 @@
/* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H

/* Hostbin executable */
#undef HOSTBIN_PATH

/* Number of bytes in keys for gcrypt */
#undef KEY_SIZE_BYTES

Expand Down
53 changes: 33 additions & 20 deletions configure
Expand Up @@ -969,6 +969,7 @@ with_testrm
with_default_port
with_localstorage
enable_bluegene
with_hostbin
enable_pipes
enable_socket
enable_shmem
Expand Down Expand Up @@ -1679,6 +1680,7 @@ Optional Packages:
'slurm' and 'flux')
--with-default-port=NUM TCP Port for Spindle server communication
--with-localstorage=DIR Directory on back-ends for storing relocated files
--with-hostbin=EXE Executable for returning host lists for jobs
--with-python-prefix=STR
List of directories containing python installs
--with-usage-logging=FILE
Expand Down Expand Up @@ -5131,13 +5133,13 @@ if test "${lt_cv_nm_interface+set}" = set; then
else
lt_cv_nm_interface="BSD nm"
echo "int some_variable = 0;" > conftest.$ac_ext
(eval echo "\"\$as_me:5134: $ac_compile\"" >&5)
(eval echo "\"\$as_me:5136: $ac_compile\"" >&5)
(eval "$ac_compile" 2>conftest.err)
cat conftest.err >&5
(eval echo "\"\$as_me:5137: $NM \\\"conftest.$ac_objext\\\"\"" >&5)
(eval echo "\"\$as_me:5139: $NM \\\"conftest.$ac_objext\\\"\"" >&5)
(eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out)
cat conftest.err >&5
(eval echo "\"\$as_me:5140: output\"" >&5)
(eval echo "\"\$as_me:5142: output\"" >&5)
cat conftest.out >&5
if $GREP 'External.*some_variable' conftest.out > /dev/null; then
lt_cv_nm_interface="MS dumpbin"
Expand Down Expand Up @@ -6343,7 +6345,7 @@ ia64-*-hpux*)
;;
*-*-irix6*)
# Find out which ABI we are using.
echo '#line 6346 "configure"' > conftest.$ac_ext
echo '#line 6348 "configure"' > conftest.$ac_ext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>&5
ac_status=$?
Expand Down Expand Up @@ -8934,11 +8936,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
(eval echo "\"\$as_me:8937: $lt_compile\"" >&5)
(eval echo "\"\$as_me:8939: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
echo "$as_me:8941: \$? = $ac_status" >&5
echo "$as_me:8943: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings other than the usual output.
Expand Down Expand Up @@ -9273,11 +9275,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
(eval echo "\"\$as_me:9276: $lt_compile\"" >&5)
(eval echo "\"\$as_me:9278: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
echo "$as_me:9280: \$? = $ac_status" >&5
echo "$as_me:9282: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings other than the usual output.
Expand Down Expand Up @@ -9378,11 +9380,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
(eval echo "\"\$as_me:9381: $lt_compile\"" >&5)
(eval echo "\"\$as_me:9383: $lt_compile\"" >&5)
(eval "$lt_compile" 2>out/conftest.err)
ac_status=$?
cat out/conftest.err >&5
echo "$as_me:9385: \$? = $ac_status" >&5
echo "$as_me:9387: \$? = $ac_status" >&5
if (exit $ac_status) && test -s out/conftest2.$ac_objext
then
# The compiler can only warn and ignore the option if not recognized
Expand Down Expand Up @@ -9433,11 +9435,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
(eval echo "\"\$as_me:9436: $lt_compile\"" >&5)
(eval echo "\"\$as_me:9438: $lt_compile\"" >&5)
(eval "$lt_compile" 2>out/conftest.err)
ac_status=$?
cat out/conftest.err >&5
echo "$as_me:9440: \$? = $ac_status" >&5
echo "$as_me:9442: \$? = $ac_status" >&5
if (exit $ac_status) && test -s out/conftest2.$ac_objext
then
# The compiler can only warn and ignore the option if not recognized
Expand Down Expand Up @@ -12236,7 +12238,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
#line 12239 "configure"
#line 12241 "configure"
#include "confdefs.h"

#if HAVE_DLFCN_H
Expand Down Expand Up @@ -12332,7 +12334,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
#line 12335 "configure"
#line 12337 "configure"
#include "confdefs.h"

#if HAVE_DLFCN_H
Expand Down Expand Up @@ -14352,11 +14354,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
(eval echo "\"\$as_me:14355: $lt_compile\"" >&5)
(eval echo "\"\$as_me:14357: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
echo "$as_me:14359: \$? = $ac_status" >&5
echo "$as_me:14361: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings other than the usual output.
Expand Down Expand Up @@ -14451,11 +14453,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
(eval echo "\"\$as_me:14454: $lt_compile\"" >&5)
(eval echo "\"\$as_me:14456: $lt_compile\"" >&5)
(eval "$lt_compile" 2>out/conftest.err)
ac_status=$?
cat out/conftest.err >&5
echo "$as_me:14458: \$? = $ac_status" >&5
echo "$as_me:14460: \$? = $ac_status" >&5
if (exit $ac_status) && test -s out/conftest2.$ac_objext
then
# The compiler can only warn and ignore the option if not recognized
Expand Down Expand Up @@ -14503,11 +14505,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
(eval echo "\"\$as_me:14506: $lt_compile\"" >&5)
(eval echo "\"\$as_me:14508: $lt_compile\"" >&5)
(eval "$lt_compile" 2>out/conftest.err)
ac_status=$?
cat out/conftest.err >&5
echo "$as_me:14510: \$? = $ac_status" >&5
echo "$as_me:14512: \$? = $ac_status" >&5
if (exit $ac_status) && test -s out/conftest2.$ac_objext
then
# The compiler can only warn and ignore the option if not recognized
Expand Down Expand Up @@ -16076,6 +16078,17 @@ if test "x$OS_BUILD" == "x"; then
OS_BUILD=linux
fi

#Startup type

# Check whether --with-hostbin was given.
if test "${with_hostbin+set}" = set; then
withval=$with_hostbin;
cat >>confdefs.h <<_ACEOF
#define HOSTBIN_PATH "${withval}"
_ACEOF

fi


#Runmode detection (pipe/socket or cobo/msocket communications)
if test "x$OS_BUILD" == "xlinux"; then
Expand Down
4 changes: 4 additions & 0 deletions configure.common.ac
Expand Up @@ -21,6 +21,10 @@ if test "x$OS_BUILD" == "x"; then
OS_BUILD=linux
fi

#Startup type
AC_ARG_WITH(hostbin,
[AS_HELP_STRING([--with-hostbin=EXE],[Executable for returning host lists for jobs])],
[AC_DEFINE_UNQUOTED([HOSTBIN_PATH],"[${withval}]",[Hostbin executable])],)

#Runmode detection (pipe/socket or cobo/msocket communications)
if test "x$OS_BUILD" == "xlinux"; then
Expand Down
71 changes: 64 additions & 7 deletions src/client/beboot/spindle_bootstrap.c
Expand Up @@ -21,6 +21,8 @@ Place, Suite 330, Boston, MA 02111-1307 USA
#include <string.h>
#include <assert.h>
#include <signal.h>
#include <fcntl.h>
#include <sys/wait.h>
#include <sys/types.h>
#include <sys/stat.h>

Expand All @@ -36,7 +38,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA
#if !defined(LIBEXECDIR)
#error Expected to be built with libdir defined
#endif

char spindle_daemon[] = LIBEXECDIR "/spindle_be";

int ldcsid;
static int rankinfo[4]={-1,-1,-1,-1};
Expand All @@ -46,6 +48,7 @@ static char **cmdline;
static char *executable;
static char *client_lib;
static char *opts_s;
static char **daemon_args;

unsigned long opts;

Expand Down Expand Up @@ -98,19 +101,71 @@ static void setup_environment()

static int parse_cmdline(int argc, char *argv[])
{
int i, daemon_arg_count;
if (argc < 4)
return -1;

i = 1;
if (strcmp(argv[1], "-daemon_args") == 0) {
debug_printf("Parsing daemon args out of bootstrap launch line\n");
daemon_arg_count = atoi(argv[2]);
daemon_args = malloc(sizeof(char *) * (daemon_arg_count + 2));
daemon_args[0] = spindle_daemon;
for (i = 4; i < 3 + daemon_arg_count; i++)
daemon_args[i - 3] = argv[i];
daemon_args[i - 3] = NULL;
}

location = argv[1];
number_s = argv[2];
location = argv[i++];
number_s = argv[i++];
number = atoi(number_s);
opts_s = argv[3];
opts_s = argv[i++];
opts = atoi(opts_s);
cmdline = argv + 4;
cmdline = argv + i;
assert(i < argc);

return 0;
}

static void launch_daemon(char *location)
{
/*grand-child fork, then execv daemon. By grand-child forking we ensure that
the app won't get confused by seeing an unknown process as a child. */
pid_t child, gchild;
int status;
int fd;
char unique_file[MAX_PATH_LEN+1];
char buffer[32];

snprintf(unique_file, MAX_PATH_LEN, "%s/spindle_daemon_pid", location);
unique_file[MAX_PATH_LEN] = '\0';
fd = open(unique_file, O_CREAT | O_EXCL | O_WRONLY, 0600);
if (fd == -1) {
debug_printf("Not starting daemon -- %s already exists\n", unique_file);
return;
}
debug_printf("Client is spawning daemon\n");

child = fork();
if (child == 0) {
gchild = fork();
if (gchild != 0) {
snprintf(buffer, sizeof(buffer), "%d\n", getpid());
write(fd, buffer, strlen(buffer));
close(fd);
exit(0);
}
close(fd);
execv(spindle_daemon, daemon_args);
fprintf(stderr, "Spindle error: Could not execv daemon %s\n", daemon_args[0]);
exit(-1);
}
else if (child > 0) {
close(fd);
waitpid(child, &status, 0);
}
}

static void get_executable()
{
if (!(opts & OPT_RELOCAOUT)) {
Expand All @@ -129,8 +184,6 @@ static void get_executable()
debug_printf("Relocated executable %s to %s\n", *cmdline, executable);
chmod(executable, 0700);
}


}

static void adjust_script()
Expand Down Expand Up @@ -226,6 +279,10 @@ int main(int argc, char *argv[])
return -1;
}
location = realize(location);

if (daemon_args) {
launch_daemon(location);
}

result = establish_connection();
if (result == -1) {
Expand Down
3 changes: 3 additions & 0 deletions src/client/config.h.in
Expand Up @@ -45,6 +45,9 @@
/* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H

/* Hostbin executable */
#undef HOSTBIN_PATH

/* Number of bytes in keys for gcrypt */
#undef KEY_SIZE_BYTES

Expand Down

0 comments on commit 1dd436a

Please sign in to comment.