+        desiredLocationScore (Instance.dsrdLocTags t) (Node.locationTags p) +
+        Set.size (Node.locationTags p `Set.intersection` Node.locationTags s) }
+  where desiredLocationScore instTags nodeTags
+          | Set.null instTags = 0 -- there are no desired location tags
+          | Set.null ( instTags `Set.intersection` nodeTags ) = 1
+          | otherwise = 0 -- desired location is satisfied

Are you sure that this is a correct way of saying "0 if the location 
requirements are
fullfilled, one otherwise"? To me it seems correct, if there is at most one
desired location for the instance, but what wrong if there are two (like 
specifying
a desired geographic location and a desired machine type in an inhomogeneous
cluster). I would have expected something along the lines of

   | Set.null ( instTags Set.\\ nodeTags) = 0
   | otherwise = 1

Let me explain why I decided to do it this way. I thought that if it doesn't matter where the instance will be placed either on machine a or on a machine b, it's possible to select both locations as desired. In that case if one location desire is satisfied - it's ok and there is no reason for making cluster score bigger.

On the other hand, if we have such contradictive desired locations, one of them will be always unsatisfied. Since we care only about metric changes but not about its absolute value it's ok to add plus one for each unsatisfied desired location as you suggest.

--
Sincerely, Oleg Ponomarev <[email protected]>

Reply via email to