-
Notifications
You must be signed in to change notification settings - Fork 367
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
core: Add basic system-config support #8572
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
adding some notes to take care of before merge - avoiding cycling CI before further review
oops, need to use some OS abstraction to open/read the file. |
I misunderstood the CI error at first. I think how I access the file should work, but the SYSCONFDIR preprocessor define seems undefined for Windows build. |
200049c
to
d498ead
Compare
2ec31e5
to
28a0c6b
Compare
Please update the commit message title to something like "core: Add support for system-config files". I'm mostly focused on the 'core' part, so I can identify what component the patch applies to when running git log --oneline 6 months from now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm thinking we may want to add an option to the config file to force it to override the system values in case of a conflict.
2de3f0c
to
f6fb106
Compare
what system values? environment defined values will override config defined values |
I'm suggesting a separate change that allows the config file to override environment variables |
src/var.c
Outdated
if (ofi_prefer_sysconfig) { | ||
conf = find_conf_entry(param->env_var_name); | ||
if (!conf) { | ||
FI_INFO(provider, FI_LOG_CORE, | ||
"variable %s=<not set>\n", param_name); | ||
ret = -FI_ENODATA; | ||
goto out; | ||
FI_DBG(provider, FI_LOG_CORE, | ||
"variable %s=<not set>, checking environment\n", | ||
param_name); | ||
str_value = getenv(param->env_var_name); | ||
if (!str_value) { | ||
FI_INFO(provider, FI_LOG_CORE, | ||
"variable %s=<not set>\n", param_name); | ||
ret = -FI_ENODATA; | ||
goto out; | ||
} | ||
} else { | ||
str_value = conf->value; | ||
} | ||
} else { | ||
str_value = getenv(param->env_var_name); | ||
if (!str_value) { | ||
FI_DBG(provider, FI_LOG_CORE, | ||
"variable %s=<not set>, checking system\n", | ||
param_name); | ||
conf = find_conf_entry(param->env_var_name); | ||
if (!conf) { | ||
FI_INFO(provider, FI_LOG_CORE, | ||
"variable %s=<not set>\n", param_name); | ||
ret = -FI_ENODATA; | ||
goto out; | ||
} | ||
str_value = conf->value; | ||
} | ||
str_value = conf->value; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To reduce code duplication, you can read both conf and env first, and choose the right one based on preference. Something like:
if (ofi_prefer_sysconfig)
str_value = conf->value ? conf->value : env_value;
else
str_value = env_value ? env_value : conf->value;
if (!str_value)
FI_DBG(.....);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did think about this and can move to this if preferred. my concern was adding extra calls to query the environment or looping through the config cache. I suppose the expectation is the cache should be pretty small so querying the environment would be the bigger concern, but we're doing that anyway today so maybe my concern was misplaced...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated to remove duplication!
break; | ||
} | ||
|
||
dlist_insert_tail(&conf->entry, &conf_list); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice to add FI_INFO() here using the core to print all read name-value pairs. This can be added as a separate change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the logging interface requires an instance of a provider, so we can either dump this late (maybe during getinfo?) or we need to add a logging function with that requirement removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use 'core_prov', which is for this purpose.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, tmyk...
Other issue is that this takes place prior to fi_log_init, so the logging system hasn't been initialized. The logging system relies on these variables, so it seems a catch 22
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bah, i guess we'll figure it out when the variables are assigned.
Add support for reading environment variables from a config file on the system. The config file supports a single definition per line, defined as KEY=VALUE any whitespaces (other than '\n') will be preserved. When loading environment variables, check this file for definitions as a fallback Runtime definitions will overwrite system definitions Signed-off-by: Stephen Oost <stephen.oost@intel.com>
There are some situations where the user or administrator will want to force system-configured values for certain variables. This switch enables the config file to select such an option. Signed-off-by: Stephen Oost <stephen.oost@intel.com>
a683510
to
b9c6b7c
Compare
Signed-off-by: Stephen Oost <stephen.oost@intel.com>
Add support for reading environment variables from a config file on the system. The config file supports a single definition per line, defined as KEY=VALUE any whitespaces (other than '\n') will be preserved.
When loading environment variables, check this file for definitions as a fallback
Runtime definitions will overwrite system definitions
This targets an initial solution for #8308