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

Fix reinstall not detecting changed permissions by itself #6658

Open
wants to merge 4 commits into
base: 8.4.x
Choose a base branch
from

Conversation

MetRonnie
Copy link
Member

@MetRonnie MetRonnie commented Mar 6, 2025

This fixes a bug where cylc reinstall in interactive mode would not pick up on permissions changes for files.

The reason for this is that rsync does not report files as included to be sent if only the permissions have been changed, unless %i is added to the --out-format option. %i is an itemized changes summary.

https://linux.die.net/man/1/rsync, https://man.freebsd.org/cgi/man.cgi?query=rsync

The "%i" escape has a cryptic output that is 11 letters long. The general format is like the string YXcstpoguax, where Y is replaced by the type of update being done, X is replaced by the file-type, and the other letters represent attributes that may be output if they are being modified.

I have hidden this itemized changes summary unless using cylc reinstall -v or even higher verbosity.

Check List

  • I have read CONTRIBUTING.md and added my name as a Code Contributor.
  • Contains logically grouped changes (else tidy your branch by rebase).
  • Does not contain off-topic changes (use other PRs for other changes).
  • No dependency changes
  • Tests are included
  • Changelog entry included if this is a change that can affect users
  • No docs needed
  • If this is a bug fix, PR should be raised against the relevant ?.?.x branch.

@MetRonnie MetRonnie added bug Something is wrong :( small labels Mar 6, 2025
@MetRonnie MetRonnie added this to the 8.4.2 milestone Mar 6, 2025
@MetRonnie MetRonnie self-assigned this Mar 6, 2025
@MetRonnie MetRonnie marked this pull request as ready for review March 10, 2025 13:52
stdout, stderr = proc.communicate()

# Strip unwanted output.
stdout = ('\n'.join(re.findall(r'\+\+\+(.*)\+\+\+', stdout))).strip()
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seemed to be duplicating the work of format_rsync_output(), but removing all cannot delete non-empty directory: lines, not just the opt dir

Copy link
Member

@oliver-sanders oliver-sanders Mar 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The point of the +++ prefix/suffix will have been to separate intended rsync output from any unexpected "junk" that might be output by the command / shell, ensuring that we only display what we need, even if the output differs from expectation in other ways.

Why did you remove this? Just didn't like the look of it?

Remember that this code is used for more than just the dry-run check.

Copy link
Member Author

@MetRonnie MetRonnie Mar 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the context I could gather in #5125, the only unwanted output that was being targeted was cannot delete non-empty directory:. This is implemented in format_reinstall_output()

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This rsync command doesn't just apply to the dry-run check (which is passed throughformat_rsync_output). And this prefix stripped out other potential output.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

# Strip unwanted output.
stdout = ('\n'.join(re.findall(r'\+\+\+(.*)\+\+\+', stdout))).strip()

is at odds with
else:
# other uncategorised log line
lines.append(line)

The former seems to have been implemented to cover cannot delete non-empty directory:, there was no mention of any other potential rsync output in #5125. And the latter seems to have been implemented to deliberately include other potential rsync output in case the rsync implementation results in non-standard output format.

Hence I am not sure we should be stripping other potential rsync output.

Copy link
Member

@oliver-sanders oliver-sanders Mar 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not at odds.

  • The +++ prefix ensures that only the intended output lines get through.
  • The else handles intended output lines that don't match send or del..

Copy link
Member Author

@MetRonnie MetRonnie Mar 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cannot delete non-empty directory: does not have +++ pre/suffixed to it (it is orthogonal to the %o %n%L output format). It is always being stripped. Only lines that match send or del. have +++ pre/suffixed anyway.

Copy link
Member Author

@MetRonnie MetRonnie Mar 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only case I can think of where some other potential output would make it through both bits of code is if the %o output format resulted in something other than send or del.. But that seems unlikely

else:
# other uncategorised log line
# shouldn't happen; tolerate unknown rsync implementation?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you don't think it should happen, then perhaps a message warning that this is an unexpected rsync implementation, please contact the dev team might be appropriate.

continue
match = re.match(r'^(.{11}) (send|del\.) (.*)$', line)
if match:
summary, operation, file = match.groups()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[should not block/nice to have]
If nothing has changed except permissions can get this info from the rsync output and pass it on to the user?

Copy link
Member

@wxtim wxtim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Tested manually
  • Read
  • Made 2 non-blocking suggestions

@@ -180,9 +180,14 @@ def get_includes_to_rsync(rsync_includes=None):
DEFAULT_RSYNC_OPTS = [
'-a',
'--checksum',
'--out-format=%o %n%L',
'--out-format=%i %o %n%L', # see comment below
Copy link
Member

@oliver-sanders oliver-sanders Mar 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to include %i in the logs?

  • If this is only really relevant to the dry-run functionality, then continue to override the CLI argument as we did before (no need to change here).
  • If we think we should have this in the logs, then to keep them readable it might be better to keep the operation at the start of the line?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rsync output isn't included in the reinstall logs. The only thing we do with the rsync output is print it to stdout in the dry-run case.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is, install a workflow, make changes, then check ~/cylc-run/<workflow>/log/install/*.

Copy link
Member Author

@MetRonnie MetRonnie Mar 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah ok - it's only included in the 01-install.log. So I should make this option with %i only apply to reinstall. But it is not included in the reinstall logs regardless.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is wrong :( small
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants