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-12414: Use librsync's Stream API in GET <FILENAME> requests #5629

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

larsewi
Copy link
Contributor

@larsewi larsewi commented Nov 19, 2024

  • Added file stream API
  • New network protocol version v4 - filestream

TODO:

Build Status

@larsewi larsewi force-pushed the librsync branch 7 times, most recently from c29dfd8 to 937589a Compare November 20, 2024 12:43
cf-serverd/server_common.c Fixed Show fixed Hide fixed
cf-serverd/server_common.c Fixed Show fixed Hide fixed
cf-serverd/server_common.c Fixed Show fixed Hide fixed
cf-serverd/server_common.c Fixed Show fixed Hide fixed
libcfnet/client_code.c Fixed Show fixed Hide fixed
libcfnet/client_code.c Fixed Show fixed Hide fixed
libcfnet/client_code.c Fixed Show fixed Hide fixed
libcfnet/file_stream.c Fixed Show fixed Hide fixed
libcfnet/file_stream.c Fixed Show fixed Hide fixed
@larsewi larsewi force-pushed the librsync branch 8 times, most recently from 37a8af2 to 9cb3c14 Compare November 28, 2024 13:53
@larsewi larsewi marked this pull request as ready for review November 28, 2024 13:54
@larsewi larsewi force-pushed the librsync branch 3 times, most recently from fafd971 to af5bd02 Compare November 29, 2024 10:51
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 otherwise. Very nice! Thanks for taking the hard road! 👏 🍻 I'm very excited about this!

libcfnet/file_stream.c Outdated Show resolved Hide resolved
libcfnet/file_stream.c Outdated Show resolved Hide resolved
libcfnet/file_stream.c Show resolved Hide resolved
libcfnet/file_stream.c Outdated Show resolved Hide resolved
libcfnet/file_stream.c Show resolved Hide resolved
libcfnet/file_stream.c Show resolved Hide resolved
libcfnet/file_stream.c Outdated Show resolved Hide resolved
libcfnet/file_stream.c Outdated Show resolved Hide resolved
libcfnet/file_stream.c Outdated Show resolved Hide resolved
libcfnet/file_stream.c Outdated Show resolved Hide resolved
@larsewi larsewi force-pushed the librsync branch 3 times, most recently from b627503 to 2e808ed Compare December 2, 2024 09:10
vpodzime
vpodzime previously approved these changes Dec 2, 2024
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.

Let's see if it works! 😁 🤞 🍻

Copy link
Contributor

@craigcomstock craigcomstock left a comment

Choose a reason for hiding this comment

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

Some comments and little typos.

configure.ac Outdated Show resolved Hide resolved
libcfnet/README.md Outdated Show resolved Hide resolved
libcfnet/README.md Outdated Show resolved Hide resolved
libcfnet/README.md Outdated Show resolved Hide resolved
libcfnet/file_stream.c Outdated Show resolved Hide resolved
/* librsync has rs_file_size() which basically does the same thing.
* However, it is only available in the most recent versions of the
* library. Hence, we provide our own implementation in order to have
* some backwards compatibility in terms of librsync versions. */
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you be specific here about the version in which rs_file_size() was added?

Are there any minimum version notes in INSTALL and configure.ac that prevent problems with the code as-is?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added some more info in the comment. When it comes to minimum version checks, it does not seem like we have this for any of the other dependencies. If you think we should have these checks, then we should probably make a separate ticket for this.

libcfnet/file_stream.c Outdated Show resolved Hide resolved
libcfnet/file_stream.c Outdated Show resolved Hide resolved
libcfnet/file_stream.c Outdated Show resolved Hide resolved
libcfnet/file_stream.h Outdated Show resolved Hide resolved
@larsewi larsewi force-pushed the librsync branch 5 times, most recently from f728290 to 8ad0742 Compare December 5, 2024 14:32
vpodzime
vpodzime previously approved these changes Dec 6, 2024
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.

ACK

craigcomstock
craigcomstock previously approved these changes Dec 6, 2024
@larsewi
Copy link
Contributor Author

larsewi commented Dec 9, 2024

Just tested this manually on Windows and it works like a charm.

PS C:\Program Files\Cfengine\bin> .\cf-agent.exe -KI
    info: Copied file '/var/cfengine/masterfiles/promises.cf' from '172.31.39.27' to 'C:\promises.cf.cfnew'
    info: Moved 'C:\promises.cf.cfnew' to 'C:\promises.cf'
    info: Updated file 'C:\promises.cf' from '172.31.39.27:/var/cfengine/masterfiles/promises.cf'

Did however find a separate (surprisingly unrelated) issue in cf-net.exe (see ENT-12511)

.github/workflows/acceptance_tests.yml Show resolved Hide resolved
libcfnet/Makefile.am Outdated Show resolved Hide resolved
libcfnet/file_stream.c Show resolved Hide resolved
larsewi and others added 7 commits December 11, 2024 13:18
This commit was added while working on implementing the File Stream API
in ticket ENT-12414. The File Stream API utilizes librsync.  To begin
with I had `AC_CHECK_HEADERS([librsync_export.h], [],
AC_MSG_ERROR(Cannot find librsync))` in configure.ac. This file did not
exist in earlier versions of librync. Hence, I upgraded the Ubuntu
platforms in GitHub CI to make configure work. Later a realized that I
should remove that line enirely to make CFEngine compatible with earlier
versions. However, it does not hurt to upgrade the Ubuntu platforms, so
decided on keeping this commit.

Ticket: None
Changelog: None
Signed-off-by: Lars Erik Wik <[email protected]>
After upgrading GitHub CI platorms to Ubuntu 24, the ASAN Unit Tests
started complaining about One Definition Rule (ODR) violations. Hence, I
disabled ODR and created a follow-up ticket (see CFE-4454) to fix the
violations and enable ODR again.

Ticket: None
Changelog: None
Signed-off-by: Lars Erik Wik <[email protected]>
Ticket: ENT-12414
Changelog: None
Signed-off-by: Lars Erik Wik <[email protected]>
Added API for streaming file contents over the network using the RSYNC
algorithm from librsync.

Ticket: ENT-12414
Changelog: None
Signed-off-by: Lars Erik Wik <[email protected]>
Co-authored-by: Craig Comstock <[email protected]>
Ticket: ENT-12414
Changelog: Title
Signed-off-by: Lars Erik Wik <[email protected]>
Co-authored-by: Craig Comstock <[email protected]>
The implementation is based on the previous protocol for `GET
<FILENAME>` requests that used sparse files.

Ticket: ENT-12414
Changelog: Title
Signed-off-by: Lars Erik Wik <[email protected]>
Apparently there are functions called `SendMessage()` and
`GetFileSize()` in the Win32 API. I fixed these name conflicts by adding
a `Protocol` prefix to all functions related to the simple network
protocol for file stream communication. Furthermore, I changed the name
of `GetFileSize()` to `GetSizeOfFile()`.

Ticket: ENT-12414
Changelog: None
Signed-off-by: Lars Erik Wik <[email protected]>
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.

4 participants