Cleanup a node's peer map when possible
authorIustin Pop <iustin@google.com>
Fri, 16 Jul 2010 20:20:17 +0000 (22:20 +0200)
committerIustin Pop <iustin@google.com>
Sun, 18 Jul 2010 21:13:34 +0000 (23:13 +0200)
If the last secondary instance of a peer is deleted (detected by the new
peer memory value being equal to zero), then the pair (pdx, 0) should be
deleted completely. This is not optimization per se, but rather cleanup
(the speedup is at most a percent, and only in some corner cases).

Ganeti/HTools/Node.hs

index ffdad4e..3452ee1 100644 (file)
@@ -322,7 +322,9 @@ removeSec t inst =
         old_peers = peers t
         old_peem = P.find pnode old_peers
         new_peem =  old_peem - Instance.mem inst
-        new_peers = P.add pnode new_peem old_peers
+        new_peers = if new_peem > 0
+                    then P.add pnode new_peem old_peers
+                    else P.remove pnode old_peers
         old_rmem = rMem t
         new_rmem = if old_peem < old_rmem
                    then old_rmem