Skip to content

Commit 2959423

Browse files
authored
Merge pull request #2388 from jjhursey/topic/v2.x/ras-fqdn-hostname-fix
Fix FQDN hostnames in RAS components
2 parents 1d1b2e7 + 2b1abad commit 2959423

File tree

5 files changed

+43
-20
lines changed

5 files changed

+43
-20
lines changed

orte/mca/ras/gridengine/ras_gridengine_module.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
* Copyright (c) 2004-2005 The Regents of the University of California.
1111
* All rights reserved.
1212
* Copyright (c) 2006-2010 Oracle and/or its affiliates. All rights reserved
13+
* Copyright (c) 2016 IBM Corporation. All rights reserved.
1314
* $COPYRIGHT$
1415
*
1516
* Additional copyrights may follow
@@ -28,6 +29,7 @@
2829
#include <string.h>
2930

3031
#include "opal/util/output.h"
32+
#include "opal/util/net.h"
3133
#include "orte/util/show_help.h"
3234
#include "orte/mca/errmgr/errmgr.h"
3335
#include "orte/runtime/orte_globals.h"
@@ -62,7 +64,7 @@ static int orte_ras_gridengine_allocate(orte_job_t *jdata, opal_list_t *nodelist
6264
{
6365
char *pe_hostfile = getenv("PE_HOSTFILE");
6466
char *job_id = getenv("JOB_ID");
65-
char buf[1024], *tok, *num, *queue, *arch, *ptr;
67+
char buf[1024], *tok, *num, *queue, *arch, *ptr, *tmp;
6668
int rc;
6769
FILE *fp;
6870
orte_node_t *node;
@@ -96,6 +98,12 @@ static int orte_ras_gridengine_allocate(orte_job_t *jdata, opal_list_t *nodelist
9698
queue = strtok_r(NULL, " \n", &tok);
9799
arch = strtok_r(NULL, " \n", &tok);
98100

101+
if( !orte_keep_fqdn_hostnames && !opal_net_isaddr(ptr) ) {
102+
if (NULL != (tmp = strchr(ptr, '.'))) {
103+
*tmp = '\0';
104+
}
105+
}
106+
99107
/* see if we already have this node */
100108
found = false;
101109
for (item = opal_list_get_first(nodelist);

orte/mca/ras/loadleveler/ras_loadleveler_module.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* Copyright (c) 2004-2005 The Regents of the University of California.
1111
* All rights reserved.
1212
* Copyright (c) 2006 Cisco Systems, Inc. All rights reserved.
13-
* Copyright (c) 2010-2011 IBM Corporation. All rights reserved.
13+
* Copyright (c) 2010-2016 IBM Corporation. All rights reserved.
1414
* $COPYRIGHT$
1515
*
1616
* Additional copyrights may follow
@@ -26,6 +26,7 @@
2626

2727
#include "opal/util/argv.h"
2828
#include "opal/util/output.h"
29+
#include "opal/util/net.h"
2930

3031
#include "orte/mca/errmgr/errmgr.h"
3132
#include "orte/runtime/orte_globals.h"
@@ -106,6 +107,7 @@ static int orte_ras_loadleveler_discover(opal_list_t* nodelist)
106107
char *hostname;
107108
char *filename;
108109
char input[LL_FILE_MAX_LINE_LENGTH];
110+
char *ptr;
109111

110112
/* Ignore anything that the user already specified -- we're
111113
getting nodes only from LoadLeveler. */
@@ -125,6 +127,12 @@ static int orte_ras_loadleveler_discover(opal_list_t* nodelist)
125127
/* Iterate through all the nodes and make an entry for each */
126128
while (0 != ll_getline(fp, input)) {
127129
hostname = strdup(input);
130+
if( !orte_keep_fqdn_hostnames && !opal_net_isaddr(hostname) ) {
131+
if (NULL != (ptr = strchr(hostname, '.'))) {
132+
*ptr = '\0';
133+
}
134+
}
135+
128136
OPAL_OUTPUT_VERBOSE((1, orte_ras_base_framework.framework_output,
129137
"%s ras:loadleveler:allocate:discover: got hostname %s",
130138
ORTE_NAME_PRINT(ORTE_PROC_MY_NAME), hostname));

orte/mca/ras/lsf/ras_lsf_module.c

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include <lsf/lsbatch.h>
3232

3333
#include "opal/util/argv.h"
34+
#include "opal/util/net.h"
3435
#include "opal/mca/hwloc/hwloc.h"
3536

3637
#include "orte/mca/rmaps/rmaps_types.h"
@@ -60,31 +61,15 @@ orte_ras_base_module_t orte_ras_lsf_module = {
6061
finalize
6162
};
6263

63-
static char *orte_getline(FILE *fp)
64-
{
65-
char *ret, *buff;
66-
char input[1024];
67-
68-
ret = fgets(input, 1024, fp);
69-
if (NULL != ret) {
70-
input[strlen(input)-1] = '\0'; /* remove newline */
71-
buff = strdup(input);
72-
return buff;
73-
}
74-
75-
return NULL;
76-
}
77-
7864

7965
static int allocate(orte_job_t *jdata, opal_list_t *nodes)
8066
{
8167
char **nodelist;
8268
orte_node_t *node;
8369
int i, num_nodes;
84-
char *affinity_file, *hstname;
85-
bool found;
70+
char *affinity_file;
8671
struct stat buf;
87-
orte_app_context_t *app;
72+
char *ptr;
8873

8974
/* get the list of allocated nodes */
9075
if ((num_nodes = lsb_getalloc(&nodelist)) < 0) {
@@ -96,6 +81,12 @@ static int allocate(orte_job_t *jdata, opal_list_t *nodes)
9681

9782
/* step through the list */
9883
for (i = 0; i < num_nodes; i++) {
84+
if( !orte_keep_fqdn_hostnames && !opal_net_isaddr(nodelist[i]) ) {
85+
if (NULL != (ptr = strchr(nodelist[i], '.'))) {
86+
*ptr = '\0';
87+
}
88+
}
89+
9990
/* is this a repeat of the current node? */
10091
if (NULL != node && 0 == strcmp(nodelist[i], node->name)) {
10192
/* it is a repeat - just bump the slot count */

orte/mca/ras/slurm/ras_slurm_module.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
* Copyright (c) 2013-2014 Intel, Inc. All rights reserved.
1616
* Copyright (c) 2015 Research Organization for Information Science
1717
* and Technology (RIST). All rights reserved.
18+
* Copyright (c) 2016 IBM Corporation. All rights reserved.
1819
* $COPYRIGHT$
1920
*
2021
* Additional copyrights may follow
@@ -405,6 +406,7 @@ static int orte_ras_slurm_discover(char *regexp, char *tasks_per_node,
405406
int *slots;
406407
bool found_range = false;
407408
bool more_to_come = false;
409+
char *ptr;
408410

409411
orig = base = strdup(regexp);
410412
if (NULL == base) {
@@ -568,6 +570,12 @@ static int orte_ras_slurm_discover(char *regexp, char *tasks_per_node,
568570
for (i = 0; NULL != names && NULL != names[i]; ++i) {
569571
orte_node_t *node;
570572

573+
if( !orte_keep_fqdn_hostnames && !opal_net_isaddr(names[i]) ) {
574+
if (NULL != (ptr = strchr(names[i], '.'))) {
575+
*ptr = '\0';
576+
}
577+
}
578+
571579
OPAL_OUTPUT_VERBOSE((1, orte_ras_base_framework.framework_output,
572580
"%s ras:slurm:allocate:discover: adding node %s (%d slot%s)",
573581
ORTE_NAME_PRINT(ORTE_PROC_MY_NAME),

orte/mca/ras/tm/ras_tm_module.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
* All rights reserved.
1212
* Copyright (c) 2006 Cisco Systems, Inc. All rights reserved.
1313
* Copyright (c) 2014 Intel, Inc. All rights reserved.
14+
* Copyright (c) 2016 IBM Corporation. All rights reserved.
1415
* $COPYRIGHT$
1516
*
1617
* Additional copyrights may follow
@@ -27,6 +28,7 @@
2728

2829
#include "orte/util/show_help.h"
2930
#include "opal/util/os_path.h"
31+
#include "opal/util/net.h"
3032

3133
#include "orte/mca/errmgr/errmgr.h"
3234
#include "orte/runtime/orte_globals.h"
@@ -127,6 +129,7 @@ static int discover(opal_list_t* nodelist, char *pbs_jobid)
127129
FILE *fp;
128130
char *hostname, *cppn;
129131
int ppn;
132+
char *ptr;
130133

131134
/* Ignore anything that the user already specified -- we're
132135
getting nodes only from TM. */
@@ -168,6 +171,11 @@ static int discover(opal_list_t* nodelist, char *pbs_jobid)
168171

169172
nodeid=0;
170173
while (NULL != (hostname = tm_getline(fp))) {
174+
if( !orte_keep_fqdn_hostnames && !opal_net_isaddr(hostname) ) {
175+
if (NULL != (ptr = strchr(hostname, '.'))) {
176+
*ptr = '\0';
177+
}
178+
}
171179

172180
OPAL_OUTPUT_VERBOSE((1, orte_ras_base_framework.framework_output,
173181
"%s ras:tm:allocate:discover: got hostname %s",

0 commit comments

Comments
 (0)