Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reinstall changes to rose-suite.conf #5125

Merged
merged 2 commits into from
Oct 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
23 changes: 19 additions & 4 deletions cylc/flow/workflow_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -1464,18 +1464,26 @@ 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',
'rose-suite.conf',
'opt/rose-suite-cylc-install.conf',
WorkflowFiles.LOG_DIR,
WorkflowFiles.WORK_DIR,
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}")
Expand Down Expand Up @@ -1527,12 +1535,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:
Expand Down
12 changes: 6 additions & 6 deletions tests/integration/test_reinstall.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


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