From 5230253f0f673d7d64fc2161557c6ffcc5a5510a Mon Sep 17 00:00:00 2001 From: Tim Pillinger <26465611+wxtim@users.noreply.github.com> Date: Mon, 3 Oct 2022 15:45:11 +0100 Subject: [PATCH 1/2] fix rose re-install fail --- CHANGES.md | 3 +++ cylc/flow/workflow_files.py | 22 +++++++++++++++++++--- tests/integration/test_reinstall.py | 12 ++++++------ 3 files changed, 28 insertions(+), 9 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 84a9dd8dc28..482508745f3 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -36,6 +36,9 @@ Maintenance release. ### Fixes +[#5125](https://github.com/cylc/cylc-flow/pull/5125) - Allow rose-suite.conf +changes to be considered by ``cylc reinstall``. + [#5023](https://github.com/cylc/cylc-flow/pull/5023) - tasks force-triggered after a shutdown was ordered should submit to run immediately on restart. diff --git a/cylc/flow/workflow_files.py b/cylc/flow/workflow_files.py index b0069b30b0e..e3eaabf8825 100644 --- a/cylc/flow/workflow_files.py +++ b/cylc/flow/workflow_files.py @@ -1464,7 +1464,8 @@ def get_rsync_rund_cmd(src, dst, reinstall=False, dry_run=False): rsync_cmd.append("--dry-run") if reinstall: rsync_cmd.append('--delete') - for exclude in [ + + exclusions = [ '.git', '.svn', '.cylcignore', @@ -1475,7 +1476,15 @@ def get_rsync_rund_cmd(src, dst, reinstall=False, dry_run=False): WorkflowFiles.SHARE_DIR, WorkflowFiles.Install.DIRNAME, WorkflowFiles.Service.DIRNAME - ]: + ] + + # This is a hack to make sure that changes to rose-suite.conf + # are considered when re-installing. + # It should be removed after https://github.com/cylc/cylc-rose/issues/149 + if not dry_run: + exclusions.append('rose-suite.conf') + + for exclude in exclusions: if (Path(src).joinpath(exclude).exists() or Path(dst).joinpath(exclude).exists()): rsync_cmd.append(f"--exclude={exclude}") @@ -1527,12 +1536,19 @@ def reinstall_workflow( reinstall=True, dry_run=dry_run, ) + + # Add '+++' to -out-format to mark lines passed through formatter. + rsync_cmd.append('--out-format=+++%o %n%L+++') + + # Run rsync command: reinstall_log.info(cli_format(rsync_cmd)) LOG.debug(cli_format(rsync_cmd)) proc = Popen(rsync_cmd, stdout=PIPE, stderr=PIPE, text=True) # nosec # * command is constructed via internal interface stdout, stderr = proc.communicate() - stdout = stdout.strip() + + # Strip unwanted output. + stdout = ('\n'.join(re.findall(r'\+\+\+(.*)\+\+\+', stdout))).strip() stderr = stderr.strip() if proc.returncode != 0: diff --git a/tests/integration/test_reinstall.py b/tests/integration/test_reinstall.py index 4ffe4bbface..a0d2cdbc12a 100644 --- a/tests/integration/test_reinstall.py +++ b/tests/integration/test_reinstall.py @@ -62,7 +62,7 @@ def non_interactive(monkeypatch): def one_src(tmp_path): src_dir = tmp_path (src_dir / 'flow.cylc').touch() - # (src_dir / 'rose-suite.conf').touch() + (src_dir / 'rose-suite.conf').touch() return SimpleNamespace(path=src_dir) @@ -242,15 +242,15 @@ def test_rose_warning(one_src, one_run, capsys, interactive, monkeypatch): ) (one_src.path / 'a').touch() # give it something to install - # reinstall (no rose-suite.conf file) - reinstall_cli(opts=ReInstallOptions(), args=one_run.id) - assert rose_message not in capsys.readouterr().err - # reinstall (with rose-suite.conf file) - (one_src.path / 'rose-suite.conf').touch() reinstall_cli(opts=ReInstallOptions(), args=one_run.id) assert rose_message in capsys.readouterr().err + # reinstall (no rose-suite.conf file) + (one_src.path / 'rose-suite.conf').unlink() + reinstall_cli(opts=ReInstallOptions(), args=one_run.id) + assert rose_message not in capsys.readouterr().err + def test_keyboard_interrupt( one_src, From 0feaabbc6f4c87de60b266fed400c6b26d7038af Mon Sep 17 00:00:00 2001 From: Tim Pillinger <26465611+wxtim@users.noreply.github.com> Date: Tue, 4 Oct 2022 10:26:30 +0100 Subject: [PATCH 2/2] fix mistake --- cylc/flow/workflow_files.py | 1 - 1 file changed, 1 deletion(-) diff --git a/cylc/flow/workflow_files.py b/cylc/flow/workflow_files.py index e3eaabf8825..6d2ada72dc6 100644 --- a/cylc/flow/workflow_files.py +++ b/cylc/flow/workflow_files.py @@ -1469,7 +1469,6 @@ def get_rsync_rund_cmd(src, dst, reinstall=False, dry_run=False): '.git', '.svn', '.cylcignore', - 'rose-suite.conf', 'opt/rose-suite-cylc-install.conf', WorkflowFiles.LOG_DIR, WorkflowFiles.WORK_DIR,