ganeti

Safe HaskellSafe-Infered

Ganeti.Confd.Server

Contents

Description

Implementation of the Ganeti confd server functionality.

Synopsis

Types and constants definitions

type FStat = (EpochTime, FileID, FileOffset)Source

data ReloadModel Source

Constructors

ReloadNotify 
ReloadPoll Int 

Instances

data ServerState Source

Constructors

ServerState 

Confd base functionality

Configuration handling

Helper functions

moveToPolling :: String -> INotify -> FilePath -> CRef -> MVar ServerState -> IO ReloadModelSource

Configuration loading

updateConfig :: FilePath -> CRef -> IO ()Source

buildFileStatus :: FileStatus -> FStatSource

getFStat :: FilePath -> IO FStatSource

needsReload :: FStat -> FilePath -> IO (Maybe FStat)Source

Watcher threads

We have three threads/functions that can mutate the server state:

  1. the long-interval watcher (onWatcherTimer)
  2. the polling watcher (onPollTimer)
  3. the inotify event handler (onInotify)

All of these will mutate the server state under modifyMVar or modifyMVar_, so that server transitions are more or less atomic. The inotify handler remains active during polling mode, but checks for polling mode and doesn't do anything in this case (this check is needed even if we would unregister the event handler due to how events are serialised).

onWatcherTimer :: IO Bool -> FilePath -> CRef -> MVar ServerState -> IO ()Source

onPollTimer :: IO Bool -> FilePath -> CRef -> MVar ServerState -> IO ()Source

onPollInner :: IO Bool -> FilePath -> CRef -> ServerState -> IO (ServerState, Bool)Source

addNotifier :: INotify -> FilePath -> CRef -> MVar ServerState -> IO BoolSource

onInotify :: INotify -> String -> CRef -> MVar ServerState -> Event -> IO ()Source

Client input/output handlers

responder :: CRef -> Socket -> HashKey -> String -> SockAddr -> IO ()Source

listener :: Socket -> HashKey -> (Socket -> HashKey -> String -> SockAddr -> IO ()) -> IO ()Source

type PrepResult = (Socket, (FilePath, Socket), IORef (Result (ConfigData, LinkIpMap)))Source

checkMain :: CheckFn (Family, SockAddr)Source

Check function for confd.

prepMain :: PrepFn (Family, SockAddr) PrepResultSource

Prepare function for confd.

main :: MainFn (Family, SockAddr) PrepResultSource

Main function.