From 77076d7e1625e006c5991fee7bbd7fa41514de4d Mon Sep 17 00:00:00 2001 From: Moe Jette <jette1@llnl.gov> Date: Fri, 27 Feb 2009 22:01:57 +0000 Subject: [PATCH] Add explicit spank_init_post_opt call for srun, salloc, and sbatch PATCH 9/9 from Mark Grondona Expand test7.11 to validate new features. --- src/common/plugstack.c | 44 +++++++++++++++++++++++++++++++++------ src/common/plugstack.h | 2 ++ src/salloc/salloc.c | 3 +++ src/sbatch/sbatch.c | 3 +++ src/srun/srun.c | 3 +++ testsuite/expect/test7.11 | 36 ++++++++++++++++++++++++-------- 6 files changed, 76 insertions(+), 15 deletions(-) diff --git a/src/common/plugstack.c b/src/common/plugstack.c index 2ca2c278975..47e4b6311cb 100644 --- a/src/common/plugstack.c +++ b/src/common/plugstack.c @@ -663,20 +663,41 @@ int _spank_init(enum spank_context_type context, slurmd_job_t * job) if (_do_call_stack(SPANK_INIT, job, -1) < 0) return (-1); - if (job && spank_get_remote_options(job->options) < 0) { - error("spank: Unable to get remote options"); + /* + * Nothing more to do unless we are in remote context: + */ + if (spank_ctx != S_CTX_REMOTE) + return (0); + + /* + * Remote-specific code: + */ + if (!job) { + error("spank: spank_init called without job reference!"); return (-1); } - if (job && spank_get_remote_options_env(job->env) < 0) { - error("spank: Unable to get remote options from environment"); + /* + * Get any remote options from job launch message: + */ + if (spank_get_remote_options(job->options) < 0) { + error("spank: Unable to get remote options"); return (-1); } - if (_do_call_stack(SPANK_INIT_POST_OPT, job, -1) < 0) + /* + * Get any remote option passed thru environment + */ + if (spank_get_remote_options_env(job->env) < 0) { + error("spank: Unable to get remote options from environment"); return (-1); + } - return (0); + /* + * Now that all options have been processed, we can + * call the post_opt handlers here in remote context. + */ + return (_do_call_stack(SPANK_INIT_POST_OPT, job, -1) < 0); } int spank_init (slurmd_job_t * job) @@ -692,6 +713,17 @@ int spank_init_allocator (void) return _spank_init (S_TYPE_ALLOCATOR, NULL); } +int spank_init_post_opt (void) +{ + /* + * In allocator context, set remote options in env here. + */ + if (spank_ctx == S_TYPE_ALLOCATOR) + spank_set_remote_options_env(); + + return (_do_call_stack(SPANK_INIT_POST_OPT, NULL, -1)); +} + int spank_user(slurmd_job_t * job) { return (_do_call_stack(STEP_USER_INIT, job, -1)); diff --git a/src/common/plugstack.h b/src/common/plugstack.h index 16e551265f1..b9096b7e5d3 100644 --- a/src/common/plugstack.h +++ b/src/common/plugstack.h @@ -68,6 +68,8 @@ int spank_init (slurmd_job_t *job); int spank_init_allocator (void); +int spank_init_post_opt (void); + int spank_user (slurmd_job_t *job); int spank_local_user (struct spank_launcher_job_info *job); diff --git a/src/salloc/salloc.c b/src/salloc/salloc.c index 1d46ad5608d..300c366bd11 100644 --- a/src/salloc/salloc.c +++ b/src/salloc/salloc.c @@ -143,6 +143,9 @@ int main(int argc, char *argv[]) log_alter(logopt, 0, NULL); } + if (spank_init_post_opt() < 0) + fatal("Plugin stack post-option processing failed"); + if (opt.cwd && chdir(opt.cwd)) { error("chdir(%s): %m", opt.cwd); exit(1); diff --git a/src/sbatch/sbatch.c b/src/sbatch/sbatch.c index 4d890bc13de..52f2076a9a0 100644 --- a/src/sbatch/sbatch.c +++ b/src/sbatch/sbatch.c @@ -100,6 +100,9 @@ int main(int argc, char *argv[]) fatal("sbatch parameter parsing"); } + if (spank_init_post_opt() < 0) + fatal("Plugin stack post-option processing failed"); + if (opt.get_user_env_time < 0) { /* Moab does not propage the user's resource limits, so * slurmd determines the values at the same time that it diff --git a/src/srun/srun.c b/src/srun/srun.c index 1edb42033b4..d0d31af68b6 100644 --- a/src/srun/srun.c +++ b/src/srun/srun.c @@ -199,6 +199,9 @@ int srun(int ac, char **av) exit (1); } record_ppid(); + + if (spank_init_post_opt() < 0) + fatal("Plugin stack post-option processing failed."); /* reinit log with new verbosity (if changed by command line) */ diff --git a/testsuite/expect/test7.11 b/testsuite/expect/test7.11 index 58521970723..1d7e0170f83 100755 --- a/testsuite/expect/test7.11 +++ b/testsuite/expect/test7.11 @@ -290,10 +290,12 @@ if {[wait_for_file $file_out] == 0} { # if {[wait_for_file $spank_out] == 0} { send_user "\n\n" - set matches 0 - spawn $bin_cat $spank_out + set matches 0 + set matches_sbatch 0 + set matches_srun 0 + spawn $bin_sort $spank_out expect { - -re "slurm_spank_task_init: opt_arg=5" { + -re "spank_get_item: argv" { incr matches exp_continue } @@ -301,20 +303,36 @@ if {[wait_for_file $spank_out] == 0} { incr matches exp_continue } - -re "spank_get_item: argv" { - incr matches + -re "slurm_spank_exit: opt_arg=($number)" { + if {$expect_out(1,string) == 4} { + incr matches_sbatch + } + if {$expect_out(1,string) == 5} { + incr matches_srun + } exp_continue } - -re "slurm_spank_exit: opt_arg=5" { - incr matches + -re "slurm_spank_task_init: opt_arg=($number)" { + if {$expect_out(1,string) == 4} { + incr matches_sbatch + } + if {$expect_out(1,string) == 5} { + incr matches_srun + } exp_continue } eof { wait } } - if {$matches != 4} { - send_user "\nFAILURE: remote (slurmd) spank plugin failure\n" + if {$matches_sbatch != 2} { + send_user "\nFAILURE: remote (slurmd) sbatch spank plugin failure ($matches_sbatch)\n" + set exit_code 1 + } elseif {$matches_srun != 2} { + send_user "\nFAILURE: remote (slurmd) srun spank plugin failure ($matches_srun)\n" + set exit_code 1 + } elseif {$matches != 4} { + send_user "\nFAILURE: remote (slurmd) spank plugin failure ($matches)\n" set exit_code 1 } else { send_user "\n remote (slurmd) spank plugin success\n" -- GitLab