Skip to content

Commit

Permalink
DAOS-14532 gurt: fix environment APIs hook (#13579)
Browse files Browse the repository at this point in the history
Replace call to the standard getenv() function with d_isenv_def(), d_agetenv() and d_freeenv_str().
It also renames the d_free_env_str() function intoduce in previous related PRs to d_freeenv_str().


# NOTE: The following default set of pragmas will result in no build
#       or test.
#
#       Please edit the list of pragmas to produce the minimal amount of build
#       and test to prove your PR works.
#
#       Or if you have already done the above, and your PR is ready for it's
#       final for-landing run, remove all of the following pragmas.
#
#       More detail can be found at
#       https://wiki.hpdd.intel.com/display/CI/Commit+Pragmas.
# You should not use this one without prior approval:
#Priority: 3
# Run the GitHub Actions test jobs
#Run-GHA: false
Skip-checkpatch: true
Skip-python-bandit: true
Skip-build: true
# Or you can skip specific PR build stages:
#Skip-build-ubuntu20-rpm: true
#Skip-build-el8-rpm: true
#Skip-build-leap15-rpm: true
#Skip-build-el8-gcc: true
#Skip-build-el8-gcc-debug: true
#Skip-build-el8-gcc-release: true
#Skip-build-leap15-gcc: true
#Skip-build-leap15-icc: true
#Skip-build-ubuntu-clang: true

# And/or you could just enable quick-build below which reduces build tims considerably
Quick-build: true
# Just build and run Functional tests, skipping all others
Quick-Functional: true
# or building with multiple jobs
#Parallel-build: true

#Skip-unit-tests: true
# Or you could choose which Unit Test stages to skip below
#Skip-nlt: true
#Skip-unit-test: true
#Skip-unit-test-memcheck: true
#Skip-test: true

# Every run should include the features it is testing.  Uncomment the below
# line and add the features (space separated) your PR should be testing for.
# I.e. rebuild, ...
#Features:

# Or you can choose which test stages to skip below
#Skip-coverity-test: true
#Skip-fault-injection-test: true
# Skip all Functional test stages
#Skip-func-test: true
# Skip all Functional test stages on VMs
#Skip-func-test-vm: true
# Don't skip the valgrind functional test
#Skip-func-test-vm-valgrind: false
# Skip Functional test stages on EL7, EL8 or Leap 15
#Skip-func-test-el7: true
#Skip-func-test-el8: true
#Skip-func-test-leap15: true
# Skip all Functional test stages on hardware
#Skip-func-hw-test: true
# or just specific hardware test stages
#Skip-func-hw-test-small: true
#Skip-func-hw-test-medium: true
#Skip-func-hw-test-medium-verbs-provider: true
#Skip-func-hw-test-medium-ucx-provider: true
#Skip-func-hw-test-large: true
#Skip-scan-rpms: true
#Skip-test-rpms: true
# or per distro variants:
#Skip-scan-centos-rpms: true
#Skip-scan-centos-7-rpms: true
#Skip-scan-centos-8-rpms: true
#Skip-scan-leap-15-rpms: true
#Skip-test-centos-rpms: true
#Skip-test-centos-7-rpms: true
#Skip-test-centos-8-rpms: true
#Skip-test-centos-8.3-rpms: true

# If you do run any of the above Functional test stages, please use the following to
# limit your tests run to the tests/features you are working on
# You can add the tags for your tests to the appropriate pragmas below:
#Test-tag: -hw
#Test-tag-hw-small: hw,small
#Test-tag-hw-medium: hw,medium,ib2
#Test-tag-hw-large: hw,large

# If you want to allow Hardware testing to run even if VM testing fails:
Allow-unstable-test: true

# if you want to test your PR with a PR of a component, you can speify that PR:
#PR-repos: project@PR-number[:build_num]

# if you want to disable using RPMs in the Functional tests:
#RPM-test: false

# Or if you want to test with daos RPMs that are already built (i.e. in another PR or in the repo):
#RPM-test-version: version[-release]
# to get the latest RPMs for the current verison:
#RPM-test-version: 2.5.100

# This should be figured out automatically, but you can force it with
#Doc-only: true

# If you want to use a repo-files PR
# Repo-files-PR: PR-123

# If you'd prefer not to have your PRs cluttered up with stage failure
# comments, uncomment this
# Skip-PR-comments: true

# ansible-role-snapshot_host-branch: branch-name
# ansible-role-kvm-branch: branch-name

# to use a different cluster for various stages
# VM1-label: ci_vm1
# Ubuntu-VM9-label: ci_vm9
# Leap15-VM9-label: ci_vm9
# EL8-VM9-label: ci_vm9
# HW-medium-label: ci_nvme5
# HW-large-label: ci_nvme9

# to tell CI not to skip a test due to a ticket
# Fixes: DAOS-1234
#
# If you are ready to push a full CI build and test you can uncomment
# the below pragma:
#Full-CI-run: true
Signed-off-by: Cedric Koch-Hofer <cedric.koch-hofer@intel.com>
  • Loading branch information
knard-intel authored and brianjmurrell committed Jan 31, 2024
1 parent a478844 commit 91a2784
Show file tree
Hide file tree
Showing 41 changed files with 425 additions and 280 deletions.
3 changes: 2 additions & 1 deletion src/bio/bio_xstream.c
Original file line number Diff line number Diff line change
Expand Up @@ -293,11 +293,12 @@ bio_nvme_init(const char *nvme_conf, int numa_node, unsigned int mem_size,
nvme_glb.bd_bs_opts.cluster_sz = DAOS_BS_CLUSTER_SZ;
nvme_glb.bd_bs_opts.max_channel_ops = BIO_BS_MAX_CHANNEL_OPS;

env = getenv("VOS_BDEV_CLASS");
d_agetenv_str(&env, "VOS_BDEV_CLASS");
if (env && strcasecmp(env, "AIO") == 0) {
D_WARN("AIO device(s) will be used!\n");
nvme_glb.bd_bdev_class = BDEV_CLASS_AIO;
}
d_freeenv_str(&env);

if (numa_node > 0) {
bio_numa_node = (unsigned int)numa_node;
Expand Down
9 changes: 3 additions & 6 deletions src/cart/crt_hg.c
Original file line number Diff line number Diff line change
Expand Up @@ -793,8 +793,7 @@ crt_hg_free_protocol_info(struct na_protocol_info *na_protocol_info)
int
crt_hg_init(void)
{
int rc = 0;
char *env;
int rc = 0;

if (crt_initialized()) {
D_ERROR("CaRT already initialized.\n");
Expand All @@ -803,10 +802,8 @@ crt_hg_init(void)

#define EXT_FAC DD_FAC(external)

env = getenv("HG_LOG_SUBSYS");
if (!env) {
env = getenv("HG_LOG_LEVEL");
if (!env)
if (!d_isenv_def("HG_LOG_SUBSYS")) {
if (!d_isenv_def("HG_LOG_LEVEL"))
HG_Set_log_level("warning");
HG_Set_log_subsys("hg,na");
}
Expand Down
228 changes: 119 additions & 109 deletions src/cart/crt_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,44 @@ static volatile int gdata_init_flag;
struct crt_plugin_gdata crt_plugin_gdata;
static bool g_prov_settings_applied[CRT_PROV_COUNT];

/* List of the environment variables used in CaRT */
static const char *crt_env_names[] = {"D_PROVIDER",
"D_INTERFACE",
"D_DOMAIN",
"D_PORT",
"CRT_PHY_ADDR_STR",
"D_LOG_STDERR_IN_LOG",
"D_LOG_SIZE",
"D_LOG_FILE",
"D_LOG_FILE_APPEND_PID",
"D_LOG_MASK",
"DD_MASK",
"DD_STDERR",
"DD_SUBSYS",
"CRT_TIMEOUT",
"CRT_ATTACH_INFO_PATH",
"OFI_PORT",
"OFI_INTERFACE",
"OFI_DOMAIN",
"CRT_CREDIT_EP_CTX",
"CRT_CTX_SHARE_ADDR",
"CRT_CTX_NUM",
"D_FI_CONFIG",
"FI_UNIVERSE_SIZE",
"CRT_ENABLE_MEM_PIN",
"FI_OFI_RXM_USE_SRX",
"D_LOG_FLUSH",
"CRT_MRC_ENABLE",
"CRT_SECONDARY_PROVIDER",
"D_PROVIDER_AUTH_KEY",
"D_PORT_AUTO_ADJUST",
"D_POLL_TIMEOUT",
"D_LOG_FILE_APPEND_RANK",
"D_QUOTA_RPCS",
"D_POST_INIT",
"D_POST_INCR",
"DAOS_SIGNAL_REGISTER"};

static void
crt_lib_init(void) __attribute__((__constructor__));

Expand Down Expand Up @@ -62,52 +100,20 @@ crt_lib_fini(void)
static void
dump_envariables(void)
{
int i;
char *val;
char *envars[] = {"D_PROVIDER",
"D_INTERFACE",
"D_DOMAIN",
"D_PORT",
"CRT_PHY_ADDR_STR",
"D_LOG_STDERR_IN_LOG",
"D_LOG_SIZE",
"D_LOG_FILE",
"D_LOG_FILE_APPEND_PID",
"D_LOG_MASK",
"DD_MASK",
"DD_STDERR",
"DD_SUBSYS",
"CRT_TIMEOUT",
"CRT_ATTACH_INFO_PATH",
"OFI_PORT",
"OFI_INTERFACE",
"OFI_DOMAIN",
"CRT_CREDIT_EP_CTX",
"CRT_CTX_SHARE_ADDR",
"CRT_CTX_NUM",
"D_FI_CONFIG",
"FI_UNIVERSE_SIZE",
"CRT_ENABLE_MEM_PIN",
"FI_OFI_RXM_USE_SRX",
"D_LOG_FLUSH",
"CRT_MRC_ENABLE",
"CRT_SECONDARY_PROVIDER",
"D_PROVIDER_AUTH_KEY",
"D_PORT_AUTO_ADJUST",
"D_POLL_TIMEOUT",
"D_LOG_FILE_APPEND_RANK",
"D_QUOTA_RPCS",
"D_POST_INIT",
"D_POST_INCR",
"DAOS_SIGNAL_REGISTER"};
int i;

D_INFO("-- ENVARS: --\n");
for (i = 0; i < ARRAY_SIZE(envars); i++) {
val = getenv(envars[i]);
if (strcmp(envars[i], "D_PROVIDER_AUTH_KEY") == 0 && val)
D_INFO("%s = %s\n", envars[i], "********");
for (i = 0; i < ARRAY_SIZE(crt_env_names); i++) {
char *val = NULL;

d_agetenv_str(&val, crt_env_names[i]);
if (val == NULL)
continue;
if (strcmp(crt_env_names[i], "D_PROVIDER_AUTH_KEY") == 0)
D_INFO("%s = %s\n", crt_env_names[i], "********");
else
D_INFO("%s = %s\n", envars[i], val);
D_INFO("%s = %s\n", crt_env_names[i], val);
d_freeenv_str(&val);
}
}

Expand Down Expand Up @@ -596,41 +602,40 @@ crt_protocol_info_free(struct crt_protocol_info *protocol_info)
int
crt_init_opt(crt_group_id_t grpid, uint32_t flags, crt_init_options_t *opt)
{
char *provider_env;
char *interface_env;
char *domain_env;
char *auth_key_env;
char *tmp;
struct timeval now;
unsigned int seed;
const char *path;
bool server;
int rc = 0;
char *provider_str0 = NULL;
char *provider_str1 = NULL;
crt_provider_t primary_provider;
crt_provider_t secondary_provider;
crt_provider_t tmp_prov;
char *port_str, *port0, *port1;
char *iface0, *iface1, *domain0, *domain1;
char *auth_key0, *auth_key1;
int num_secondaries = 0;
bool port_auto_adjust = false;
int i;
char *provider;
char *provider_env = NULL;
char *interface;
char *interface_env = NULL;
char *domain;
char *domain_env = NULL;
char *auth_key;
char *auth_key_env = NULL;
struct timeval now;
unsigned int seed;
char *path;
bool server = flags & CRT_FLAG_BIT_SERVER;
int rc = 0;
char *provider_str0 = NULL;
char *provider_str1 = NULL;
crt_provider_t primary_provider;
crt_provider_t secondary_provider;
crt_provider_t tmp_prov;
char *port;
char *port_env = NULL;
char *port0 = NULL;
char *port1 = NULL;
char *iface0 = NULL;
char *iface1 = NULL;
char *domain0 = NULL;
char *domain1 = NULL;
char *auth_key0 = NULL;
char *auth_key1 = NULL;
int num_secondaries = 0;
bool port_auto_adjust = false;
int i;

d_signal_register();

server = flags & CRT_FLAG_BIT_SERVER;
port_str = NULL;
port0 = NULL;
port1 = NULL;
iface0 = NULL;
iface1 = NULL;
domain0 = NULL;
domain1 = NULL;
auth_key0 = NULL;
auth_key1 = NULL;

/* d_log_init is reference counted */
rc = d_log_init();
if (rc != 0) {
Expand Down Expand Up @@ -677,7 +682,7 @@ crt_init_opt(crt_group_id_t grpid, uint32_t flags, crt_init_options_t *opt)
crt_gdata.cg_auto_swim_disable =
(flags & CRT_FLAG_BIT_AUTO_SWIM_DISABLE) ? 1 : 0;

path = getenv("CRT_ATTACH_INFO_PATH");
d_agetenv_str(&path, "CRT_ATTACH_INFO_PATH");
if (path != NULL && strlen(path) > 0) {
rc = crt_group_config_path_set(path);
if (rc != 0)
Expand All @@ -687,76 +692,76 @@ crt_init_opt(crt_group_id_t grpid, uint32_t flags, crt_init_options_t *opt)
else
D_DEBUG(DB_ALL, "set group_config_path as %s.\n", path);
}
d_freeenv_str(&path);

if (opt && opt->cio_auth_key)
auth_key_env = opt->cio_auth_key;
else
auth_key_env = getenv("D_PROVIDER_AUTH_KEY");
auth_key = opt->cio_auth_key;
else {
d_agetenv_str(&auth_key_env, "D_PROVIDER_AUTH_KEY");
auth_key = auth_key_env;
}

if (opt && opt->cio_provider)
provider_env = opt->cio_provider;
provider = opt->cio_provider;
else {
provider_env = getenv(CRT_PHY_ADDR_ENV);

tmp = getenv("D_PROVIDER");
if (tmp)
provider_env = tmp;
d_agetenv_str(&provider_env, "D_PROVIDER");
if (provider_env == NULL)
d_agetenv_str(&provider_env, CRT_PHY_ADDR_ENV);
provider = provider_env;
}

if (opt && opt->cio_interface)
interface_env = opt->cio_interface;
interface = opt->cio_interface;
else {
interface_env = getenv("OFI_INTERFACE");

tmp = getenv("D_INTERFACE");
if (tmp)
interface_env = tmp;
d_agetenv_str(&interface_env, "D_INTERFACE");
if (interface_env == NULL) {
d_agetenv_str(&interface_env, "OFI_INTERFACE");
}
interface = interface_env;
}

if (opt && opt->cio_domain)
domain_env = opt->cio_domain;
domain = opt->cio_domain;
else {
domain_env = getenv("OFI_DOMAIN");

tmp = getenv("D_DOMAIN");
if (tmp)
domain_env = tmp;
d_agetenv_str(&domain_env, "D_DOMAIN");
if (domain_env == NULL)
d_agetenv_str(&domain_env, "OFI_DOMAIN");
domain = domain_env;
}

if (opt && opt->cio_port)
port_str = opt->cio_port;
port = opt->cio_port;
else {
port_str = getenv("OFI_PORT");

tmp = getenv("D_PORT");
if (tmp)
port_str = tmp;
d_agetenv_str(&port_env, "D_PORT");
if (port_env == NULL)
d_agetenv_str(&port_env, "OFI_PORT");
port = port_env;
}

d_getenv_bool("D_PORT_AUTO_ADJUST", &port_auto_adjust);

rc = __split_arg(provider_env, &provider_str0, &provider_str1);
rc = __split_arg(provider, &provider_str0, &provider_str1);
if (rc != 0)
D_GOTO(unlock, rc);

primary_provider = crt_str_to_provider(provider_str0);
secondary_provider = crt_str_to_provider(provider_str1);

if (primary_provider == CRT_PROV_UNKNOWN) {
D_ERROR("Requested provider %s not found\n", provider_env);
D_ERROR("Requested provider %s not found\n", provider);
D_GOTO(unlock, rc = -DER_NONEXIST);
}

rc = __split_arg(interface_env, &iface0, &iface1);
rc = __split_arg(interface, &iface0, &iface1);
if (rc != 0)
D_GOTO(unlock, rc);
rc = __split_arg(domain_env, &domain0, &domain1);
rc = __split_arg(domain, &domain0, &domain1);
if (rc != 0)
D_GOTO(unlock, rc);
rc = __split_arg(port_str, &port0, &port1);
rc = __split_arg(port, &port0, &port1);
if (rc != 0)
D_GOTO(unlock, rc);
rc = __split_arg(auth_key_env, &auth_key0, &auth_key1);
rc = __split_arg(auth_key, &auth_key0, &auth_key1);
if (rc != 0)
D_GOTO(unlock, rc);

Expand Down Expand Up @@ -896,6 +901,11 @@ crt_init_opt(crt_group_id_t grpid, uint32_t flags, crt_init_options_t *opt)
D_FREE(domain0);
D_FREE(provider_str0);
D_FREE(auth_key0);
d_freeenv_str(&port_env);
d_freeenv_str(&domain_env);
d_freeenv_str(&interface_env);
d_freeenv_str(&provider_env);
d_freeenv_str(&auth_key_env);

if (rc != 0) {
D_ERROR("failed, "DF_RC"\n", DP_RC(rc));
Expand Down
Loading

0 comments on commit 91a2784

Please sign in to comment.