On Wed, Jun 25, 2014 at 11:23 AM, 'Klaus Aehlig' via ganeti-devel < [email protected]> wrote:
> If this option is given, relax the check for a previous > not N+1 happy cluster to ignore the affected group, but > still consider allocations in other groups. > > Signed-off-by: Klaus Aehlig <[email protected]> > --- > src/Ganeti/HTools/Program/Hspace.hs | 13 +++++++++++-- > 1 file changed, 11 insertions(+), 2 deletions(-) > > diff --git a/src/Ganeti/HTools/Program/Hspace.hs > b/src/Ganeti/HTools/Program/Hspace.hs > index b02a8cc..1620b6d 100644 > --- a/src/Ganeti/HTools/Program/Hspace.hs > +++ b/src/Ganeti/HTools/Program/Hspace.hs > @@ -32,6 +32,7 @@ module Ganeti.HTools.Program.Hspace > import Control.Monad > import Data.Char (toUpper, toLower) > import Data.Function (on) > +import qualified Data.IntMap as IntMap > import Data.List > import Data.Maybe (fromMaybe) > import Data.Ord (comparing) > @@ -41,6 +42,7 @@ import Text.Printf (printf, hPrintf) > > import qualified Ganeti.HTools.Container as Container > import qualified Ganeti.HTools.Cluster as Cluster > +import qualified Ganeti.HTools.Group as Group > import qualified Ganeti.HTools.Node as Node > import qualified Ganeti.HTools.Instance as Instance > > @@ -67,6 +69,7 @@ options = do > , oIAllocSrc > , oVerbose > , oQuiet > + , oIndependentGrps > , oOfflineNode > , oMachineReadable > , oMaxCpu > @@ -447,6 +450,7 @@ main opts args = do > > let verbose = optVerbose opts > machine_r = optMachineReadable opts > + independent_grps = optIndependentGrps opts > > orig_cdata@(ClusterData gl fixed_nl il _ ipol) <- loadExternalData opts > nl <- setNodeStatus opts fixed_nl > @@ -477,7 +481,12 @@ main opts args = do > printCluster machine_r (Cluster.totalResources nl) (length all_nodes) > (Node.haveExclStorage nl) > > - let stop_allocation = case Cluster.computeBadItems nl il of > + let (bad_items, _) = Cluster.computeBadItems nl il > Optional nitpick: s/bad_items/bad_nodes/ > + gl' = foldl (flip $ IntMap.adjust Group.setUnallocable) gl > + $ map Node.group bad_items > + grps_remaining = any Group.isAllocable $ IntMap.elems gl' > + stop_allocation = case Cluster.computeBadItems nl il of > As the bad items have already been computed earlier, can't you just use bad_items / bad_nodes here? This also eliminates the tuple matching in the second case. > + _ | independent_grps && grps_remaining -> > Nothing > ([], _) -> Nothing > _ -> Just ([(FailN1, 1)]::FailStats, nl, il, > [], []) > alloclimit = if optMaxLength opts == -1 > @@ -485,7 +494,7 @@ main opts args = do > else Just (optMaxLength opts) > > allocnodes <- exitIfBad "failure during allocation" $ > - Cluster.genAllocNodes gl nl req_nodes True > + Cluster.genAllocNodes gl' nl req_nodes True > > when (verbose > 3) > . hPrintf stderr "Allocatable nodes: %s\n" $ show allocnodes > -- > 2.0.0.526.g5318336 > >
