Commit c29501f6 authored by Klaus Aehlig's avatar Klaus Aehlig
Browse files

Make getFQDN honor vcluster



Make the official (exported) getFQDN function honor the vcluster
setup. In this way, also Haskell daemons can obtain their name
correctly in a vcluster. In particular, voting will work.
Signed-off-by: default avatarKlaus Aehlig <aehlig@google.com>
Reviewed-by: default avatarPetr Pudlak <pudlak@google.com>
parent 279653b7
...@@ -330,8 +330,9 @@ parseAddress opts defport = do ...@@ -330,8 +330,9 @@ parseAddress opts defport = do
vClusterHostNameEnvVar :: String vClusterHostNameEnvVar :: String
vClusterHostNameEnvVar = "GANETI_HOSTNAME" vClusterHostNameEnvVar = "GANETI_HOSTNAME"
getFQDN :: IO String -- | Get the real full qualified host name.
getFQDN = do getFQDN' :: IO String
getFQDN' = do
hostname <- getHostName hostname <- getHostName
addrInfos <- Socket.getAddrInfo Nothing (Just hostname) Nothing addrInfos <- Socket.getAddrInfo Nothing (Just hostname) Nothing
let address = listToMaybe addrInfos >>= (Just . Socket.addrAddress) let address = listToMaybe addrInfos >>= (Just . Socket.addrAddress)
...@@ -341,17 +342,22 @@ getFQDN = do ...@@ -341,17 +342,22 @@ getFQDN = do
return (fromMaybe hostname fqdn) return (fromMaybe hostname fqdn)
Nothing -> return hostname Nothing -> return hostname
-- | Returns if the current node is the master node. -- | Return the full qualified host name, honoring the vcluster setup.
isMaster :: IO Bool getFQDN :: IO String
isMaster = do getFQDN = do
let ioErrorToNothing :: IOError -> IO (Maybe String) let ioErrorToNothing :: IOError -> IO (Maybe String)
ioErrorToNothing _ = return Nothing ioErrorToNothing _ = return Nothing
vcluster_node <- Control.Exception.catch vcluster_node <- Control.Exception.catch
(liftM Just (getEnv vClusterHostNameEnvVar)) (liftM Just (getEnv vClusterHostNameEnvVar))
ioErrorToNothing ioErrorToNothing
curNode <- case vcluster_node of case vcluster_node of
Just node_name -> return node_name Just node_name -> return node_name
Nothing -> getFQDN Nothing -> getFQDN'
-- | Returns if the current node is the master node.
isMaster :: IO Bool
isMaster = do
curNode <- getFQDN
masterNode <- Ssconf.getMasterNode Nothing masterNode <- Ssconf.getMasterNode Nothing
case masterNode of case masterNode of
Ok n -> return (curNode == n) 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