Skip to content

Commit

Permalink
Merge pull request #1182 from rhc54/topic/rawname
Browse files Browse the repository at this point in the history
Cleanup handling of allocated node names
  • Loading branch information
rhc54 authored Jan 28, 2022
2 parents 0923d16 + 2482abb commit 900b67a
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 14 deletions.
8 changes: 4 additions & 4 deletions src/mca/plm/base/plm_base_launch_support.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* Copyright (c) 2014-2019 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* Copyright (c) 2016-2020 IBM Corporation. All rights reserved.
* Copyright (c) 2021 Nanook Consulting. All rights reserved.
* Copyright (c) 2021-2022 Nanook Consulting. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
Expand Down Expand Up @@ -2340,11 +2340,11 @@ int prte_plm_base_setup_virtual_machine(prte_job_t *jdata)
PRTE_OUTPUT_VERBOSE((5, prte_plm_base_framework.framework_output, "%s checking node %s",
PRTE_NAME_PRINT(PRTE_PROC_MY_NAME), nptr->name));
for (i = 0; i < prte_node_pool->size; i++) {
if (NULL
== (node = (prte_node_t *) prte_pointer_array_get_item(prte_node_pool, i))) {
node = (prte_node_t *) prte_pointer_array_get_item(prte_node_pool, i);
if (NULL == node) {
continue;
}
if (0 != strcmp(node->name, nptr->name)) {
if (!prte_nptr_match(node, nptr)) {
continue;
}
/* have a match - now see if we want this node */
Expand Down
15 changes: 10 additions & 5 deletions src/mca/plm/ssh/plm_ssh_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* Copyright (c) 2014-2020 Intel, Inc. All rights reserved.
* Copyright (c) 2015-2019 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* Copyright (c) 2021 Nanook Consulting. All rights reserved.
* Copyright (c) 2021-2022 Nanook Consulting. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
Expand Down Expand Up @@ -998,7 +998,7 @@ static void launch_daemons(int fd, short args, void *cbdata)
prte_state_caddy_t *state = (prte_state_caddy_t *) cbdata;
prte_plm_ssh_caddy_t *caddy;
prte_list_t coll;
char *username;
char *username, *nname;
int port, *portptr;
prte_namelist_t *child;

Expand Down Expand Up @@ -1117,7 +1117,7 @@ static void launch_daemons(int fd, short args, void *cbdata)
* prefer to find some other node so we can tell what the remote
* shell is, if necessary
*/
if (0 != strcmp(node->name, prte_process_info.nodename)) {
if (!prte_check_host_is_local(node->name)) {
break;
}
}
Expand Down Expand Up @@ -1190,13 +1190,18 @@ static void launch_daemons(int fd, short args, void *cbdata)

/* setup node name */
free(argv[node_name_index1]);
if (NULL == node->rawname) {
nname = node->name;
} else {
nname = node->rawname;
}
username = NULL;
if (prte_get_attribute(&node->attributes, PRTE_NODE_USERNAME, (void **) &username,
PMIX_STRING)) {
prte_asprintf(&argv[node_name_index1], "%s@%s", username, node->name);
prte_asprintf(&argv[node_name_index1], "%s@%s", username, nname);
free(username);
} else {
argv[node_name_index1] = strdup(node->name);
argv[node_name_index1] = strdup(nname);
}

/* pass the vpid */
Expand Down
3 changes: 2 additions & 1 deletion src/mca/ras/base/ras_base_allocate.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* Copyright (c) 2018 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* Copyright (c) 2020 Cisco Systems, Inc. All rights reserved
* Copyright (c) 2021 Nanook Consulting. All rights reserved.
* Copyright (c) 2021-2022 Nanook Consulting. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
Expand Down Expand Up @@ -282,6 +282,7 @@ void prte_ras_base_allocate(int fd, short args, void *cbdata)
PRTE_LIST_FOREACH(node, &nodes, prte_node_t) {
if (!prte_net_isaddr(node->name) &&
NULL != (ptr = strchr(node->name, '.'))) {
node->rawname = strdup(node->name);
if (prte_keep_fqdn_hostnames) {
/* retain the non-fqdn name as an alias */
*ptr = '\0';
Expand Down
8 changes: 7 additions & 1 deletion src/mca/ras/base/ras_base_node.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* Copyright (c) 2015-2018 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* Copyright (c) 2020 Cisco Systems, Inc. All rights reserved
* Copyright (c) 2021 Nanook Consulting. All rights reserved.
* Copyright (c) 2021-2022 Nanook Consulting. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
Expand Down Expand Up @@ -149,6 +149,12 @@ int prte_ras_base_node_insert(prte_list_t *nodes, prte_job_t *jdata)
}
/* if the node name is different, store it as an alias */
prte_argv_append_unique_nosize(&hnp_node->aliases, node->name);
if (NULL != node->rawname) {
if (NULL != hnp_node->rawname) {
free(hnp_node->rawname);
}
hnp_node->rawname = strdup(node->rawname);
}
/* don't keep duplicate copy */
PRTE_RELEASE(node);
/* create copies, if required */
Expand Down
7 changes: 6 additions & 1 deletion src/runtime/prte_globals.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* Copyright (c) 2014-2019 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* Copyright (c) 2017-2020 IBM Corporation. All rights reserved.
* Copyright (c) 2021 Nanook Consulting. All rights reserved.
* Copyright (c) 2021-2022 Nanook Consulting. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
Expand Down Expand Up @@ -589,6 +589,7 @@ static void prte_node_construct(prte_node_t *node)
{
node->index = -1;
node->name = NULL;
node->rawname = NULL;
node->aliases = NULL;
node->daemon = NULL;

Expand Down Expand Up @@ -618,6 +619,10 @@ static void prte_node_destruct(prte_node_t *node)
free(node->name);
node->name = NULL;
}
if (NULL != node->rawname) {
free(node->rawname);
node->rawname = NULL;
}
if (NULL != node->aliases) {
prte_argv_free(node->aliases);
node->aliases = NULL;
Expand Down
1 change: 1 addition & 0 deletions src/runtime/prte_globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ typedef struct {
int32_t index;
/** String node name */
char *name;
char *rawname; // name originally given in allocation, if different from name
/** aliases */
char **aliases;
/* daemon on this node */
Expand Down
1 change: 1 addition & 0 deletions src/runtime/prte_progress_threads.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "src/event/event-internal.h"
#include "src/runtime/prte_globals.h"
#include "src/threads/threads.h"
#include "src/util/argv.h"
#include "src/util/error.h"
#include "src/util/fd.h"

Expand Down
19 changes: 18 additions & 1 deletion src/util/dash_host/dash_host.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* Copyright (c) 2015 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* Copyright (c) 2016 IBM Corporation. All rights reserved.
* Copyright (c) 2021 Nanook Consulting. All rights reserved.
* Copyright (c) 2021-2022 Nanook Consulting. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
Expand Down Expand Up @@ -116,6 +116,7 @@ int prte_util_add_dash_host_nodes(prte_list_t *nodes, char *hosts, bool allocati
bool slots_given;
char *cptr;
char *shortname;
char *rawname;

PRTE_OUTPUT_VERBOSE((1, prte_ras_base_framework.framework_output,
"%s dashhost: parsing args %s", PRTE_NAME_PRINT(PRTE_PROC_MY_NAME),
Expand Down Expand Up @@ -268,6 +269,7 @@ int prte_util_add_dash_host_nodes(prte_list_t *nodes, char *hosts, bool allocati

/* check for local name and compute non-fqdn name */
shortname = NULL;
rawname = NULL;
if (prte_check_host_is_local(mini_map[i])) {
ndname = prte_process_info.nodename;
} else {
Expand All @@ -277,6 +279,7 @@ int prte_util_add_dash_host_nodes(prte_list_t *nodes, char *hosts, bool allocati
!prte_net_isaddr(ndname)) {
cptr = strchr(ndname, '.');
if (NULL != cptr) {
rawname = strdup(ndname);
*cptr = '\0';
shortname = strdup(ndname);
*cptr = '.';
Expand Down Expand Up @@ -306,6 +309,10 @@ int prte_util_add_dash_host_nodes(prte_list_t *nodes, char *hosts, bool allocati
free(shortname);
shortname = NULL;
}
if (NULL != rawname) {
node->rawname = rawname;
rawname = NULL;
}
} else {
/* if we didn't find it, add it to the list */
node = PRTE_NEW(prte_node_t);
Expand All @@ -314,13 +321,20 @@ int prte_util_add_dash_host_nodes(prte_list_t *nodes, char *hosts, bool allocati
if (NULL != shortname) {
free(shortname);
}
if (NULL != rawname) {
free(rawname);
}
return PRTE_ERR_OUT_OF_RESOURCE;
}
if (prte_keep_fqdn_hostnames || NULL == shortname) {
node->name = strdup(ndname);
} else {
node->name = strdup(shortname);
}
if (NULL != rawname) {
node->rawname = rawname;
rawname = NULL;
}
PRTE_OUTPUT_VERBOSE((1, prte_ras_base_framework.framework_output,
"%s dashhost: added node %s to list - slots %d",
PRTE_NAME_PRINT(PRTE_PROC_MY_NAME), node->name, slots));
Expand Down Expand Up @@ -350,6 +364,9 @@ int prte_util_add_dash_host_nodes(prte_list_t *nodes, char *hosts, bool allocati
if (NULL != shortname) {
free(shortname);
}
if (NULL != rawname) {
free(rawname);
}
}
prte_argv_free(mini_map);

Expand Down
6 changes: 5 additions & 1 deletion src/util/hostfile/hostfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* Copyright (c) 2015-2018 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* Copyright (c) 2016 IBM Corporation. All rights reserved.
* Copyright (c) 2021 Nanook Consulting. All rights reserved.
* Copyright (c) 2021-2022 Nanook Consulting. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
Expand Down Expand Up @@ -180,6 +180,7 @@ static int hostfile_parse_line(int token, prte_list_t *updates, prte_list_t *exc
node->name = strdup(node_name);
} else {
node->name = strdup(alias);
node->rawname = strdup(node_name);
}
if (NULL != username) {
prte_set_attribute(&node->attributes, PRTE_NODE_USERNAME, PRTE_ATTR_LOCAL,
Expand Down Expand Up @@ -223,6 +224,7 @@ static int hostfile_parse_line(int token, prte_list_t *updates, prte_list_t *exc
node->name = strdup(node_name);
} else {
node->name = strdup(alias);
node->rawname = strdup(node_name);
}
node->slots = 1;
if (NULL != username) {
Expand Down Expand Up @@ -266,6 +268,7 @@ static int hostfile_parse_line(int token, prte_list_t *updates, prte_list_t *exc
node->name = strdup(prte_util_hostfile_value.sval);
} else {
node->name = strdup(alias);
node->rawname = strdup(prte_util_hostfile_value.sval);
}
if (NULL != alias && 0 != strcmp(alias, node->name)) {
// new node object, so alias must be unique
Expand Down Expand Up @@ -339,6 +342,7 @@ static int hostfile_parse_line(int token, prte_list_t *updates, prte_list_t *exc
if (NULL != alias) {
prte_argv_append_unique_nosize(&node->aliases, alias);
free(alias);
node->rawname = strdup(node_name);
}
PRTE_OUTPUT_VERBOSE((1, prte_ras_base_framework.framework_output,
"%s hostfile: node %s slots %d nodes-given %s",
Expand Down

0 comments on commit 900b67a

Please sign in to comment.