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

ENT-12511: Now cf-net get no longer unlinks original file #5666

Merged
merged 2 commits into from
Dec 20, 2024

Conversation

larsewi
Copy link
Contributor

@larsewi larsewi commented Dec 18, 2024

The command cf-net get <FILENAME> now writes to <FILENAME>.cfnew
followed by replacing <FILENAME> with <FILENAME>.cfnew. Previously
it would unlink and re-create the original file.

With the new "filestream" protocol, we need the original file in order
to compute its signature, so that we can save bandwidth using the RSYNC
protocol. Furthermore, unlinking the original file, causes a brief
moment when it either does not exist or is incomplete. This can be
problematic if other processes depend on it.

Ticket: ENT-12511
Changelog: Title
Signed-off-by: Lars Erik Wik lars.erik.wik@northern.tech

Build Status together with NorthernTechHQ/libntech#231

  • Manually tested on Windows Server 2019 & Ubuntu 24

The command `cf-net get <FILENAME>` now writes to `<FILENAME>.cfnew`
followed by replacing `<FILENAME>` with `<FILENAME>.cfnew`. Previously
it would unlink and re-create the original file.

With the new `"filestream"` protocol, we need the original file in order
to compute its signature, so that we can save bandwidth using the RSYNC
protocol. Furthermore, unlinking the original file, causes a brief
moment when it either does not exist or is incomplete. This can be
problematic if other processes depend on it.

Ticket: ENT-12511
Changelog: Title
Signed-off-by: Lars Erik Wik <lars.erik.wik@northern.tech>
@larsewi
Copy link
Contributor Author

larsewi commented Dec 18, 2024

@cf-bottom Jenkins please :)

@cf-bottom
Copy link

@larsewi larsewi marked this pull request as ready for review December 18, 2024 16:19
The File Stream API now unlinks the destination file (i.e.,
`<FILENAME>.cfnew`) before opening it with the `O_EXCL` flag. Previously
the agent would fail if the destination file already exists.
Fortunately, the File Stream API unlinks this file afterwards, both on
success and error, causing the agent to recover. Both the `cf-net get
<FILENAME>` command and the `copy_from` attribute were affected.

Ticket: None
Changelog: Commit
Signed-off-by: Lars Erik Wik <lars.erik.wik@northern.tech>
Copy link
Contributor

@vpodzime vpodzime left a comment

Choose a reason for hiding this comment

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

Looks good to me either way.

}

if (!success)
{
unlink(local_path);
Log(LOG_LEVEL_VERBOSE, "Removing file '%s'...", dest);
Copy link
Contributor

Choose a reason for hiding this comment

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

These should be INFO, I think. The rule of thumb is that info: message inform the user about changes being made. (applies below as well)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not according to @olehermanse (see CFE-4470).

Copy link
Contributor

Choose a reason for hiding this comment

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

I have no problem with that. Let's just be consistent.

@larsewi larsewi merged commit e436c67 into cfengine:master Dec 20, 2024
43 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants