Revision 44485f49 lib/cmdlib.py
b/lib/cmdlib.py | ||
---|---|---|
670 | 670 |
return _BuildInstanceHookEnv(**args) |
671 | 671 |
|
672 | 672 |
|
673 |
def _AdjustCandidatePool(lu): |
|
673 |
def _AdjustCandidatePool(lu, exceptions):
|
|
674 | 674 |
"""Adjust the candidate pool after node operations. |
675 | 675 |
|
676 | 676 |
""" |
677 |
mod_list = lu.cfg.MaintainCandidatePool() |
|
677 |
mod_list = lu.cfg.MaintainCandidatePool(exceptions)
|
|
678 | 678 |
if mod_list: |
679 | 679 |
lu.LogInfo("Promoted nodes to master candidate role: %s", |
680 | 680 |
", ".join(node.name for node in mod_list)) |
681 | 681 |
for name in mod_list: |
682 | 682 |
lu.context.ReaddNode(name) |
683 |
mc_now, mc_max, _ = lu.cfg.GetMasterCandidateStats() |
|
683 |
mc_now, mc_max, _ = lu.cfg.GetMasterCandidateStats(exceptions)
|
|
684 | 684 |
if mc_now > mc_max: |
685 | 685 |
lu.LogInfo("Note: more nodes are candidates (%d) than desired (%d)" % |
686 | 686 |
(mc_now, mc_max)) |
... | ... | |
1946 | 1946 |
if self.op.candidate_pool_size is not None: |
1947 | 1947 |
self.cluster.candidate_pool_size = self.op.candidate_pool_size |
1948 | 1948 |
# we need to update the pool size here, otherwise the save will fail |
1949 |
_AdjustCandidatePool(self) |
|
1949 |
_AdjustCandidatePool(self, [])
|
|
1950 | 1950 |
|
1951 | 1951 |
self.cfg.Update(self.cluster) |
1952 | 1952 |
|
... | ... | |
2282 | 2282 |
logging.info("Stopping the node daemon and removing configs from node %s", |
2283 | 2283 |
node.name) |
2284 | 2284 |
|
2285 |
# Promote nodes to master candidate as needed |
|
2286 |
_AdjustCandidatePool(self, exceptions=[node.name]) |
|
2285 | 2287 |
self.context.RemoveNode(node.name) |
2286 | 2288 |
|
2287 | 2289 |
# Run post hooks on the node before it's removed |
... | ... | |
2297 | 2299 |
self.LogWarning("Errors encountered on the remote node while leaving" |
2298 | 2300 |
" the cluster: %s", msg) |
2299 | 2301 |
|
2300 |
# Promote nodes to master candidate as needed |
|
2301 |
_AdjustCandidatePool(self) |
|
2302 |
|
|
2303 | 2302 |
|
2304 | 2303 |
class LUQueryNodes(NoHooksLU): |
2305 | 2304 |
"""Logical unit for querying nodes. |
Also available in: Unified diff