Skip to content

Commit

Permalink
Set forward variables by platform
Browse files Browse the repository at this point in the history
  • Loading branch information
ScottWales committed Oct 27, 2023
1 parent 8053ead commit ac071c6
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 22 deletions.
16 changes: 8 additions & 8 deletions cylc/flow/cfgspec/globalcfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -784,14 +784,6 @@ def default_for(
{REPLACES}``[suite servers][run host select]rank``.
''')
Conf('ssh forward environment variables', VDR.V_STRING_LIST, '',
desc='''
A list containing the names of the environment variables to
forward with SSH connections to the workflow host from
the host running 'cylc play'
.. versionadded:: 8.3.0
''')

with Conf('host self-identification', desc=f'''
How Cylc determines and shares the identity of the workflow host.
Expand Down Expand Up @@ -1640,6 +1632,14 @@ def default_for(
.. versionadded:: 8.0.0
''')
Conf('ssh forward environment variables', VDR.V_STRING_LIST, '',
desc='''
A list containing the names of the environment variables to
forward with SSH connections to the workflow host from
the host running 'cylc play'
.. versionadded:: 8.3.0
''')
with Conf('selection', desc='''
How to select a host from the list of platform hosts.
Expand Down
5 changes: 1 addition & 4 deletions cylc/flow/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
from cylc.flow.option_parsers import verbosity_to_opts
from cylc.flow.platforms import get_platform, get_host_from_platform
from cylc.flow.util import format_cmd
from cylc.flow.cfgspec.glbl_cfg import glbl_cfg


def get_proc_ancestors():
Expand Down Expand Up @@ -300,9 +299,7 @@ def construct_ssh_cmd(
'CYLC_COVERAGE',
'CLIENT_COMMS_METH',
'CYLC_ENV_NAME',
*(glbl_cfg().get(['scheduler'])
['run hosts']
['ssh forward environment variables']),
*platform['ssh forward environment variables'],
]:
if envvar in os.environ:
command.append(
Expand Down
10 changes: 10 additions & 0 deletions tests/unit/cfgspec/test_globalcfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,3 +148,13 @@ def test_source_dir_validation(
assert "must be an absolute path" in str(excinfo.value)
else:
glblcfg.load()

def test_platform_ssh_forward_variables(mock_global_config):

glblcfg: GlobalConfig = mock_global_config('''
[platforms]
[[foo]]
ssh forward environment variables = "FOO", "BAR"
''')

assert glblcfg.get(['platforms','foo','ssh forward environment variables']) == ["FOO", "BAR"]
12 changes: 2 additions & 10 deletions tests/unit/test_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,25 +90,17 @@ def test_construct_rsync_over_ssh_cmd():
]


def test_construct_ssh_cmd_forward_env(mock_glbl_cfg):
def test_construct_ssh_cmd_forward_env():
""" Test for 'ssh forward environment variables'
"""
import os

mock_glbl_cfg(
'cylc.flow.remote.glbl_cfg',
'''
[scheduler]
[[run hosts]]
ssh forward environment variables = FOO, BAR
'''
)

host = 'example.com'
config = {
'ssh command': 'ssh',
'use login shell': None,
'cylc path': None,
'ssh forward environment variables': ['FOO', 'BAZ'],
}

# Variable isn't set, no change to command
Expand Down

0 comments on commit ac071c6

Please sign in to comment.