In particular:

  - make ArHealthy take an optional AutoRepairData; this allows to
    represent the situation where a repair completed successfully, and
    hence there's an associated tag we might want to know about.

  - add an 'arTag' member to AutoRepairData to store the exact tag this
    data was derived from; this allows for easier removal of the tag when
    its associated state is superseded.

  - change the default sort order of AutoRepairResult to reflect the
    precedence used when reading tags from an object (a failure, if
    present, is always the resulting state; a success overrides an
    ENOPERM).

  - (trivial) make AutoRepairStatus and AutoRepairData derive Eq and Show.

Signed-off-by: Dato Simó <[email protected]>
---
 src/Ganeti/HTools/Types.hs | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/src/Ganeti/HTools/Types.hs b/src/Ganeti/HTools/Types.hs
index 735ae5e..c394c6c 100644
--- a/src/Ganeti/HTools/Types.hs
+++ b/src/Ganeti/HTools/Types.hs
@@ -370,9 +370,11 @@ $(THH.declareSADT "AutoRepairType"
 
 -- | The possible auto-repair results.
 $(THH.declareSADT "AutoRepairResult"
-       [ ("ArSuccess", 'C.autoRepairSuccess)
+       -- Order is important here: higher results take precedence when an 
object
+       -- has several result annotations attached.
+       [ ("ArEnoperm", 'C.autoRepairEnoperm)
+       , ("ArSuccess", 'C.autoRepairSuccess)
        , ("ArFailure", 'C.autoRepairFailure)
-       , ("ArEnoperm", 'C.autoRepairEnoperm)
        ])
 
 -- | The possible auto-repair policy for a given instance.
@@ -389,10 +391,11 @@ data AutoRepairSuspendTime = Forever         -- ^ 
Permanently suspended
 
 -- | The possible auto-repair states for any given instance.
 data AutoRepairStatus
-  = ArHealthy                      -- ^ No problems detected with the instance
+  = ArHealthy (Maybe AutoRepairData) -- ^ No problems detected with the 
instance
   | ArNeedsRepair AutoRepairData   -- ^ Instance has problems, no action taken
   | ArPendingRepair AutoRepairData -- ^ Repair jobs ongoing for the instance
   | ArFailedRepair AutoRepairData  -- ^ Some repair jobs for the instance 
failed
+  deriving (Eq, Show)
 
 -- | The data accompanying a repair operation (future, pending, or failed).
 data AutoRepairData = AutoRepairData { arType :: AutoRepairType
@@ -400,4 +403,6 @@ data AutoRepairData = AutoRepairData { arType :: 
AutoRepairType
                                      , arTime :: ClockTime
                                      , arJobs :: [JobId]
                                      , arResult :: Maybe AutoRepairResult
+                                     , arTag :: String
                                      }
+                    deriving (Eq, Show)
-- 
1.8.0.2-x20-1

Reply via email to