LGTM, thanks On Wed, 19 Aug 2015 at 11:37 'Hrvoje Ribicic' via ganeti-devel < [email protected]> wrote:
> Unlike the Python-side query logic still used for more detailed > queries, the Haskell queries neglected to take into account the > user-shutdown cluster-level parameter, turning USER_DOWN reporting on > by default. This is especially bad considering that this parameter was > introduced to give time to users to adapt their automation to take the > new statuses into account. This patch makes the parameter usable, > albeit possibly too late. > > Signed-off-by: Hrvoje Ribicic <[email protected]> > --- > src/Ganeti/Query/Instance.hs | 20 +++++++++++++------- > 1 file changed, 13 insertions(+), 7 deletions(-) > > diff --git a/src/Ganeti/Query/Instance.hs b/src/Ganeti/Query/Instance.hs > index d4feb03..132b31b 100644 > --- a/src/Ganeti/Query/Instance.hs > +++ b/src/Ganeti/Query/Instance.hs > @@ -693,6 +693,10 @@ isPrimaryOffline cfg inst = > Ok pNode -> nodeOffline pNode > Bad _ -> error "Programmer error - result assumed to be OK is > Bad!" > > +-- | Determines if user shutdown reporting is enabled > +userShutdownEnabled :: ConfigData -> Bool > +userShutdownEnabled = clusterEnabledUserShutdown . configCluster > + > -- | Determines the status of a live instance > liveInstanceStatus :: ConfigData > -> (InstanceInfo, Bool) > @@ -716,18 +720,20 @@ liveInstanceStatus cfg (instInfo, foundOnPrimary) > inst > fromContainer $ getFilledInstHvParams (C.toList C.hvcGlobals) > cfg inst > > allowDown = > - instHypervisor inst /= Kvm || > - (Map.member C.hvKvmUserShutdown hvparams && > - hvparams Map.! C.hvKvmUserShutdown == J.JSBool True) > + userShutdownEnabled cfg && > + (instHypervisor inst /= Kvm || > + (Map.member C.hvKvmUserShutdown hvparams && > + hvparams Map.! C.hvKvmUserShutdown == J.JSBool True)) > > -- | Determines the status of a dead instance. > -deadInstanceStatus :: Instance -> InstanceStatus > -deadInstanceStatus inst = > +deadInstanceStatus :: ConfigData -> Instance -> InstanceStatus > +deadInstanceStatus cfg inst = > case instAdminState inst of > AdminUp -> ErrorDown > - AdminDown | instAdminStateSource inst == UserSource -> UserDown > + AdminDown | wasCleanedUp && userShutdownEnabled cfg -> UserDown > | otherwise -> StatusDown > AdminOffline -> StatusOffline > + where wasCleanedUp = instAdminStateSource inst == UserSource > > -- | Determines the status of the instance, depending on whether it is > possible > -- to communicate with its primary node, on which node it is, and its > @@ -741,7 +747,7 @@ determineInstanceStatus cfg res inst > | otherwise = case res of > Left _ -> NodeDown > Right (Just liveData, _) -> liveInstanceStatus cfg liveData inst > - Right (Nothing, _) -> deadInstanceStatus inst > + Right (Nothing, _) -> deadInstanceStatus cfg inst > > -- | Extracts the instance status, retrieving it using the functions > above and > -- transforming it into a 'ResultEntry'. > -- > 2.5.0.276.gf5e568e > > -- Helga Velroyen Software Engineer [email protected] Google Germany GmbH Dienerstraße 12 80331 München Geschäftsführer: Graham Law, Christine Elizabeth Flores Registergericht und -nummer: Hamburg, HRB 86891 Sitz der Gesellschaft: Hamburg Diese E-Mail ist vertraulich. Wenn Sie nicht der richtige Adressat sind, leiten Sie diese bitte nicht weiter, informieren Sie den Absender und löschen Sie die E-Mail und alle Anhänge. Vielen Dank. This e-mail is confidential. If you are not the right addressee please do not forward it, please inform the sender, and please erase this e-mail including any attachments. Thanks.
