Skip to content

Commit

Permalink
move suite servers to scheduler section of global config
Browse files Browse the repository at this point in the history
  • Loading branch information
wxtim committed Nov 25, 2020
1 parent e2d361e commit e693cbb
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 58 deletions.
62 changes: 30 additions & 32 deletions cylc/flow/cfgspec/globalcfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,36 @@
desc='''
The number of old run directory trees to retain at start-up.
''')
Conf('run hosts', VDR.V_SPACELESS_STRING_LIST, desc='''
A list of allowed suite run hosts. One of these hosts will be
appointed for a suite to start up on if an explicit host is not
provided as an option to a ``run`` or ``restart`` command.
''')
Conf('run ports', VDR.V_INTEGER_LIST, list(range(43001, 43101)),
desc='''
A list of allowed ports for Cylc to use to run suites.
''')
Conf('condemned hosts', VDR.V_ABSOLUTE_HOST_LIST, desc='''
Hosts specified in ``condemned hosts`` will not be considered as
suite run hosts. If suites are already running on ``condemned
hosts`` they will be automatically shutdown and restarted (see
:ref:`auto-stop-restart`).
''')
Conf('auto restart delay', VDR.V_INTERVAL, desc='''
Relates to Cylc's auto stop-restart mechanism (see
:ref:`auto-stop-restart`). When a host is set to automatically
shutdown/restart it will first wait a random period of time between
zero and ``auto restart delay`` seconds before beginning the
process. This is to prevent large numbers of suites from restarting
simultaneously.
''')
Conf('ranking', VDR.V_STRING, desc='''
A multiline string containing Python expressions to filter
and/or rank hosts. For example:
cpu_percent() < 70
cpu_percent()
to filter by cpu_percent() < 70 then to rank by cpu_percent.
''')

with Conf('events', desc='''
You can define site defaults for each of the following options,
Expand Down Expand Up @@ -579,38 +609,6 @@
host if you have to use the *hardwired* self-identification method.
''')

# suite
with Conf('suite servers', desc='''
Configure allowed suite hosts and ports for starting up (running or
restarting) suites. Additionally configure host selection settings
specifying how to determine the most suitable run host at any given
time from those configured.
'''):
Conf('run hosts', VDR.V_SPACELESS_STRING_LIST, desc='''
A list of allowed suite run hosts. One of these hosts will be
appointed for a suite to start up on if an explicit host is not
provided as an option to a ``run`` or ``restart`` command.
''')
Conf('run ports', VDR.V_INTEGER_LIST, list(range(43001, 43101)),
desc='''
A list of allowed ports for Cylc to use to run suites.
''')
Conf('condemned hosts', VDR.V_ABSOLUTE_HOST_LIST, desc='''
Hosts specified in ``condemned hosts`` will not be considered as
suite run hosts. If suites are already running on ``condemned
hosts`` they will be automatically shutdown and restarted (see
:ref:`auto-stop-restart`).
''')
Conf('auto restart delay', VDR.V_INTERVAL, desc='''
Relates to Cylc's auto stop-restart mechanism (see
:ref:`auto-stop-restart`). When a host is set to automatically
shutdown/restart it will first wait a random period of time between
zero and ``auto restart delay`` seconds before beginning the
process. This is to prevent large numbers of suites from restarting
simultaneously.
''')
Conf('ranking', VDR.V_STRING)


def upg(cfg, descr):
"""Upgrader."""
Expand Down
6 changes: 3 additions & 3 deletions cylc/flow/host_select.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,12 @@ def select_suite_host(cached=True):

return select_host(
# list of suite hosts
global_config.get(['suite servers', 'run hosts']) or ['localhost'],
global_config.get(['scheduler', 'run hosts']) or ['localhost'],
# rankings to apply
ranking_string=global_config.get(['suite servers', 'ranking']),
ranking_string=global_config.get(['scheduler', 'ranking']),
# list of condemned hosts
blacklist=global_config.get(
['suite servers', 'condemned hosts']
['scheduler', 'condemned hosts']
),
blacklist_name='condemned host'
)
Expand Down
16 changes: 8 additions & 8 deletions cylc/flow/main_loop/auto_restart.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"""Automatically restart suites if they are running on bad servers.
Loads in the global configuration to check if the server a suite is running
on is listed in :cylc:conf:`global.cylc[suite servers]condemned hosts`.
on is listed in :cylc:conf:`global.cylc[scheduler]condemned hosts`.
This is useful if a host needs to be taken off-line e.g. for scheduled
maintenance.
Expand All @@ -26,11 +26,11 @@
.. cylc-scope:: global.cylc
- :cylc:conf:`[suite servers]auto restart delay`
- :cylc:conf:`[suite servers]condemned hosts`
- :cylc:conf:`[suite servers]run hosts`
- :cylc:conf:`[scheduler]auto restart delay`
- :cylc:conf:`[scheduler]condemned hosts`
- :cylc:conf:`[scheduler]run hosts`
.. cylc-scope:: global.cylc[suite servers]
.. cylc-scope:: global.cylc[scheduler]
The auto stop-restart feature has two modes:
Expand All @@ -56,7 +56,7 @@
.. code-block:: cylc
[suite servers]
[scheduler]
run hosts = pub
condemned hosts = foo, bar!
Expand Down Expand Up @@ -107,7 +107,7 @@ async def auto_restart(scheduler, _):
_set_auto_restart(
scheduler,
restart_delay=current_glbl_cfg.get(
['suite servers', 'auto restart delay']
['scheduler', 'auto restart delay']
),
mode=mode
)
Expand All @@ -117,7 +117,7 @@ def _should_auto_restart(scheduler, current_glbl_cfg):
# check if suite host is condemned - if so auto restart
if scheduler.stop_mode is None:
for host in current_glbl_cfg.get(
['suite servers', 'condemned hosts']
['scheduler', 'condemned hosts']
):
if host.endswith('!'):
# host ends in an `!` -> force shutdown mode
Expand Down
2 changes: 1 addition & 1 deletion cylc/flow/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ async def configure(self):

async def start_servers(self):
"""Start the TCP servers."""
port_range = glbl_cfg().get(['suite servers', 'run ports'])
port_range = glbl_cfg().get(['scheduler', 'run ports'])
self.server.start(port_range[0], port_range[-1])
self.publisher.start(port_range[0], port_range[-1])
# wait for threads to setup socket ports before continuing
Expand Down
2 changes: 1 addition & 1 deletion cylc/flow/scheduler_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ def get_option_parser(is_restart, add_std_opts=False):
help=(
"Specify the host on which to start-up the suite. "
"If not specified, a host will be selected using "
"the 'suite servers' global config."
"the '[scheduler]run hosts' global config."
),
metavar="HOST", action="store", dest="host")

Expand Down
2 changes: 1 addition & 1 deletion tests/integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ def _log_filter(log, name=None, level=None, contains=None, regex=None):

@pytest.fixture(scope='session')
def port_range():
ports = glbl_cfg().get(['suite servers', 'run ports'])
ports = glbl_cfg().get(['scheduler', 'run ports'])
return min(ports), max(ports)


Expand Down
2 changes: 1 addition & 1 deletion tests/unit/network/test_publisher.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

@pytest.fixture(scope='session')
def port_range():
ports = glbl_cfg().get(['suite servers', 'run ports'])
ports = glbl_cfg().get(['scheduler', 'run ports'])
return min(ports), max(ports)


Expand Down
10 changes: 5 additions & 5 deletions tests/unit/test_host_select.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def test_suite_host_select(mock_glbl_cfg):
mock_glbl_cfg(
'cylc.flow.host_select.glbl_cfg',
f'''
[suite servers]
[scheduler]
run hosts = {localhost}
'''
)
Expand All @@ -150,7 +150,7 @@ def test_suite_host_select_default(mock_glbl_cfg):
mock_glbl_cfg(
'cylc.flow.host_select.glbl_cfg',
'''
[suite servers]
[scheduler]
run hosts =
'''
)
Expand All @@ -169,7 +169,7 @@ def test_suite_host_select_condemned(mock_glbl_cfg):
mock_glbl_cfg(
'cylc.flow.host_select.glbl_cfg',
f'''
[suite servers]
[scheduler]
run hosts = {localhost}
condemned hosts = {localhost_fqdn}
'''
Expand All @@ -181,15 +181,15 @@ def test_suite_host_select_condemned(mock_glbl_cfg):


def test_condemned_host_ambiguous(mock_glbl_cfg):
"""Test the [suite servers]condemend host coercer
"""Test the [scheduler]condemend host coercer
Not actually host_select code but related functionality.
"""
with pytest.raises(ListValueError) as excinfo:
mock_glbl_cfg(
'cylc.flow.host_select.glbl_cfg',
f'''
[suite servers]
[scheduler]
run hosts = {localhost}
condemned hosts = {localhost}
'''
Expand Down
12 changes: 6 additions & 6 deletions tests/unit/test_host_select_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,23 +130,23 @@ def mocked_get_metrics(hosts, metrics, _=None):


def test_remote_suite_host_select(mock_glbl_cfg):
"""test [suite servers]run hosts"""
"""test [scheduler]run hosts"""
mock_glbl_cfg(
'cylc.flow.host_select.glbl_cfg',
f'''
[suite servers]
[scheduler]
run hosts = {remote_platform}
'''
)
assert select_suite_host() == (remote_platform, remote_platform_fqdn)


def test_remote_suite_host_condemned(mock_glbl_cfg):
"""test [suite servers]condemned hosts"""
"""test [scheduler]condemned hosts"""
mock_glbl_cfg(
'cylc.flow.host_select.glbl_cfg',
f'''
[suite servers]
[scheduler]
run hosts = {remote_platform}, {local_host}
condemned hosts = {remote_platform}
'''
Expand All @@ -156,11 +156,11 @@ def test_remote_suite_host_condemned(mock_glbl_cfg):


def test_remote_suite_host_rankings(mock_glbl_cfg):
"""test [suite servers]rankings"""
"""test [scheduler]rankings"""
mock_glbl_cfg(
'cylc.flow.host_select.glbl_cfg',
f'''
[suite servers]
[scheduler]
run hosts = {remote_platform}
ranking = """
# if this test fails due to race conditions
Expand Down

0 comments on commit e693cbb

Please sign in to comment.