Skip to content

Commit

Permalink
Deprecate the DEFAULT.cluster_type keyword in favor of DEFAULT.topology
Browse files Browse the repository at this point in the history
Still support cluster_type for backward compat.
  • Loading branch information
cvaroqui committed Oct 23, 2017
1 parent 517dc9f commit 2c4d7b7
Show file tree
Hide file tree
Showing 13 changed files with 51 additions and 48 deletions.
8 changes: 4 additions & 4 deletions lib/node.py
Expand Up @@ -3046,17 +3046,17 @@ 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
except KeyError:
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)
Expand All @@ -3065,7 +3065,7 @@ def load_svc(svcname, data):
line = [
" "+colorize(svcname, color.BOLD),
status,
clustertype,
topology,
"|",
]
for nodename in nodenames:
Expand Down
4 changes: 2 additions & 2 deletions lib/osvcd_mon.py
Expand Up @@ -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):
Expand Down
4 changes: 2 additions & 2 deletions lib/osvcd_shared.py
Expand Up @@ -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' "
Expand All @@ -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'"
Expand Down
4 changes: 2 additions & 2 deletions lib/resScsiReserv.py
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/resSync.py
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion lib/resSyncRsync.py
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions lib/resources.py
Expand Up @@ -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

Expand Down
18 changes: 9 additions & 9 deletions lib/svc.py
Expand Up @@ -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 = []
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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),
))

Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion lib/svcBuilder.py
Expand Up @@ -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

Expand Down
23 changes: 12 additions & 11 deletions lib/svcdict.py
Expand Up @@ -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",
Expand Down Expand Up @@ -768,7 +769,7 @@ def __init__(self):
keyword="flex_primary",
at=True,
order=11,
depends=[('cluster_type', ["flex"])],
depends=[('topology', ["flex"])],
default_text="<first node of the nodes parameter>",
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)."
)
Expand All @@ -781,7 +782,7 @@ def __init__(self):
keyword="drp_flex_primary",
at=True,
order=11,
depends=[('cluster_type', ["flex"])],
depends=[('topology', ["flex"])],
default_text="<first node of the drpnodes parameter>",
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)."
)
Expand Down Expand Up @@ -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
)

Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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.",
)

Expand Down Expand Up @@ -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."
)

Expand All @@ -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."
)

Expand All @@ -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.",
)

Expand All @@ -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.",
)

Expand Down Expand Up @@ -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()
Expand Down
8 changes: 5 additions & 3 deletions lib/xmlrpcClient.py
Expand Up @@ -477,7 +477,7 @@ def _push_resinfo(self, svc, sync=True):

vars = ['res_svcname',
'res_nodename',
'cluster_type',
'topology',
'rid',
'res_key',
'res_value']
Expand All @@ -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:
Expand Down Expand Up @@ -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',
Expand All @@ -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,
Expand Down

0 comments on commit 2c4d7b7

Please sign in to comment.