genericQuery filters objects without runtime data first.
We need to filter the objects again, this time with runtime data.

This fixes issue 1100.

Signed-off-by: BSRK Aditya <[email protected]>
---
 src/Ganeti/Query/Query.hs |   10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/Ganeti/Query/Query.hs b/src/Ganeti/Query/Query.hs
index 88928f3..00ec183 100644
--- a/src/Ganeti/Query/Query.hs
+++ b/src/Ganeti/Query/Query.hs
@@ -230,11 +230,13 @@ genericQuery fieldsMap collector nameFn configFn getFn cfg
   -- limit the objects that we'll contact for exports
   fobjects <- toError $
     filterM (\n -> evaluateQueryFilter cfg Nothing n cfilter) objects
-  -- Gather the runtime data
-  runtimes <- case collector of
+  -- Gather the runtime data and filter the results again,
+  -- based on the gathered data
+  runtimes <- (case collector of
     CollectorSimple     collFn -> lift $ collFn live' cfg fobjects
-    CollectorFieldAware collFn -> lift $ collFn live' cfg fields fobjects
-  -- Filter the results again, based on the gathered data
+    CollectorFieldAware collFn -> lift $ collFn live' cfg fields fobjects) >>=
+    (toError . filterM (\(obj, runtime) ->
+      evaluateQueryFilter cfg (Just runtime) obj cfilter))
   let fdata = map (\(obj, runtime) ->
                      map (execGetter cfg runtime obj) fgetters)
               runtimes
-- 
1.7.10.4

Reply via email to