Skip to content

Commit 6efdfa2

Browse files
Ralph CastainScott Miller
authored andcommitted
Detect/warn of illegal node names
If we detect that someone has given us an incorrect node name, provide a helpful message telling them as it is almost certainly a typo. Signed-off-by: Ralph Castain <[email protected]> (cherry picked from commit 3269f2d)
1 parent ce93622 commit 6efdfa2

File tree

2 files changed

+22
-9
lines changed

2 files changed

+22
-9
lines changed

orte/util/help-regex.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
# All rights reserved.
1313
# Copyright (c) 2014 Research Organization for Information Science
1414
# and Technology (RIST). All rights reserved.
15+
# Copyright (c) 2017 Intel, Inc. All rights reserved.
1516
# $COPYRIGHT$
1617
#
1718
# Additional copyrights may follow
@@ -68,3 +69,18 @@ digits in the names:
6869
regexp: %s
6970

7071
Please contact the Open MPI help list for assistance.
72+
#
73+
[regex:invalid-name]
74+
While trying to create a regular expression of the node names
75+
used in this application, the regex parser has detected the
76+
presence of an illegal character in the following node name:
77+
78+
node: %s
79+
80+
Node names must be composed of a combination of ascii letters,
81+
digits, dots, and the hyphen ('-') character. See the following
82+
for an explanation:
83+
84+
https://en.wikipedia.org/wiki/Hostname
85+
86+
Please correct the error and try again.

orte/util/nidmap.c

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ int orte_util_nidmap_create(opal_pointer_array_t *pool, char **regex)
209209
char *node;
210210
char prefix[ORTE_MAX_NODE_PREFIX];
211211
int i, j, n, len, startnum, nodenum, numdigits;
212-
bool found, fullname;
212+
bool found;
213213
char *suffix, *sfx, *nodenames;
214214
orte_regex_node_t *ndreg;
215215
orte_regex_range_t *range, *rng;
@@ -271,7 +271,6 @@ int orte_util_nidmap_create(opal_pointer_array_t *pool, char **regex)
271271
}
272272
node = nptr->name;
273273
/* determine this node's prefix by looking for first digit char */
274-
fullname = false;
275274
len = strlen(node);
276275
startnum = -1;
277276
memset(prefix, 0, ORTE_MAX_NODE_PREFIX);
@@ -289,18 +288,16 @@ int orte_util_nidmap_create(opal_pointer_array_t *pool, char **regex)
289288
}
290289
continue;
291290
}
292-
if ('.' == node[i]) {
293-
/* just use the entire name */
294-
fullname = true;
295-
break;
291+
/* this must be either an alpha, a '.', or '-' */
292+
if (!isalpha(node[i]) && '-' != node[i] && '.' != node[i]) {
293+
orte_show_help("help-regex.txt", "regex:invalid-name", true, node);
294+
return ORTE_ERR_SILENT;
296295
}
297-
/* this is either an alpha or '-' */
298-
assert(isalpha(node[i]) || '-' == node[i]);
299296
if (startnum < 0) {
300297
prefix[j++] = node[i];
301298
}
302299
}
303-
if (fullname || startnum < 0) {
300+
if (startnum < 0) {
304301
/* can't compress this name - just add it to the list */
305302
ndreg = OBJ_NEW(orte_regex_node_t);
306303
ndreg->prefix = strdup(node);

0 commit comments

Comments
 (0)