commit cd6445ccab0c3246f71222d67adde29a2854b4e9
Merge: ff3f66b 32230f0
Author: Hrvoje Ribicic <[email protected]>
Date:   Wed May 13 14:15:20 2015 +0000

    Merge branch 'stable-2.14' into stable-2.15

    * stable-2.14
      Fix mismerge by correcting test import

    * stable-2.13
      (no changes)

    * stable-2.12
      Expand orphan volume test
      Restrict Ganeti's orphan volume checks to the single VG
      Modify UDS server startup to set permissions for sockets
      Add wheezy chroot files to gitignore file
      Makefile.am: Don't use -dynamic-too for .hpc_o files
      Makefile.am: Don't use dots in -osuf
      Fix compiler invocation for GHC >= 7.8
      Makefile.am: Fix wrong -dep-suffix for GHC 7.8
      Only upgrade configs not upgraded
      Only unlock config if we did lock it
      Mention preferred DRBD module settings when using Xen
      Avoid assertIn
      Test presence of public and private parameters
      Put private parameters into the environment
      Always close pipe on job forking
      Clean up pipes early on failed forks

diff --cc src/Ganeti/Metad/ConfigServer.hs
index ad8e461,62ea43c..ad32e65
--- a/src/Ganeti/Metad/ConfigServer.hs
+++ b/src/Ganeti/Metad/ConfigServer.hs
@@@ -39,28 -42,74 +39,40 @@@ import Control.Monad.Reade

  import Ganeti.Path as Path
  import Ganeti.Daemon (DaemonOptions, cleanupSocket, describeError)
- import Ganeti.Runtime (GanetiDaemon(..))
 -import qualified Ganeti.Logging as Logging
+ import Ganeti.Runtime (GanetiDaemon(..), GanetiGroup(..), MiscGroup(..))
 -import Ganeti.UDSServer (Client, ConnectConfig(..), Server,
ServerConfig(..))
 +import Ganeti.THH.RPC
 +import Ganeti.UDSServer (ConnectConfig(..), ServerConfig(..))
  import qualified Ganeti.UDSServer as UDSServer
+ import Ganeti.Utils (FilePermissions(..))

 -import Ganeti.Metad.Config as Config
 -import Ganeti.Metad.Types (InstanceParams)
 +import Ganeti.Metad.ConfigCore

 --- | Update the configuration with the received instance parameters.
 -updateConfig :: MVar InstanceParams -> String -> IO ()
 -updateConfig config str =
 -  case decode str of
 -    Error err ->
 -      Logging.logDebug $ show err
 -    Ok x ->
 -      case Config.getInstanceParams x of
 -        Error err ->
 -          Logging.logError $ "Could not get instance parameters: " ++ err
 -        Ok (name, instanceParams) -> do
 -          cfg <- takeMVar config
 -          let cfg' = mergeConfig cfg instanceParams
 -          putMVar config cfg'
 -          Logging.logInfo $
 -            "Updated instance " ++ show name ++ " configuration"
 -          Logging.logDebug $ "Instance configuration: " ++ show cfg'
 +-- * The handler that converts RPCs to calls to the above functions

 --- | Reads messages from clients and update the configuration
 --- according to these messages.
 -acceptConfig :: MVar InstanceParams -> Client -> IO ()
 -acceptConfig config client =
 -  do res <- try $ UDSServer.recvMsg client
 -     case res of
 -       Left err -> do
 -         unless (isEOFError err) .
 -           Logging.logDebug $ show err
 -         return ()
 -       Right str -> do
 -         Logging.logDebug $ "Received: " ++ str
 -         updateConfig config str
 +handler :: RpcServer MetadMonadInt
 +handler = $( mkRpcM exportedFunctions )

 --- | Loop that accepts clients and dispatches them to an isolated
 --- thread that will handle the client's requests.
 -acceptClients :: MVar InstanceParams -> Server -> IO ()
 -acceptClients config server =
 -  do client <- UDSServer.acceptClient server
 -     _ <- forkIO $ acceptConfig config client
 -     acceptClients config server
 +-- * The main server code

 -start :: DaemonOptions -> MVar InstanceParams -> IO ()
 +start :: DaemonOptions -> MetadHandle -> IO ()
  start _ config = do
       socket_path <- Path.defaultMetadSocket
       cleanupSocket socket_path
       server <- describeError "binding to the socket" Nothing (Just
socket_path)
                 $ UDSServer.connectServer metadConfig True socket_path
       finally
 -       (acceptClients config server)
 +       (forever $ runMetadMonadInt (UDSServer.listener handler server)
config)
         (UDSServer.closeServer server)
    where
-     metadConfig = ServerConfig GanetiMetad $ ConnectConfig 60 60
+     metadConfig =
+       ServerConfig
+         -- The permission 0600 is completely acceptable because only the
node
+         -- daemon talks to the metadata daemon, and the node daemon runs
as
+         -- root.
+         FilePermissions { fpOwner = Just GanetiMetad
+                         , fpGroup = Just $ ExtraGroup DaemonsGroup
+                         , fpPermissions = 0o0600
+                         }
+         ConnectConfig { recvTmo = 60
+                       , sendTmo = 60
+                       }
diff --cc src/Ganeti/Utils.hs
index c2d1322,c6ddb0d..7ec9f84
--- a/src/Ganeti/Utils.hs
+++ b/src/Ganeti/Utils.hs
@@@ -131,9 -130,7 +131,8 @@@ import System.I
  import System.Exit
  import System.Posix.Files
  import System.Posix.IO
- import System.Posix.User
 -import System.Time
 +import System.Time (ClockTime(..), getClockTime, TimeDiff(..))
 +import qualified System.Time as STime

  -- * Debug functions


Hrvoje Ribicic
Ganeti Engineering
Google Germany GmbH
Dienerstr. 12, 80331, München

Geschäftsführer: Graham Law, Christine Elizabeth Flores
Registergericht und -nummer: Hamburg, HRB 86891
Sitz der Gesellschaft: Hamburg

Reply via email to