Commit ecff332f authored by Thomas Thrainer's avatar Thomas Thrainer
Browse files

Use FQDN to check master node status



The master node name in SS conf is stored as FQDN, so also use the FQDN
on each node to check if it is the master node.

This fixes issue 551.
Signed-off-by: default avatarThomas Thrainer <thomasth@google.com>
Reviewed-by: default avatarGuido Trotter <ultrotter@google.com>
parent 0c072225
......@@ -47,7 +47,7 @@ module Ganeti.Daemon
import Control.Exception
import Control.Monad
import Data.Maybe (fromMaybe)
import Data.Maybe (fromMaybe, listToMaybe)
import Data.Word
import GHC.IO.Handle (hDuplicateTo)
import Network.BSD (getHostName)
......@@ -297,6 +297,17 @@ parseAddress opts defport = do
vClusterHostNameEnvVar :: String
vClusterHostNameEnvVar = "GANETI_HOSTNAME"
getFQDN :: IO String
getFQDN = do
hostname <- getHostName
addrInfos <- Socket.getAddrInfo Nothing (Just hostname) Nothing
let address = listToMaybe addrInfos >>= (Just . Socket.addrAddress)
case address of
Just a -> do
fqdn <- liftM fst $ Socket.getNameInfo [] True False a
return (fromMaybe hostname fqdn)
Nothing -> return hostname
-- | Returns if the current node is the master node.
isMaster :: IO Bool
isMaster = do
......@@ -307,7 +318,7 @@ isMaster = do
ioErrorToNothing
curNode <- case vcluster_node of
Just node_name -> return node_name
Nothing -> getHostName
Nothing -> getFQDN
masterNode <- Ssconf.getMasterNode Nothing
case masterNode of
Ok n -> return (curNode == n)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment