How Condor determines a node’s IP and hostname

Most direct way to find out what is happening is to use,

$ env _CONDOR_TOOL_DEBUG=D_HOSTNAME condor_config_val -debug FULL_HOSTNAME

(or if you’re running a version before 7.4.4 or 7.5.4, where -debug was fixed (#1541) for condor_config_val, use condor_status -debug -total)

You will get some output similar to,

$ _CONDOR_ALL_DEBUG=D_HOSTNAME condor_config_val -debug -dump | grep -e ^HOSTNAME -e ^FULL_HOSTNAME -e ^IP_ADDRESS
07/28 13:48:44 Finding local host information, calling gethostname()
07/28 13:48:44 gethostname() returned a host with no domain "eeyore"
07/28 13:48:44 Trying to find full hostname and IP addr for "eeyore"
07/28 13:48:44 Calling gethostbyname(eeyore)
07/28 13:48:44 Found IP addr in hostent:
07/28 13:48:44 Trying to find full hostname from hostent
07/28 13:48:44 Main name in hostent "eeyore" contains no '.', checking aliases
07/28 13:48:44 Checking alias "localhost.localdomain"
07/28 13:48:44 Alias "localhost.localdomain" is fully qualified
07/28 13:48:44 Trying to initialize local IP address (config file not read)
07/28 13:48:44 Already found IP with gethostbyname()
07/28 13:48:44 Trying to initialize local IP address (after reading config)
07/28 13:48:44 NETWORK_INTERFACE not in config file, using existing value
FULL_HOSTNAME = localhost.localdomain
HOSTNAME = eeyore

That is from my laptop, whose IP changes with the time of day and weather, and whose non-fully qualified name is listed in /etc/hosts.

Condor is doing its best to find a FQDN and associated IP. The heuristic used to identify a FQDN is presence of a period (.). Condor starts by calling gethostname(), you can run hostname. If that returns a FQDN, gethostbyname() is called, you can run hostname -i, to find the IP and done. If a non-FQDN is returned, all the IPs associated with the name are scanned looking for what is most likely a public IP. The heuristic prefers non-private over private over, where private are 10/8, 172.16/12, or 192.168/16. Once an IP is selected, the primary name and aliases for the IP are scanned for a FQDN, you can run getent hosts $(hostname), and done.

Experimenting with various configurations, the best advice is to setup a system so hostname returns a fully qualified name, and do not bother changing /etc/hosts.

eeyore (none) eeyore eeyore (OOPS!)
eeyore eeyore eeyore localhost.localdomain
eeyore.local (none) eeyore eeyore.local
eeyore.local eeyore eeyore eeyore.local
eeyore.local eeyore.local eeyore eeyore.local

Tags: , ,

2 Responses to “How Condor determines a node’s IP and hostname”

  1. Jasan Says:

    According to hostname(1) man page, the hostname on Linux should be set to a simple name (non-FQDN, i.e. name without dots) which then gets translated into FQDN by resorver(3). By default resolver looks it up in /etc/hosts before asking DNS (order may be changed /etc/hosts.conf).

    I understand that it is advantageous for you to not set any alias in /etc/hosts and use the undocumented feature of magical-IP-address-association on Condor, but I would not recommend it and would call it “misfunction”.

    The Fedora/RHEL problem is more general, as Anaconda installer sets the hostname to FQDN on newly installed systems – which is wrong and the developers may get wrong impressions out of this.

    After updating your IP address by DHCP, to add correct /etc/hosts entry
    and delete the old one first, you can use following

    sed -i “/$HOSTNAME/d” /etc/hosts && >> /etc/hosts

    cat > <<EOF

    DEV=\`ip -4 route show default | cut -d" " -f5\`
    IP4=\`ip -4 address show dev \$DEV | grep inet | tr \ / | cut -d/ -f6\`
    FQDN=\`hostname -f\`

    echo -e "\$IP4\t\$FQDN\t\${FQDN%%.*}"

    • Jasan Says:

      One space is missing between backslash and slash character of the tr command (or change it for ‘tr ” ” /’).

      Any improvements to this script are welcome.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: