From 3190ad64358982b352b37a84d3bac406afa3a906 Mon Sep 17 00:00:00 2001 From: Iustin Pop <iustin@google.com> Date: Wed, 16 Jan 2013 15:28:40 +0100 Subject: [PATCH] Explicitly load the config at confd startup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Currently, confd main function doesn't load the config, but simply forks the individual timer threads, which willβas a side effect-also load the configuration as soon as they start. However, this makes codes to the startup more complex, so let's explicitly (try to) load the configuration as first thing. Signed-off-by: Iustin Pop <iustin@google.com> Reviewed-by: Guido Trotter <ultrotter@google.com> --- src/Ganeti/Confd/Server.hs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/Ganeti/Confd/Server.hs b/src/Ganeti/Confd/Server.hs index dd309897a..29204a4ef 100644 --- a/src/Ganeti/Confd/Server.hs +++ b/src/Ganeti/Confd/Server.hs @@ -6,7 +6,7 @@ {- -Copyright (C) 2011, 2012 Google Inc. +Copyright (C) 2011, 2012, 2013 Google Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -108,10 +108,6 @@ reloadRatelimitSec = fromIntegral C.confdConfigReloadRatelimit initialPoll :: ReloadModel initialPoll = ReloadPoll 0 --- | Initial server state. -initialState :: ServerState -initialState = ServerState initialPoll 0 nullFStat - -- | Reload status data type. data ConfigReload = ConfigToDate -- ^ No need to reload | ConfigReloaded -- ^ Configuration reloaded @@ -526,11 +522,14 @@ prepMain _ (af_family, bindaddr) = do -- | Main function. main :: MainFn (S.Family, S.SockAddr) PrepResult main _ _ (s, query_data, cref) = do - statemvar <- newMVar initialState + -- try to load the configuration, if possible + conf_file <- Path.clusterConfFile + (fstat, _) <- safeUpdateConfig conf_file nullFStat cref + ctime <- getCurrentTime + statemvar <- newMVar $ ServerState initialPoll ctime fstat hmac <- getClusterHmac -- Inotify setup inotify <- initINotify - conf_file <- Path.clusterConfFile let inotiaction = addNotifier inotify conf_file cref statemvar -- fork the timeout timer _ <- forkIO $ onTimeoutTimer inotiaction conf_file cref statemvar -- GitLab