Revision 7ea201c9 src/Ganeti/WConfd/ConfigWriter.hs
b/src/Ganeti/WConfd/ConfigWriter.hs | ||
---|---|---|
34 | 34 |
, writeConfig |
35 | 35 |
, saveConfigAsyncTask |
36 | 36 |
, distMCsAsyncTask |
37 |
, distSSConfAsyncTask |
|
37 | 38 |
) where |
38 | 39 |
|
39 | 40 |
import Control.Applicative |
... | ... | |
54 | 55 |
import Ganeti.Utils.AsyncWorker |
55 | 56 |
import Ganeti.WConfd.ConfigState |
56 | 57 |
import Ganeti.WConfd.Monad |
58 |
import Ganeti.WConfd.Ssconf |
|
57 | 59 |
|
58 | 60 |
-- | Loads the configuration from the file, if it hasn't been loaded yet. |
59 | 61 |
-- The function is internal and isn't thread safe. |
... | ... | |
161 | 163 |
cd <- liftBase (csConfigData <$> cdRef) :: ResultG ConfigData |
162 | 164 |
fupload <- prepareRpcCallUploadFile ents cpath |
163 | 165 |
execRpcCallAndLog (getMasterCandidates cd) fupload |
166 |
|
|
167 |
-- | Construct an asynchronous worker whose action is to construct SSConf |
|
168 |
-- and distribute it to master candidates. |
|
169 |
-- The worker's action reads the configuration using the given @IO@ action, |
|
170 |
-- computes the current SSConf, compares it to the previous version, and |
|
171 |
-- if different, distributes it. |
|
172 |
distSSConfAsyncTask |
|
173 |
:: IO ConfigState -- ^ An action to read the current config |
|
174 |
-> ResultG (AsyncWorker ()) |
|
175 |
distSSConfAsyncTask cdRef = |
|
176 |
lift . mkStatefulAsyncTask ERROR "Can't distribute Ssconf" emptySSConf |
|
177 |
$ \oldssc -> do |
|
178 |
cd <- liftBase (csConfigData <$> cdRef) :: ResultG ConfigData |
|
179 |
let ssc = mkSSConf cd |
|
180 |
when (oldssc /= ssc) |
|
181 |
$ execRpcCallAndLog (getOnlineNodes cd) |
|
182 |
(RpcCallWriteSsconfFiles ssc) |
|
183 |
return ssc |
Also available in: Unified diff