Commit 3953242f authored by Iustin Pop's avatar Iustin Pop

Add a new cluster parameter maintain_node_health

This will be used to conditionally enable the watcher node maintenance
feature.
Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarGuido Trotter <ultrotter@google.com>
parent aa2efc52
......@@ -197,7 +197,8 @@ def InitCluster(cluster_name, mac_prefix,
master_netdev, file_storage_dir, candidate_pool_size,
secondary_ip=None, vg_name=None, beparams=None,
nicparams=None, hvparams=None, enabled_hypervisors=None,
modify_etc_hosts=True, modify_ssh_setup=True):
modify_etc_hosts=True, modify_ssh_setup=True,
maintain_node_health=False):
"""Initialise the cluster.
@type candidate_pool_size: int
......@@ -340,6 +341,7 @@ def InitCluster(cluster_name, mac_prefix,
ctime=now,
mtime=now,
uuid=utils.NewUUID(),
maintain_node_health=maintain_node_health,
)
master_node_config = objects.Node(name=hostname.name,
primary_ip=hostname.ip,
......
......@@ -76,6 +76,7 @@ __all__ = [
"IGNORE_SECONDARIES_OPT",
"IGNORE_SIZE_OPT",
"MAC_PREFIX_OPT",
"MAINTAIN_NODE_HEALTH_OPT",
"MASTER_NETDEV_OPT",
"MC_OPT",
"NET_OPT",
......@@ -913,6 +914,13 @@ USE_REPL_NET_OPT = cli_option("--use-replication-network",
" for talking to the nodes",
action="store_true", default=False)
MAINTAIN_NODE_HEALTH_OPT = \
cli_option("--maintain-node-health", dest="maintain_node_health",
metavar=_YORNO, default=None, type="bool",
help="Configure the cluster to automatically maintain node"
" health, by shutting down unknown instances, shutting down"
" unknown DRBD devices, etc.")
def _ParseArgs(argv, commands, aliases):
"""Parser for the command line arguments.
......
......@@ -2240,6 +2240,7 @@ class LUSetClusterParams(LogicalUnit):
if self.op.candidate_pool_size < 1:
raise errors.OpPrereqError("At least one master candidate needed",
errors.ECODE_INVAL)
_CheckBooleanOpField(self.op, "maintain_node_health")
def ExpandNames(self):
# FIXME: in the future maybe other cluster params won't require checking on
......@@ -2432,6 +2433,9 @@ class LUSetClusterParams(LogicalUnit):
# we need to update the pool size here, otherwise the save will fail
_AdjustCandidatePool(self, [])
if self.op.maintain_node_health is not None:
self.cluster.maintain_node_health = self.op.maintain_node_health
self.cfg.Update(self.cluster, feedback_fn)
......@@ -3691,6 +3695,7 @@ class LUQueryClusterInfo(NoHooksLU):
"master_netdev": cluster.master_netdev,
"volume_group_name": cluster.volume_group_name,
"file_storage_dir": cluster.file_storage_dir,
"maintain_node_health": cluster.maintain_node_health,
"ctime": cluster.ctime,
"mtime": cluster.mtime,
"uuid": cluster.uuid,
......
......@@ -864,6 +864,7 @@ class Cluster(TaggableObject):
"candidate_pool_size",
"modify_etc_hosts",
"modify_ssh_setup",
"maintain_node_health",
] + _TIMESTAMPS + _UUID
def UpgradeConfig(self):
......@@ -910,6 +911,10 @@ class Cluster(TaggableObject):
if hvname != self.default_hypervisor])
self.default_hypervisor = None
# maintain_node_health added after 2.1.1
if self.maintain_node_health is None:
self.maintain_node_health = False
def ToDict(self):
"""Custom function for cluster.
......
......@@ -305,6 +305,7 @@ class OpSetClusterParams(OpCode):
"beparams",
"nicparams",
"candidate_pool_size",
"maintain_node_health",
]
......
......@@ -242,6 +242,8 @@
<sbr>
<arg>--nic-parameters <replaceable>nic-param</replaceable>=<replaceable>value</replaceable><arg rep="repeat" choice="opt">,<replaceable>nic-param</replaceable>=<replaceable>value</replaceable></arg></arg>
<sbr>
<arg>--maintain-node-health <group choice="req"><arg>yes</arg><arg>no</arg></group></arg>
<sbr>
<arg choice="req"><replaceable>clustername</replaceable></arg>
</cmdsynopsis>
......@@ -489,6 +491,15 @@
</variablelist>
</para>
<para>
The option <option>--maintain-node-health</option> allows to
enable/disable automatic maintenance actions on
nodes. Currently these include automatic shutdown of instances
and deactivation of DRBD devices on offline nodes; in the
future it might be extended to automatic removal of unknown
LVM volumes, etc.
</para>
</refsect2>
<refsect2>
......@@ -546,6 +557,8 @@
<arg choice="opt">--nic-parameters <replaceable>nic-param</replaceable>=<replaceable>value</replaceable><arg rep="repeat" choice="opt">,<replaceable>nic-param</replaceable>=<replaceable>value</replaceable></arg></arg>
<sbr>
<arg choice="opt">-C <replaceable>candidate_pool_size</replaceable></arg>
<sbr>
<arg>--maintain-node-health <group choice="req"><arg>yes</arg><arg>no</arg></group></arg>
</cmdsynopsis>
......@@ -558,7 +571,8 @@
<option>--enabled-hypervisors</option>,
<option>--hypervisor-parameters</option>,
<option>--backend-parameters</option> and
<option>--nic-parameters</option> and options are
<option>--nic-parameters</option>
and <option>--maintain-node-health</option> options are
described in the <command>init</command> command.
</para>
......
......@@ -104,6 +104,7 @@ def InitCluster(opts, args):
candidate_pool_size=opts.candidate_pool_size,
modify_etc_hosts=opts.modify_etc_hosts,
modify_ssh_setup=opts.modify_ssh_setup,
maintain_node_health=opts.maintain_node_health,
)
op = opcodes.OpPostInitCluster()
SubmitOpCode(op, opts=opts)
......@@ -272,6 +273,8 @@ def ShowClusterConfig(opts, args):
ToStdout(" - master netdev: %s", result["master_netdev"])
ToStdout(" - lvm volume group: %s", result["volume_group_name"])
ToStdout(" - file storage path: %s", result["file_storage_dir"])
ToStdout(" - maintenance of node health: %s",
result["maintain_node_health"])
ToStdout("Default instance parameters:")
_PrintGroupedParams(result["beparams"])
......@@ -597,7 +600,8 @@ def SetClusterParams(opts, args):
if not (not opts.lvm_storage or opts.vg_name or
opts.enabled_hypervisors or opts.hvparams or
opts.beparams or opts.nicparams or
opts.candidate_pool_size is not None):
opts.candidate_pool_size is not None or
opts.maintain_node_health is not None):
ToStderr("Please give at least one of the parameters.")
return 1
......@@ -624,13 +628,16 @@ def SetClusterParams(opts, args):
nicparams = opts.nicparams
utils.ForceDictType(nicparams, constants.NICS_PARAMETER_TYPES)
mnh = opts.maintain_node_health
op = opcodes.OpSetClusterParams(vg_name=vg_name,
enabled_hypervisors=hvlist,
hvparams=hvparams,
os_hvp=None,
beparams=beparams,
nicparams=nicparams,
candidate_pool_size=opts.candidate_pool_size)
candidate_pool_size=opts.candidate_pool_size,
maintain_node_health=mnh)
SubmitOpCode(op, opts=opts)
return 0
......@@ -712,7 +719,7 @@ commands = {
[BACKEND_OPT, CP_SIZE_OPT, ENABLED_HV_OPT, GLOBAL_FILEDIR_OPT,
HVLIST_OPT, MAC_PREFIX_OPT, MASTER_NETDEV_OPT, NIC_PARAMS_OPT,
NOLVM_STORAGE_OPT, NOMODIFY_ETCHOSTS_OPT, NOMODIFY_SSH_SETUP_OPT,
SECONDARY_IP_OPT, VG_NAME_OPT],
SECONDARY_IP_OPT, VG_NAME_OPT, MAINTAIN_NODE_HEALTH_OPT],
"[opts...] <cluster_name>", "Initialises a new cluster configuration"),
'destroy': (
DestroyCluster, ARGS_NONE, [YES_DOIT_OPT],
......@@ -781,7 +788,7 @@ commands = {
'modify': (
SetClusterParams, ARGS_NONE,
[BACKEND_OPT, CP_SIZE_OPT, ENABLED_HV_OPT, HVLIST_OPT,
NIC_PARAMS_OPT, NOLVM_STORAGE_OPT, VG_NAME_OPT],
NIC_PARAMS_OPT, NOLVM_STORAGE_OPT, VG_NAME_OPT, MAINTAIN_NODE_HEALTH_OPT],
"[opts...]",
"Alters the parameters of the cluster"),
"renew-crypto": (
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment