Skip to content

Commit eb577d4

Browse files
committed
Inherit env directives if requested
If someone specifies that child jobs inherit from their parents, then have them inherit any env directives as well as job-level directives. Have children inherit their parent's inheritance directive, unless directed not to do so. Signed-off-by: Ralph Castain <[email protected]>
1 parent 661d6be commit eb577d4

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

src/mca/odls/base/odls_base_default_fns.c

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1252,14 +1252,15 @@ void prte_odls_base_default_launch_local(int fd, short sd, void *cbdata)
12521252
int j, idx;
12531253
int total_num_local_procs = 0;
12541254
prte_odls_launch_local_t *caddy = (prte_odls_launch_local_t *) cbdata;
1255-
prte_job_t *jobdat;
1255+
prte_job_t *jobdat, *parent;
12561256
pmix_nspace_t job;
12571257
prte_odls_base_fork_local_proc_fn_t fork_local = caddy->fork_local;
1258-
bool index_argv;
1258+
bool index_argv, inherit;
12591259
char *msg, **xfer;
12601260
prte_odls_spawn_caddy_t *cd;
12611261
prte_event_base_t *evb;
12621262
prte_schizo_base_module_t *schizo;
1263+
pmix_proc_t *nptr;
12631264
PRTE_HIDE_UNUSED_PARAMS(fd, sd);
12641265

12651266
PMIX_ACQUIRE_OBJECT(caddy);
@@ -1352,6 +1353,20 @@ void prte_odls_base_default_launch_local(int fd, short sd, void *cbdata)
13521353
}
13531354
}
13541355

1356+
// see if we have a parent in case of inheritance
1357+
nptr = NULL;
1358+
prte_get_attribute(&jobdat->attributes, PRTE_JOB_LAUNCH_PROXY, (void **) &nptr, PMIX_PROC);
1359+
if (NULL != nptr) {
1360+
parent = prte_get_job_data_object(nptr->nspace);
1361+
if (NULL != parent) {
1362+
inherit = prte_get_attribute(&parent->attributes, PRTE_JOB_INHERIT, NULL, PMIX_BOOL);
1363+
} else {
1364+
inherit = false;
1365+
}
1366+
} else {
1367+
inherit = false;
1368+
}
1369+
13551370
for (j = 0; j < jobdat->apps->size; j++) {
13561371
app = (prte_app_context_t *) pmix_pointer_array_get_item(jobdat->apps, j);
13571372
if (NULL == app) {
@@ -1395,6 +1410,10 @@ void prte_odls_base_default_launch_local(int fd, short sd, void *cbdata)
13951410
}
13961411

13971412
// process any provided env directives
1413+
if (inherit) {
1414+
// start with the parent's directives
1415+
process_envars(parent, app);
1416+
}
13981417
process_envars(jobdat, app);
13991418

14001419

src/mca/rmaps/base/rmaps_base_map_job.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,11 +241,18 @@ void prte_rmaps_base_map_job(int fd, short args, void *cbdata)
241241
// mapped by us
242242
inherit = false;
243243
parent = NULL;
244+
244245
} else if (prte_get_attribute(&parent->attributes, PRTE_JOB_INHERIT, NULL, PMIX_BOOL)) {
245246
inherit = true;
247+
// if they didn't specifically direct it not inherit, then pass this on to the child
248+
if (!prte_get_attribute(&jdata->attributes, PRTE_JOB_NOINHERIT, NULL, PMIX_BOOL)) {
249+
prte_set_attribute(&jdata->attributes, PRTE_ATTR_GLOBAL, PRTE_JOB_INHERIT, NULL, PMIX_BOOL);
250+
}
251+
246252
} else if (prte_get_attribute(&parent->attributes, PRTE_JOB_NOINHERIT, NULL, PMIX_BOOL)) {
247253
inherit = false;
248254
parent = NULL;
255+
249256
} else {
250257
inherit = prte_rmaps_base.inherit;
251258
}

0 commit comments

Comments
 (0)