diff --git a/NEWS b/NEWS index 91deb23a0a850817ed8edf2f2e705f83905f1ee1..29b0ea90491b97b8e8e2436f7f999467b6f624f9 100644 --- a/NEWS +++ b/NEWS @@ -45,6 +45,8 @@ documents those changes that are of interest to users and admins. later change in the partition's limits. NOTE: Not reported by "scontrol show config" to avoid changing RPCs. It will be reported in SLURM version 1.4. + -- Add support for Hostname and NodeHostname in slurm.conf being fully qualified + domain names (by Vijay Ramasubramanian, University of Maryland). * Changes in SLURM 1.3.3 ======================== diff --git a/doc/man/man5/slurm.conf.5 b/doc/man/man5/slurm.conf.5 index c6713b408dfefb874811336f885a6e79b34ef11b..7ceb2880714aeaee1ca41c834568d5893b85bdbf 100644 --- a/doc/man/man5/slurm.conf.5 +++ b/doc/man/man5/slurm.conf.5 @@ -1,4 +1,5 @@ .TH "slurm.conf" "5" "June 2008" "slurm.conf 1.3" "Slurm configuration file" + .SH "NAME" slurm.conf \- Slurm configuration file .SH "DESCRIPTION" @@ -1257,9 +1258,11 @@ The node configuration specified the following information: \fBNodeName\fR Name that SLURM uses to refer to a node (or base partition for BlueGene systems). -Typically this would be the string that "/bin/hostname \-s" -returns, however it may be an arbitrary string if -\fBNodeHostname\fR is specified. +Typically this would be the string that "/bin/hostname \-s" returns. +It may also be the fully qualified domane name as returned by "/bin/hostname \-f" +(e.g. "foo1.bar.com"), although that may prevent use of hostlist expressions +(the numeric portion in brackets must be at the end of the string). +It may also be an arbitrary string if \fBNodeHostname\fR is specified. If the \fBNodeName\fR is "DEFAULT", the values specified with that record will apply to subsequent node specifications unless explicitly set to other values in that node record or @@ -1272,7 +1275,10 @@ considered adjacent in the computer. .TP \fBNodeHostname\fR -The string that "/bin/hostname \-s" returns. +Typically this would be the string that "/bin/hostname \-s" returns. +It may also be the fully qualified domain name as returned by "/bin/hostname \-f" +(e.g. "foo1.bar.com"), although that may prevent use of hostlist expressions +(the numeric portion in brackets must be at the end of the string). A node range expression can be used to specify a set of nodes. If an expression is used, the number of nodes identified by \fBNodeHostname\fR on a line in the configuration file must diff --git a/src/common/read_config.c b/src/common/read_config.c index ed638c467558c2ca6a28693e4c12710193b81aae..90598831f0302859a92425605b260e1ba173eadb 100644 --- a/src/common/read_config.c +++ b/src/common/read_config.c @@ -3,6 +3,7 @@ ***************************************************************************** * Copyright (C) 2002-2007 The Regents of the University of California. * Copyright (C) 2008 Lawrence Livermore National Security. + * Portions Copyright (C) 2008 Vijay Ramasubramanian. * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). * Written by Morris Jette <jette1@llnl.gov>. * LLNL-CODE-402394. @@ -43,6 +44,7 @@ #include <assert.h> #include <ctype.h> #include <errno.h> +#include <netdb.h> #include <pwd.h> #include <stdio.h> #include <stdlib.h> @@ -67,6 +69,7 @@ #include "src/common/parse_config.h" #include "src/common/parse_time.h" #include "src/common/slurm_selecttype_info.h" +#include "src/common/util-net.h" /* Instantiation of the "extern slurm_ctl_conf_t slurmcltd_conf" * found in slurmctld.h */ @@ -928,6 +931,58 @@ extern char *slurm_conf_get_nodename(const char *node_hostname) return NULL; } +/* + * slurm_conf_get_aliased_nodename - Return the NodeName for the + * complete hostname string returned by gethostname if there is + * such a match, otherwise iterate through any aliases returned + * by get_host_by_name + */ +extern char *slurm_conf_get_aliased_nodename() +{ + char hostname_full[1024]; + int error_code; + char *nodename; + + error_code = gethostname(hostname_full, sizeof(hostname_full)); + /* we shouldn't have any problem here since by the time + * this function has been called, gethostname_short, + * which invokes gethostname, has probably already been called + * successfully, so just return NULL if something weird + * happens at this point + */ + if (error_code) + return NULL; + + nodename = slurm_conf_get_nodename(hostname_full); + /* if the full hostname did not match a nodename */ + if (nodename == NULL) { + /* use get_host_by_name; buffer sizes, semantics, etc. + * copied from slurm_protocol_socket_implementation.c + */ + struct hostent * he = NULL; + char * h_buf[4096]; + int h_err; + + he = get_host_by_name(hostname_full, (void *)&h_buf, + sizeof(h_buf), &h_err); + if (he != NULL) { + unsigned int i = 0; + /* check the "official" host name first */ + nodename = slurm_conf_get_nodename(he->h_name); + while ((nodename == NULL) && + (he->h_aliases[i] != NULL)) { + /* the "official" name still didn't match -- + * iterate through the aliases */ + nodename = + slurm_conf_get_nodename(he->h_aliases[i]); + i++; + } + } + } + + return nodename; +} + /* * slurm_conf_get_port - Return the port for a given NodeName */ diff --git a/src/common/read_config.h b/src/common/read_config.h index a06485ecb6f3dbb6100eea646eb5a03ce6c26eb3..cddc90068df4f3ff9030a6e939b2398279da16d7 100644 --- a/src/common/read_config.h +++ b/src/common/read_config.h @@ -2,7 +2,9 @@ * read_config.h - definitions for reading the overall slurm configuration * file ***************************************************************************** - * Copyright (C) 2002-2006 The Regents of the University of California. + * Copyright (C) 2002-2007 The Regents of the University of California. + * Copyright (C) 2008 Lawrence Livermore National Security. + * Portions Copyright (C) 2008 Vijay Ramasubramanian. * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). * Written by Morris Mette <jette1@llnl.gov>. * LLNL-CODE-402394. @@ -267,6 +269,17 @@ extern char *slurm_conf_get_hostname(const char *node_name); */ extern char *slurm_conf_get_nodename(const char *node_hostname); +/* + * slurm_conf_get_aliased_nodename - Return the NodeName matching an alias + * of the local hostname + * + * Returned string was allocated with xmalloc(), and must be freed by + * the caller using xfree(). + * + * NOTE: Caller must NOT be holding slurm_conf_lock(). + */ +extern char *slurm_conf_get_aliased_nodename(void); + /* * slurm_conf_get_port - Return the port for a given NodeName * diff --git a/src/common/stepd_api.c b/src/common/stepd_api.c index 159a2047f69bc7a789f222ac2ed7f9f02e97c876..88e163cc43aa2fedc26a86b7ea8cfb84e02c1260 100644 --- a/src/common/stepd_api.c +++ b/src/common/stepd_api.c @@ -2,7 +2,9 @@ * src/common/stepd_api.c - slurmstepd message API * $Id$ ***************************************************************************** - * Copyright (C) 2005 The Regents of the University of California. + * Copyright (C) 2005-2007 The Regents of the University of California. + * Copyright (C) 2008 Lawrence Livermore National Security. + * Portions Copyright (C) 2008 Vijay Ramasubramanian * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). * Written by Christopher Morrone <morrone2@llnl.gov> * LLNL-CODE-402394. @@ -169,7 +171,9 @@ _guess_nodename() return NULL; nodename = slurm_conf_get_nodename(host); - if (nodename == NULL) /* no match? lets try localhost */ + if (nodename == NULL) + nodename = slurm_conf_get_aliased_nodename(); + if (nodename == NULL) /* if no match, try localhost */ nodename = slurm_conf_get_nodename("localhost"); return nodename; diff --git a/src/scontrol/scontrol.c b/src/scontrol/scontrol.c index 6ccb4f5a4175f55e1df46192a4935703bec6f1e8..9106ba5164e85ef0d4e81b5498ae631f4ca40573 100644 --- a/src/scontrol/scontrol.c +++ b/src/scontrol/scontrol.c @@ -3,6 +3,8 @@ * provides interface to read, write, update, and configurations. ***************************************************************************** * Copyright (C) 2002-2007 The Regents of the University of California. + * Copyright (C) 2008 Lawrence Livermore National Security. + * Portions Copyright (C) 2008 Vijay Ramasubramanian. * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). * Written by Morris Jette <jette1@llnl.gov> * LLNL-CODE-402394. @@ -419,6 +421,9 @@ _print_daemons (void) if ((n = slurm_conf_get_nodename(me))) { d = 1; xfree(n); + } else if ((n = slurm_conf_get_aliased_nodename())) { + d = 1; + xfree(n); } else if ((n = slurm_conf_get_nodename("localhost"))) { d = 1; xfree(n); diff --git a/src/slurmd/slurmd/slurmd.c b/src/slurmd/slurmd/slurmd.c index f736d5f0a8582bcde30a992565dabc47eaec5f4c..e02697f002dacea393fb0c91fb3860119facf99c 100644 --- a/src/slurmd/slurmd/slurmd.c +++ b/src/slurmd/slurmd/slurmd.c @@ -2,7 +2,9 @@ * src/slurmd/slurmd/slurmd.c - main slurm node server daemon * $Id$ ***************************************************************************** - * Copyright (C) 2002-2006 The Regents of the University of California. + * Copyright (C) 2002-2007 The Regents of the University of California. + * Copyright (C) 2008 Lawrence Livermore National Security. + * Portions Copyright (C) 2008 Vijay Ramasubramanian. * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). * Written by Mark Grondona <mgrondona@llnl.gov>. * LLNL-CODE-402394. @@ -582,6 +584,11 @@ _read_config() /* node_name may already be set from a command line parameter */ if (conf->node_name == NULL) conf->node_name = slurm_conf_get_nodename(conf->hostname); + /* if we didn't match the form of the hostname already + * stored in conf->hostname, check to see if we match any + * valid aliases */ + if (conf->node_name == NULL) + conf->node_name = slurm_conf_get_aliased_nodename(); if (conf->node_name == NULL) conf->node_name = slurm_conf_get_nodename("localhost"); if (conf->node_name == NULL) diff --git a/src/sview/popups.c b/src/sview/popups.c index f48612022787a4381144f1ffc9f96e99258c1c26..89c0aaf261637040b4bbea0307614fc1c250ace2 100644 --- a/src/sview/popups.c +++ b/src/sview/popups.c @@ -1,7 +1,9 @@ /****************************************************************************\ * popups.c - put different popup displays here ***************************************************************************** - * Copyright (C) 2002-2006 The Regents of the University of California. + * Copyright (C) 2002-2007 The Regents of the University of California. + * Copyright (C) 2008 Lawrence Livermore National Security. + * Portions Copyright (C) 2008 Vijay Ramasubramanian * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). * Written by Danny Auble <da@llnl.gov>, et. al. * LLNL-CODE-402394. @@ -627,13 +629,15 @@ extern void create_daemon_popup(GtkAction *action, gpointer user_data) } slurm_conf_unlock(); - if ((n = slurm_conf_get_nodename(me))) { - d = 1; + if ((n = slurm_conf_get_nodename(me))) { + d = 1; + xfree(n); + } else if ((n = slurm_conf_get_aliased_nodename())) { + d = 1; + xfree(n); + } else if ((n = slurm_conf_get_nodename("localhost"))) { + d = 1; xfree(n); - } else if ((n = slurm_conf_get_nodename("localhost"))) { - d = 1; - xfree(n); - } if (actld && ctld) add_display_treestore_line(update, treestore, &iter, "Slurmctld", "1"); diff --git a/src/sview/sview.c b/src/sview/sview.c index f277da115700c57e8f1ffd4c9efedbb67afd5e1b..74979e6ba514ce1f5445df113fc7d7f15a4a9719 100644 --- a/src/sview/sview.c +++ b/src/sview/sview.c @@ -1,7 +1,8 @@ /****************************************************************************\ * sview.c - main for sview ***************************************************************************** - * Copyright (C) 2002-2006 The Regents of the University of California. + * Copyright (C) 2002-2007 The Regents of the University of California. + * Copyright (C) 2008 Lawrence Livermore National Security. * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). * Written by Danny Auble <da@llnl.gov>, et. al. * LLNL-CODE-402394.