From 2c4d7b7c1ef127da0c0cbb7f50966293a00e7f01 Mon Sep 17 00:00:00 2001 From: Christophe Varoqui Date: Mon, 23 Oct 2017 20:15:05 +0200 Subject: [PATCH] Deprecate the DEFAULT.cluster_type keyword in favor of DEFAULT.topology Still support cluster_type for backward compat. --- lib/node.py | 8 +++---- lib/osvcd_mon.py | 4 ++-- lib/osvcd_shared.py | 4 ++-- lib/resScsiReserv.py | 4 ++-- lib/resSync.py | 2 +- lib/resSyncRsync.py | 2 +- lib/resources.py | 4 ++-- lib/svc.py | 18 +++++++-------- lib/svcBuilder.py | 2 +- lib/svcdict.py | 23 ++++++++++---------- lib/xmlrpcClient.py | 8 ++++--- usr/share/doc/template.DEFAULT.conf | 18 +++++++-------- usr/share/doc/template.container.docker.conf | 2 +- 13 files changed, 51 insertions(+), 48 deletions(-) diff --git a/lib/node.py b/lib/node.py index 0ccaa9b281..272138a1b7 100644 --- a/lib/node.py +++ b/lib/node.py @@ -3046,9 +3046,9 @@ def load_header(title): def load_svc(svcname, data): try: - clustertype = services[svcname].topology + topology = services[svcname].topology except KeyError: - clustertype = "" + topology = "" try: nodes = self.services[svcname].nodes drpnodes = self.services[svcname].drpnodes @@ -3056,7 +3056,7 @@ def load_svc(svcname, data): nodes = set() drpnodes = set() if rcEnv.nodename in drpnodes: - clustertype = "drp " + clustertype + topology = "drp " + topology status = colorize_status(data["avail"], lpad=0) if data["overall"] == "warn": status += colorize("!", color.BROWN) @@ -3065,7 +3065,7 @@ def load_svc(svcname, data): line = [ " "+colorize(svcname, color.BOLD), status, - clustertype, + topology, "|", ] for nodename in nodenames: diff --git a/lib/osvcd_mon.py b/lib/osvcd_mon.py index d27a38d458..8069539743 100644 --- a/lib/osvcd_mon.py +++ b/lib/osvcd_mon.py @@ -550,9 +550,9 @@ def service_orchestrator_auto(self, svc, smon, status): # svc.svcname, ','.join(intersection)) return - if svc.clustertype == "failover": + if svc.topology == "failover": self.service_orchestrator_auto_failover(svc, smon, status, candidates) - elif svc.clustertype == "flex": + elif svc.topology == "flex": self.service_orchestrator_auto_flex(svc, smon, status, candidates) def service_orchestrator_auto_failover(self, svc, smon, status, candidates): diff --git a/lib/osvcd_shared.py b/lib/osvcd_shared.py index e8e47b3750..d4c7eacc02 100644 --- a/lib/osvcd_shared.py +++ b/lib/osvcd_shared.py @@ -626,7 +626,7 @@ def placement_leader(self, svc, candidates=None, silent=False): ranks = self.placement_ranks(svc, candidates=candidates) if ranks == []: return False - elif svc.clustertype == "failover": + elif svc.topology == "failover": if rcEnv.nodename == ranks[0]: if not silent: self.duplog("info", "we have the highest '%(placement)s' " @@ -641,7 +641,7 @@ def placement_leader(self, svc, candidates=None, silent=False): nodename=ranks[0], placement=svc.placement, svcname=svc.svcname) return False - elif svc.clustertype == "flex": + elif svc.topology == "flex": index = ranks.index(rcEnv.nodename) + 1 if not silent: self.duplog("info", "we have the %(idx)d/%(mini)d '%(placement)s'" diff --git a/lib/resScsiReserv.py b/lib/resScsiReserv.py index e470d25206..de97d51108 100644 --- a/lib/resScsiReserv.py +++ b/lib/resScsiReserv.py @@ -64,9 +64,9 @@ def get_hostid(self): def info(self): self.get_hostid() data = [ - [self.svc.svcname, self.svc.node.nodename, self.svc.clustertype, self.rid, "prkey", self.hostid], + ["prkey", self.hostid], ] - return data + return self.fmt_info(data) def scsireserv_supported(self): return False diff --git a/lib/resSync.py b/lib/resSync.py index 3809d072b4..0c0e301806 100644 --- a/lib/resSync.py +++ b/lib/resSync.py @@ -117,7 +117,7 @@ def pre_sync_check_svc_not_up(self): def pre_sync_check_flex_primary(self): """ Refuse to sync from a flex non-primary node """ - if self.svc.clustertype in ["flex", "autoflex"] and \ + if self.svc.topology == "flex" and \ self.svc.flex_primary != rcEnv.nodename: if self.svc.options.cron: self.log.debug("won't sync this resource from a flex non-primary node") diff --git a/lib/resSyncRsync.py b/lib/resSyncRsync.py index bb7c5f7738..81760f30e8 100644 --- a/lib/resSyncRsync.py +++ b/lib/resSyncRsync.py @@ -349,7 +349,7 @@ def _status(self, verbose=False): """ s = self.svc.group_status(excluded_groups=set(["sync", "hb", "app"])) if s['avail'].status != rcStatus.UP or \ - (self.svc.clustertype in ['flex', 'autoflex'] and \ + (self.svc.topology == 'flex' and \ rcEnv.nodename != self.svc.flex_primary and \ s['avail'].status == rcStatus.UP): if rcEnv.nodename not in target: diff --git a/lib/resources.py b/lib/resources.py index 00aa4dd4fb..cfbbb1493a 100644 --- a/lib/resources.py +++ b/lib/resources.py @@ -99,14 +99,14 @@ def fmt_info(self, keys=None): keys[idx] = [ self.svc.svcname, self.svc.node.nodename, - self.svc.clustertype, + self.svc.topology, self.rid ] + key elif len(key) == 3: keys[idx] = [ self.svc.svcname, self.svc.node.nodename, - self.svc.clustertype + self.svc.topology ] + key return keys diff --git a/lib/svc.py b/lib/svc.py index 95436e8804..3820fb2a48 100644 --- a/lib/svc.py +++ b/lib/svc.py @@ -431,7 +431,7 @@ def __init__(self, svcname=None, node=None, cf=None): self.conf = os.path.join(rcEnv.paths.pathetc, svcname+".conf") self.comment = "" self.orchestrate = "ha" - self.clustertype = "failover" + self.topology = "failover" self.placement = "nodes order" self.stonith = False self.parents = [] @@ -529,7 +529,7 @@ def sched(self): @lazy def ha(self): - if self.clustertype == "flex": + if self.topology == "flex": return True if self.has_monitored_resources(): return True @@ -1374,7 +1374,7 @@ def print_status_data_eval(self, refresh=False): "placement": self.placement, "flex_min_nodes": self.flex_min_nodes, "flex_max_nodes": self.flex_max_nodes, - "topology": self.clustertype, + "topology": self.topology, "parents": self.parents, "children": self.children, "enslave_children": self.enslave_children, @@ -1427,7 +1427,7 @@ def print_status_data_eval(self, refresh=False): data['resources'][rid]["subset"] = resource.subset for group in group_status: data[group] = str(group_status[group]) - if self.stonith and self.clustertype == "failover" and data["avail"] == "up": + if self.stonith and self.topology == "failover" and data["avail"] == "up": data["stonith"] = True self.write_status_data(data) return data @@ -3443,7 +3443,7 @@ def do_cluster_action(self, action, options=None, waitlock=60, collect=False, ac if action in ("edit_config", "validate_config") or "sync" in action: return - if self.clustertype == "flex": + if self.topology == "flex": if rcEnv.nodename == self.drp_flex_primary: peers = set(self.drpnodes) - set([rcEnv.nodename]) elif rcEnv.nodename == self.flex_primary: @@ -3540,9 +3540,9 @@ def do_action(self, action, options): flex_primary run the action on all remote nodes. """ - if action not in ACTIONS_NO_LOCK and self.clustertype not in CLUSTER_TYPES: + if action not in ACTIONS_NO_LOCK and self.topology not in CLUSTER_TYPES: raise ex.excError("invalid cluster type '%s'. allowed: %s" % ( - self.clustertype, + self.topology, ', '.join(CLUSTER_TYPES), )) @@ -3709,8 +3709,8 @@ def destination_node_sanity_checks(self, destination_node=None): * the specified destination is the current node * the specified destination is not a service candidate node """ - if self.clustertype != "failover": - raise ex.excError("this service clustertype is not 'failover'") + if self.topology != "failover": + raise ex.excError("this service topology is not 'failover'") if destination_node is None: destination_node = self.options.destination_node if destination_node is None: diff --git a/lib/svcBuilder.py b/lib/svcBuilder.py index 4f049a171f..372b0f249d 100644 --- a/lib/svcBuilder.py +++ b/lib/svcBuilder.py @@ -2098,7 +2098,7 @@ def build(name, minimal=False, svcconf=None, node=None): pass try: - svc.clustertype = svc.conf_get('DEFAULT', 'cluster_type') + svc.topology = svc.conf_get('DEFAULT', 'topology') except ex.OptNotFound as exc: pass diff --git a/lib/svcdict.py b/lib/svcdict.py index 5aec2cce61..9f9ce0779d 100644 --- a/lib/svcdict.py +++ b/lib/svcdict.py @@ -7,6 +7,7 @@ # deprecated => supported deprecated_keywords = { "DEFAULT.mode": None, + "DEFAULT.cluster_type": "topology", "DEFAULT.service_type": "env", "DEFAULT.affinity": "hard_affinity", "DEFAULT.anti_affinity": "hard_anti_affinity", @@ -768,7 +769,7 @@ def __init__(self): keyword="flex_primary", at=True, order=11, - depends=[('cluster_type', ["flex"])], + depends=[('topology', ["flex"])], default_text="", text="The node in charge of syncing the other nodes. --cluster actions on the flex_primary are execute on all peer nodes (ie, not drpnodes)." ) @@ -781,7 +782,7 @@ def __init__(self): keyword="drp_flex_primary", at=True, order=11, - depends=[('cluster_type', ["flex"])], + depends=[('topology', ["flex"])], default_text="", text="The drpnode in charge of syncing the other drpnodes. --cluster actions on the drp_flex_primary are execute on all drpnodes (ie, not pri nodes)." ) @@ -925,7 +926,7 @@ def __init__(self): default=False, convert="boolean", candidates=(True, False), - text="If set to True, run this container as a docker service, which is possible if the cluster_type is set to flex and the docker swarm properly initialized.", + text="If set to True, run this container as a docker service, which is possible if the :kw:`topology` is set to flex and the docker swarm properly initialized.", example=False ) @@ -1397,12 +1398,12 @@ def __init__(self): text="Specifies if the disabled resources must be included in the print status and json status output." ) -class KeywordClusterType(Keyword): +class KeywordTopology(Keyword): def __init__(self): Keyword.__init__( self, section="DEFAULT", - keyword="cluster_type", + keyword="topology", at=True, order=15, default="failover", @@ -1434,7 +1435,7 @@ def __init__(self): order=16, default=False, candidates=(True, False), - depends=[("cluster_type", ["failover"])], + depends=[("topology", ["failover"])], text="Stonith the node previously running the service if stale upon start by the daemon monitor.", ) @@ -1474,7 +1475,7 @@ def __init__(self): order=16, default=1, convert="integer", - depends=[("cluster_type", ["flex"])], + depends=[("topology", ["flex"])], text="Minimum number of active nodes in the cluster. Below this number alerts are raised by the collector, and the collector won't stop any more service instances." ) @@ -1487,7 +1488,7 @@ def __init__(self): order=16, default=10, convert="integer", - depends=[("cluster_type", ["flex"])], + depends=[("topology", ["flex"])], text="Maximum number of active nodes in the cluster. Above this number alerts are raised by the collector, and the collector won't start any more service instances. 0 means unlimited." ) @@ -1500,7 +1501,7 @@ def __init__(self): order=16, default=10, convert="integer", - depends=[("cluster_type", ["flex"])], + depends=[("topology", ["flex"])], text="Cluster-wide load average below which flex service instances will be stopped.", ) @@ -1513,7 +1514,7 @@ def __init__(self): order=16, default=70, convert="integer", - depends=[("cluster_type", ["flex"])], + depends=[("topology", ["flex"])], text="Cluster-wide load average above which flex new service instances will be started.", ) @@ -4889,7 +4890,7 @@ def kw_requires(section, action): self += KeywordSoftAffinity() self += KeywordSoftAntiAffinity() self += KeywordShowDisabled() - self += KeywordClusterType() + self += KeywordTopology() self += KeywordOrchestrate() self += KeywordPlacement() self += KeywordConstraints() diff --git a/lib/xmlrpcClient.py b/lib/xmlrpcClient.py index 67b61204bb..232080321f 100644 --- a/lib/xmlrpcClient.py +++ b/lib/xmlrpcClient.py @@ -477,7 +477,7 @@ def _push_resinfo(self, svc, sync=True): vars = ['res_svcname', 'res_nodename', - 'cluster_type', + 'topology', 'rid', 'res_key', 'res_value'] @@ -489,6 +489,8 @@ def _push_resinfo(self, svc, sync=True): ["optional", str(r.optional).lower()], ["disabled", str(r.disabled).lower()], ["monitor", str(r.monitor).lower()], + ["shared", str(r.shared).lower()], + ["encap", str(r.encap).lower()], ["restart", str(r.nb_restart)], ] if r.subset: @@ -528,7 +530,7 @@ def repr_config(svc): return vars = ['svc_name', - 'svc_cluster_type', + 'svc_topology', 'svc_flex_min_nodes', 'svc_flex_max_nodes', 'svc_flex_cpu_low_threshold', @@ -543,7 +545,7 @@ def repr_config(svc): 'svc_ha'] vals = [svc.svcname, - svc.clustertype, + svc.topology, svc.flex_min_nodes, svc.flex_max_nodes, svc.flex_cpu_low_threshold, diff --git a/usr/share/doc/template.DEFAULT.conf b/usr/share/doc/template.DEFAULT.conf index ab503db08f..0e5b95ed67 100644 --- a/usr/share/doc/template.DEFAULT.conf +++ b/usr/share/doc/template.DEFAULT.conf @@ -48,7 +48,7 @@ # default: # inheritance: leaf > head # scope order: specific > generic -# depends: cluster_type in ['flex'] +# depends: topology in ['flex'] # # desc: The node in charge of syncing the other nodes. --cluster actions on # the flex_primary are execute on all peer nodes (ie, not drpnodes). @@ -64,7 +64,7 @@ # default: # inheritance: leaf > head # scope order: specific > generic -# depends: cluster_type in ['flex'] +# depends: topology in ['flex'] # # desc: The drpnode in charge of syncing the other drpnodes. --cluster # actions on the drp_flex_primary are execute on all drpnodes (ie, not @@ -396,7 +396,7 @@ ;show_disabled = True # -# keyword: cluster_type +# keyword: topology # ---------------------------------------------------------------------------- # scopable: True # required: False @@ -411,7 +411,7 @@ # can be up on n out of m nodes (n <= m), n/m must be in the # [flex_min_nodes, flex_max_nodes] range. # -;cluster_type = failover +;topology = failover # # keyword: env @@ -526,7 +526,7 @@ # default: 1 # inheritance: leaf > head # scope order: specific > generic -# depends: cluster_type in ['flex'] +# depends: topology in ['flex'] # convert: integer # # desc: Minimum number of active nodes in the cluster. Below this number @@ -544,7 +544,7 @@ # default: 10 # inheritance: leaf > head # scope order: specific > generic -# depends: cluster_type in ['flex'] +# depends: topology in ['flex'] # convert: integer # # desc: Maximum number of active nodes in the cluster. Above this number @@ -562,7 +562,7 @@ # default: 10 # inheritance: leaf > head # scope order: specific > generic -# depends: cluster_type in ['flex'] +# depends: topology in ['flex'] # convert: integer # # desc: Cluster-wide load average below which flex service instances will be @@ -579,7 +579,7 @@ # default: 70 # inheritance: leaf > head # scope order: specific > generic -# depends: cluster_type in ['flex'] +# depends: topology in ['flex'] # convert: integer # # desc: Cluster-wide load average above which flex new service instances @@ -597,7 +597,7 @@ # inheritance: leaf > head # scope order: specific > generic # candidates: True | False -# depends: cluster_type in ['failover'] +# depends: topology in ['failover'] # convert: boolean # # desc: Stonith the node previously running the service if stale upon start diff --git a/usr/share/doc/template.container.docker.conf b/usr/share/doc/template.container.docker.conf index 602d5c123b..7c49017153 100644 --- a/usr/share/doc/template.container.docker.conf +++ b/usr/share/doc/template.container.docker.conf @@ -95,7 +95,7 @@ # convert: boolean # # desc: If set to True, run this container as a docker service, which is -# possible if the cluster_type is set to flex and the docker swarm +# possible if the :kw:`topology` is set to flex and the docker swarm # properly initialized. # ;docker_service = False