Skip to content

orte/nidmap: correctly handle '-' as a valid hostname character #4627

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

Merged
merged 1 commit into from
Dec 19, 2017

Conversation

ggouaillardet
Copy link
Contributor

'-' is not an alpha character nor a digit, but it is a valid hostname
character and should be handled as an alpha character, otherwise, nodes
such as node-001 do not get "compressed" in the regex.

Refs #4621

Signed-off-by: Gilles Gouaillardet [email protected]

'-' is not an alpha character nor a digit, but it is a valid hostname
character and should be handled as an alpha character, otherwise, nodes
such as node-001 do not get "compressed" in the regex.

Refs open-mpi#4621

Signed-off-by: Gilles Gouaillardet <[email protected]>
rhc54
rhc54 previously requested changes Dec 15, 2017
break;
}
/* this is either an alpha or '-' */
assert(isalpha(node[i]) || '-' == node[i]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something doesn't look right here - why would you want to assert if the character is illegal? I should think we wouldn't want the daemon to simply crash. Let's instead do a show_help reporting the unsupported name and return an error code.

@@ -296,6 +289,13 @@ int orte_util_nidmap_create(opal_pointer_array_t *pool, char **regex)
}
continue;
}
if ('.' == node[i]) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure I understand why a dot character mandates use of the entire name - could you add a comment to explain that option?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well, i did not fully understand the initial logic, so i just preserved it.
the initial test was

if (!isalpha(node[i]) && !isdigit(node[i])) {
    fullname=true;
    break;
}

because node is a valid hostname, node[i] is either

  • an alpha
  • a digit
  • the - character
  • the . character

i honestly do not see any reason why . should not be treated as a digit, so that means fullname is always false and hence i can remove some dead code. do you remember the rationale for the fullname test ?

at that stage, node should always be a valid hostname, so i did not feel the need to validate it (and hence the assert()). that being said, this is not a strong opinion, and i am fine

  • checking node is a valid hostname and error otherwise
  • remove the dead code

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC, the rationale was that I didn't want to assume validity. The user can input a hostname in either a hostfile or a -host option, and we never check it for validity. Thus, the characters could be anything.

I suppose a better option would be to add a validity check in the hostfile and -host parsers, and then have a show_help and error out if a name fails. We could cite https://en.wikipedia.org/wiki/Hostname to explain the error.

Then I'd be comfortable just taking out the assert and assuming validity here, and the need for fullname goes away. Make sense?

@rhc54 rhc54 dismissed their stale review December 19, 2017 17:09

Let's go ahead and take this for now - I can look at the hostfile parser and upgrade it

@rhc54 rhc54 merged commit ccc2fcd into open-mpi:master Dec 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants