1
1

Fix incorrect implementation of new MCA param mca_base_env_list - it was not picking up envars and forwarding them, but only worked if you explicitly set a value for the envar. Ensure it works for both direct and indirect launch modes. Remove stale code as this replaced orte_forward_envars. Ensure it doesn't get passed to the ORTE daemons.

Этот коммит содержится в:
Ralph Castain 2014-10-16 12:58:56 -07:00
родитель 08d93bd4b9
Коммит b6aa691e0a
11 изменённых файлов: 80 добавлений и 71 удалений

Просмотреть файл

@ -127,7 +127,6 @@ static int mca_base_var_cache_files (bool rel_path_search);
static int var_set_initial (mca_base_var_t *var); static int var_set_initial (mca_base_var_t *var);
static int var_get (int vari, mca_base_var_t **var_out, bool original); static int var_get (int vari, mca_base_var_t **var_out, bool original);
static int var_value_string (mca_base_var_t *var, char **value_string); static int var_value_string (mca_base_var_t *var, char **value_string);
static int mca_base_var_process_env_list(void);
/* /*
* classes * classes
@ -261,20 +260,7 @@ int mca_base_var_init(void)
mca_base_var_cache_files(false); mca_base_var_cache_files(false);
/* set nesessary env variables for external usage */ /* register the envar-forwarding params */
mca_base_var_process_env_list();
}
return OPAL_SUCCESS;
}
static int mca_base_var_process_env_list(void)
{
int i;
char** tokens;
char* ptr;
char* param, *value;
char sep;
(void)mca_base_var_register ("opal", "mca", "base", "env_list", (void)mca_base_var_register ("opal", "mca", "base", "env_list",
"Set SHELL env variables", "Set SHELL env variables",
MCA_BASE_VAR_TYPE_STRING, NULL, 0, 0, OPAL_INFO_LVL_3, MCA_BASE_VAR_TYPE_STRING, NULL, 0, 0, OPAL_INFO_LVL_3,
@ -283,6 +269,19 @@ static int mca_base_var_process_env_list(void)
"Set SHELL env variables delimiter. Default: semicolon ';'", "Set SHELL env variables delimiter. Default: semicolon ';'",
MCA_BASE_VAR_TYPE_STRING, NULL, 0, 0, OPAL_INFO_LVL_3, MCA_BASE_VAR_TYPE_STRING, NULL, 0, 0, OPAL_INFO_LVL_3,
MCA_BASE_VAR_SCOPE_READONLY, &mca_base_env_list_sep); MCA_BASE_VAR_SCOPE_READONLY, &mca_base_env_list_sep);
}
return OPAL_SUCCESS;
}
int mca_base_var_process_env_list(char ***argv)
{
int i;
char** tokens;
char* ptr;
char* param, *value;
char sep;
if (NULL == mca_base_env_list) { if (NULL == mca_base_env_list) {
return OPAL_SUCCESS; return OPAL_SUCCESS;
} }
@ -307,10 +306,10 @@ static int mca_base_var_process_env_list(void)
value = strchr(param, '='); value = strchr(param, '=');
*value = '\0'; *value = '\0';
value++; value++;
opal_setenv(param, value, true, &environ); opal_setenv(param, value, true, argv);
free(param); free(param);
} else { } else {
opal_setenv(tokens[i], value, true, &environ); opal_setenv(tokens[i], value, true, argv);
} }
} else { } else {
opal_show_help("help-mca-var.txt", "incorrect-env-list-param", opal_show_help("help-mca-var.txt", "incorrect-env-list-param",
@ -321,7 +320,7 @@ static int mca_base_var_process_env_list(void)
value = strchr(param, '='); value = strchr(param, '=');
*value = '\0'; *value = '\0';
value++; value++;
opal_setenv(param, value, true, &environ); opal_setenv(param, value, true, argv);
free(param); free(param);
} }
} }

Просмотреть файл

@ -722,6 +722,12 @@ OPAL_DECLSPEC int mca_base_var_dump(int vari, char ***out, mca_base_var_dump_typ
#define MCA_COMPILETIME_VER "print_compiletime_version" #define MCA_COMPILETIME_VER "print_compiletime_version"
#define MCA_RUNTIME_VER "print_runtime_version" #define MCA_RUNTIME_VER "print_runtime_version"
/*
* Parse a provided list of envars and add their local value, or
* their assigned value, to the provided argv
*/
OPAL_DECLSPEC int mca_base_var_process_env_list(char ***argv);
END_C_DECLS END_C_DECLS
#endif /* OPAL_MCA_BASE_VAR_H */ #endif /* OPAL_MCA_BASE_VAR_H */

Просмотреть файл

@ -18,7 +18,9 @@
#include "opal/types.h" #include "opal/types.h"
#include "opal_stdint.h" #include "opal_stdint.h"
#include "opal/mca/base/mca_base_var.h"
#include "opal/mca/hwloc/base/base.h" #include "opal/mca/hwloc/base/base.h"
#include "opal/util/opal_environ.h"
#include "opal/util/output.h" #include "opal/util/output.h"
#include "opal/util/proc.h" #include "opal/util/proc.h"
#include "opal/util/output.h" #include "opal/util/output.h"
@ -235,6 +237,9 @@ static int cray_init(void)
} }
} }
/* setup any local envars we were asked to do */
mca_base_var_process_env_list(&environ);
return OPAL_SUCCESS; return OPAL_SUCCESS;
err_exit: err_exit:
PMI2_Finalize(); PMI2_Finalize();

Просмотреть файл

@ -13,7 +13,9 @@
#include "opal/types.h" #include "opal/types.h"
#include "opal_stdint.h" #include "opal_stdint.h"
#include "opal/mca/base/mca_base_var.h"
#include "opal/mca/hwloc/base/base.h" #include "opal/mca/hwloc/base/base.h"
#include "opal/util/opal_environ.h"
#include "opal/util/output.h" #include "opal/util/output.h"
#include "opal/util/proc.h" #include "opal/util/proc.h"
#include "opal/util/show_help.h" #include "opal/util/show_help.h"
@ -290,6 +292,9 @@ static int s1_init(void)
goto err_exit; goto err_exit;
} }
/* setup any local envars we were asked to do */
mca_base_var_process_env_list(&environ);
return OPAL_SUCCESS; return OPAL_SUCCESS;
err_exit: err_exit:

Просмотреть файл

@ -18,7 +18,9 @@
#include "opal/types.h" #include "opal/types.h"
#include "opal_stdint.h" #include "opal_stdint.h"
#include "opal/mca/base/mca_base_var.h"
#include "opal/mca/hwloc/base/base.h" #include "opal/mca/hwloc/base/base.h"
#include "opal/util/opal_environ.h"
#include "opal/util/output.h" #include "opal/util/output.h"
#include "opal/util/proc.h" #include "opal/util/proc.h"
#include "opal/util/show_help.h" #include "opal/util/show_help.h"
@ -259,6 +261,9 @@ static int s2_init(void)
} }
} }
/* setup any local envars we were asked to do */
mca_base_var_process_env_list(&environ);
return OPAL_SUCCESS; return OPAL_SUCCESS;
err_exit: err_exit:
PMI2_Finalize(); PMI2_Finalize();

Просмотреть файл

@ -573,6 +573,11 @@ static int setup_launch(int *argcptr, char ***argvptr,
* only if they aren't already present * only if they aren't already present
*/ */
for (i = 0; NULL != environ[i]; ++i) { for (i = 0; NULL != environ[i]; ++i) {
if (0 == strncmp("OMPI_MCA_mca_base_env_list", environ[i],
strlen("OMPI_MCA_mca_base_env_list"))) {
/* ignore this one */
continue;
}
if (0 == strncmp("OMPI_MCA", environ[i], 8)) { if (0 == strncmp("OMPI_MCA", environ[i], 8)) {
/* check for duplicate in app->env - this /* check for duplicate in app->env - this
* would have been placed there by the * would have been placed there by the

Просмотреть файл

@ -781,6 +781,7 @@ int orte_daemon(int argc, char *argv[])
"orte_ess_vpid", "orte_ess_vpid",
"orte_ess_num_procs", "orte_ess_num_procs",
"orte_parent_uri", "orte_parent_uri",
"mca_base_env_list",
NULL NULL
}; };
for (i=0; i < argc; i++) { for (i=0; i < argc; i++) {

Просмотреть файл

@ -177,7 +177,6 @@ bool orte_abort_non_zero_exit;
int orte_stat_history_size; int orte_stat_history_size;
/* envars to forward */ /* envars to forward */
char *orte_forward_envars = NULL;
char **orte_forwarded_envars = NULL; char **orte_forwarded_envars = NULL;
/* map-reduce mode */ /* map-reduce mode */

Просмотреть файл

@ -556,7 +556,6 @@ ORTE_DECLSPEC extern bool orte_abort_non_zero_exit;
ORTE_DECLSPEC extern int orte_stat_history_size; ORTE_DECLSPEC extern int orte_stat_history_size;
/* envars to forward */ /* envars to forward */
ORTE_DECLSPEC extern char *orte_forward_envars;
ORTE_DECLSPEC extern char **orte_forwarded_envars; ORTE_DECLSPEC extern char **orte_forwarded_envars;
/* map-reduce mode */ /* map-reduce mode */

Просмотреть файл

@ -658,13 +658,6 @@ int orte_register_params(void)
OPAL_INFO_LVL_9, MCA_BASE_VAR_SCOPE_READONLY, OPAL_INFO_LVL_9, MCA_BASE_VAR_SCOPE_READONLY,
&orte_stat_history_size); &orte_stat_history_size);
orte_forward_envars = NULL;
(void) mca_base_var_register ("orte", "orte", NULL, "forward_envars",
"Comma-delimited environmental variables to forward, can include value to set",
MCA_BASE_VAR_TYPE_STRING, NULL, 0, 0,
OPAL_INFO_LVL_9, MCA_BASE_VAR_SCOPE_READONLY,
&orte_forward_envars);
orte_max_vm_size = -1; orte_max_vm_size = -1;
(void) mca_base_var_register ("orte", "orte", NULL, "max_vm_size", (void) mca_base_var_register ("orte", "orte", NULL, "max_vm_size",
"Maximum size of virtual machine - used to subdivide allocation", "Maximum size of virtual machine - used to subdivide allocation",

Просмотреть файл

@ -834,8 +834,10 @@ int orterun(int argc, char *argv[])
*/ */
orte_launch_environ = opal_argv_copy(environ); orte_launch_environ = opal_argv_copy(environ);
/* purge an ess flag set externally */ /* purge any ess flag set externally */
opal_unsetenv("OMPI_MCA_ess", &orte_launch_environ); opal_unsetenv("OMPI_MCA_ess", &orte_launch_environ);
/* purge the env list, if set */
opal_unsetenv("OMPI_MCA_mca_base_env_list", &orte_launch_environ);
#if OPAL_ENABLE_FT_CR == 1 #if OPAL_ENABLE_FT_CR == 1
/* Disable OPAL CR notifications for this tool */ /* Disable OPAL CR notifications for this tool */
@ -1533,6 +1535,11 @@ static int capture_cmd_line_params(int argc, int start, char **argv)
for (i = 0; i < (argc-start); ++i) { for (i = 0; i < (argc-start); ++i) {
if (0 == strcmp("-mca", argv[i]) || if (0 == strcmp("-mca", argv[i]) ||
0 == strcmp("--mca", argv[i]) ) { 0 == strcmp("--mca", argv[i]) ) {
/* ignore this one */
if (0 == strcmp(argv[i+1], "mca_base_env_list")) {
i += 2;
continue;
}
/* It would be nice to avoid increasing the length /* It would be nice to avoid increasing the length
* of the orted cmd line by removing any non-ORTE * of the orted cmd line by removing any non-ORTE
* params. However, this raises a problem since * params. However, this raises a problem since
@ -1624,11 +1631,13 @@ static int create_app(int argc, char* argv[],
opal_cmd_line_t cmd_line; opal_cmd_line_t cmd_line;
char cwd[OPAL_PATH_MAX]; char cwd[OPAL_PATH_MAX];
int i, j, count, rc; int i, j, count, rc;
char *param, *value, *value2; char *param, *value;
orte_app_context_t *app = NULL; orte_app_context_t *app = NULL;
bool cmd_line_made = false; bool cmd_line_made = false;
bool found = false; bool found = false;
char *appname; char *appname;
char **vars;
char *env_set_flag;
*made_app = false; *made_app = false;
@ -1718,8 +1727,8 @@ static int create_app(int argc, char* argv[],
} }
/* Did the user request to export any environment variables on the cmd line? */ /* Did the user request to export any environment variables on the cmd line? */
env_set_flag = getenv("OMPI_MCA_mca_base_env_list");
if (opal_cmd_line_is_taken(&cmd_line, "x")) { if (opal_cmd_line_is_taken(&cmd_line, "x")) {
char* env_set_flag = getenv("OMPI_MCA_mca_base_env_list");
if (NULL != env_set_flag) { if (NULL != env_set_flag) {
orte_show_help("help-orterun.txt", "orterun:conflict-env-set", false); orte_show_help("help-orterun.txt", "orterun:conflict-env-set", false);
return ORTE_ERR_FATAL; return ORTE_ERR_FATAL;
@ -1730,59 +1739,42 @@ static int create_app(int argc, char* argv[],
for (i = 0; i < j; ++i) { for (i = 0; i < j; ++i) {
param = opal_cmd_line_get_param(&cmd_line, "x", i, 0); param = opal_cmd_line_get_param(&cmd_line, "x", i, 0);
if (NULL != strchr(param, '=')) { if (NULL != (value = strchr(param, '='))) {
opal_argv_append_nosize(&app->env, param); /* terminate the name of the param */
*value = '\0';
/* step over the equals */
value++;
/* overwrite any prior entry */
opal_setenv(param, value, true, &app->env);
/* save it for any comm_spawn'd apps */ /* save it for any comm_spawn'd apps */
opal_argv_append_nosize(&orte_forwarded_envars, param); opal_setenv(param, value, true, &orte_forwarded_envars);
} else { } else {
value = getenv(param); value = getenv(param);
if (NULL != value) { if (NULL != value) {
if (NULL != strchr(value, '=')) { /* overwrite any prior entry */
opal_argv_append_nosize(&app->env, value); opal_setenv(param, value, true, &app->env);
/* save it for any comm_spawn'd apps */ /* save it for any comm_spawn'd apps */
opal_argv_append_nosize(&orte_forwarded_envars, value); opal_setenv(param, value, true, &orte_forwarded_envars);
} else {
asprintf(&value2, "%s=%s", param, value);
opal_argv_append_nosize(&app->env, value2);
/* save it for any comm_spawn'd apps */
opal_argv_append_nosize(&orte_forwarded_envars, value2);
free(value2);
}
} else { } else {
opal_output(0, "Warning: could not find environment variable \"%s\"\n", param); opal_output(0, "Warning: could not find environment variable \"%s\"\n", param);
} }
} }
} }
} } else if (NULL != env_set_flag) {
/* set necessary env variables for external usage */
/* Did the user request to export any environment variables via MCA param? */ vars = NULL;
if (NULL != orte_forward_envars) { if (OPAL_SUCCESS == mca_base_var_process_env_list(&vars) &&
char **vars; NULL != vars) {
vars = opal_argv_split(orte_forward_envars, ',');
for (i=0; NULL != vars[i]; i++) { for (i=0; NULL != vars[i]; i++) {
if (NULL != strchr(vars[i], '=')) { value = strchr(vars[i], '=');
/* user supplied a value */ /* terminate the name of the param */
opal_argv_append_nosize(&app->env, vars[i]); *value = '\0';
/* step over the equals */
value++;
/* overwrite any prior entry */
opal_setenv(param, value, true, &app->env);
/* save it for any comm_spawn'd apps */ /* save it for any comm_spawn'd apps */
opal_argv_append_nosize(&orte_forwarded_envars, vars[i]); opal_setenv(param, value, true, &orte_forwarded_envars);
} else {
/* get the value from the environ */
value = getenv(vars[i]);
if (NULL != value) {
if (NULL != strchr(value, '=')) {
opal_argv_append_nosize(&app->env, value);
/* save it for any comm_spawn'd apps */
opal_argv_append_nosize(&orte_forwarded_envars, value);
} else {
asprintf(&value2, "%s=%s", vars[i], value);
opal_argv_append_nosize(&app->env, value2);
/* save it for any comm_spawn'd apps */
opal_argv_append_nosize(&orte_forwarded_envars, value2);
free(value2);
}
} else {
opal_output(0, "Warning: could not find environment variable \"%s\"\n", param);
}
} }
} }
opal_argv_free(vars); opal_argv_free(vars);