[Pkg-ganeti-devel] [ganeti] 20/165: Add --reason to hbal

Apollon Oikonomopoulos apoikos at moszumanska.debian.org
Tue Aug 11 13:53:09 UTC 2015


This is an automated email from the git hooks/post-receive script.

apoikos pushed a commit to branch master
in repository ganeti.

commit 7d3f947c7e2cb0c78638bae86f4b33c54b186d03
Author: Klaus Aehlig <aehlig at google.com>
Date:   Fri Feb 6 15:27:41 2015 +0100

    Add --reason to hbal
    
    In this way the reason for a balancing action can be documented.
    This is especially useful if automatic balancing is done, e.g.,
    via a cron job.
    
    Signed-off-by: Klaus Aehlig <aehlig at google.com>
    Reviewed-by: Hrvoje Ribicic <riba at google.com>
---
 src/Ganeti/HTools/Program/Hbal.hs | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/src/Ganeti/HTools/Program/Hbal.hs b/src/Ganeti/HTools/Program/Hbal.hs
index f8fa48d..03431ea 100644
--- a/src/Ganeti/HTools/Program/Hbal.hs
+++ b/src/Ganeti/HTools/Program/Hbal.hs
@@ -43,7 +43,7 @@ import Control.Arrow ((&&&))
 import Control.Lens (over)
 import Control.Monad
 import Data.List
-import Data.Maybe (isNothing)
+import Data.Maybe (isNothing, fromMaybe)
 import System.Exit
 import System.IO
 
@@ -86,6 +86,7 @@ options = do
     , luxi
     , oIAllocSrc
     , oExecJobs
+    , oReason
     , oGroup
     , oMaxSolLength
     , oVerbose
@@ -116,10 +117,11 @@ arguments = []
 
 -- | Wraps an 'OpCode' in a 'MetaOpCode' while also adding a comment
 -- about what generated the opcode.
-annotateOpCode :: Timestamp -> Jobs.Annotator
-annotateOpCode ts =
+annotateOpCode :: Maybe String -> Timestamp -> Jobs.Annotator
+annotateOpCode reason ts =
   over (metaParamsL . opReasonL)
-      (++ [("hbal", "hbal " ++ version ++ " called", reasonTrailTimestamp ts)])
+      (++ [( "hbal", fromMaybe ("hbal " ++ version ++ " called") reason
+           , reasonTrailTimestamp ts)])
   . setOpComment ("rebalancing via hbal " ++ version)
   . wrapOpCode
 
@@ -187,7 +189,7 @@ maybeExecJobs opts ord_plc fin_nl il cmd_jobs =
             Just master -> do
               ts <- currentTimestamp
               let annotator = maybe id setOpPriority (optPriority opts) .
-                              annotateOpCode ts
+                              annotateOpCode (optReason opts) ts
               execWithCancel annotator master $
                 zip (map toOpcodes cmd_jobs) (map toDescr cmd_jobs))
     else return $ Ok ()

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ganeti/ganeti.git



More information about the Pkg-ganeti-devel mailing list