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

Make dnf5 compatible with sdbus-cpp version 2 #1888

Merged
merged 9 commits into from
Feb 6, 2025
Merged

Conversation

m-blaha
Copy link
Member

@m-blaha m-blaha commented Nov 22, 2024

The new and incompatible version of sdbus-cpp library has been released upstream.
I'd like to upgrade also version in Fedora rawhide, but to not break dnf5
building we fist need to adjust it.
This patch makes dnf5 buildable with both sdbus-cpp versions.

Conan-Kudo
Conan-Kudo previously approved these changes Dec 8, 2024
Copy link
Member

@Conan-Kudo Conan-Kudo left a comment

Choose a reason for hiding this comment

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

This fixed compiling against sdbus-cpp v2 in openSUSE Tumblweed.

@kontura kontura self-assigned this Dec 16, 2024
Copy link
Contributor

@kontura kontura left a comment

Choose a reason for hiding this comment

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

This looks reasonable to me but the dnf5daemon CI tests fail, I have verified that also locally.
I didn't investigate it further but the error is: [System.Error.ENXIO] Failed to enter a variant (No such device or address) when sdbus-cpp < 2.

With sdbus-cpp >= 2 (I used your build from https://copr.fedorainfracloud.org/coprs/mblaha/dnf5-sdbus-cpp-2/) I am getting some [org.rpm.dnf.v0.rpm.Rpm.TransactionError] rpm transaction failed with code 6.

@@ -0,0 +1,11 @@

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we could drop this new line.

Comment on lines -76 to +105
"org.freedesktop.DBus", "NameOwnerChanged", [this](sdbus::Signal signal) -> void {
SDBUS_INTERFACE_NAME_TYPE{"org.freedesktop.DBus"},
SDBUS_SIGNAL_NAME_TYPE{"NameOwnerChanged"},
[this](sdbus::Signal signal) -> void {
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess this is in the wrong commit, but it doesn't matter all that much.

Also set SDBUS_CPP_VERSION_2 macro in case sdbus-c++ was found in
version 2. This enables conditional compilation according the version of
the library found.
- Use InterfaceName type instead of char * for interface names
- Use SignalName type instead of char * for signal names
- Use ServiceName instead of char * for bus names
- Use Error::Name type instead of char * for errors
In version 2 the sdbus::Variant constuctor was made explicit.
In version 2, conversion of sdbus::Variant to the underlying type is
explicit.
sdbus-cpp version 2 requires signal handler to have signature
(sdbus::Signal signal) -> void, which is also acceptable for version 1.
sdbus-cpp-2 uses different approach to registering methods and signals
on the interface.
@m-blaha
Copy link
Member Author

m-blaha commented Dec 20, 2024

This looks reasonable to me but the dnf5daemon CI tests fail, I have verified that also locally. I didn't investigate it further but the error is: [System.Error.ENXIO] Failed to enter a variant (No such device or address) when sdbus-cpp < 2.

With sdbus-cpp >= 2 (I used your build from https://copr.fedorainfracloud.org/coprs/mblaha/dnf5-sdbus-cpp-2/) I am getting some [org.rpm.dnf.v0.rpm.Rpm.TransactionError] rpm transaction failed with code 6.

Thanks, the [System.Error.ENXIO] Failed to enter a variant (No such device or address) when sdbus-cpp < 2 issue should be resolved.

Still working on coredumps with sdbus-cpp version 2. Let me convert this back to draft until the issues are investigated and resolved.

@m-blaha m-blaha marked this pull request as draft December 20, 2024 10:28
Exit the event loop and properly join the serving thread.
To address race conditions between the lifetime of the context and
callbacks, it is safer to manage them separately.

With sdbus-cpp version 2, I observed various failures in
dnf5daemon-client, typically following this pattern:

- The main thread has already completed its work and is in the process
  of destructing the Context class.

- Meanwhile, the D-Bus event loop thread is still handling messages, and
  the handler attempts to access the context instance that is currently
  being destroyed.
@m-blaha m-blaha force-pushed the mblaha/sdbus-cpp-2 branch from 45934c7 to 80c6e46 Compare January 7, 2025 09:13
@Conan-Kudo Conan-Kudo self-requested a review January 31, 2025 12:47
@jonathanspw
Copy link

Is this PR ready or should it remain a draft?

@m-blaha
Copy link
Member Author

m-blaha commented Jan 31, 2025

Oh, sorry, I forget to switch it back.

@m-blaha m-blaha marked this pull request as ready for review January 31, 2025 13:19
@kontura
Copy link
Contributor

kontura commented Feb 5, 2025

I am still getting some crashes with sdbus-cpp > 2.
Specifically it crashes and the CI hangs for me in:

distro-sync.feature: Scenario: updating a signed pkg
gpg-noeol.feature: Scenario: Install signed package from repository
gpg.feature: Scenario Outline: Install <offline> masterkey signed package and check GPG key was imported
gpg.feature: Scenario Outline: Install <offline> subkey signed package with masterkey signed dependency

It seems like some problem with signing.

Plus I am getting some crashes that result in failing tests in:

dnf/clean-cachefiles.feature
dnf/gpg.feature
dnf/install-path.feature
dnf/install-provides.feature
dnf/upgrade-dependent.feature

However since @m-blaha is the maintainer of sdbus-cpp in fedora I am thinking about merging this anyway. Perhaps fixing the crashes will be easier when we don't have to deal with so many patches?

@m-blaha
Copy link
Member Author

m-blaha commented Feb 5, 2025

Hmm, maybe. The crashes (at least those I'm aware of) were all related to the client side of tha dnf5daemon. The server seems to work correctly.

@Conan-Kudo Conan-Kudo self-assigned this Feb 5, 2025
@kontura
Copy link
Contributor

kontura commented Feb 6, 2025

The crashes (at least those I'm aware of) were all related to the client side of tha dnf5daemon.

I see, so is the plan to fix those in subsequent PR?

The server seems to work correctly.

My bad, I didn't check why it hangs properly, the server indeed doesn't crash.
For me it gets stuck here: https://github.com/rpm-software-management/dnf5/blob/main/dnf5daemon-server/session.cpp#L193 (presumably it would timed out after 5 min).
As far as I can tell the key_import callback is never called in the client.

@m-blaha
Copy link
Member Author

m-blaha commented Feb 6, 2025

I've already tried to fix them, but apparently the issues are still there. As our testing uses the dnf5daemon-client, we need to fix them before the sdbus-cpp upgrade.

@kontura kontura added this pull request to the merge queue Feb 6, 2025
Merged via the queue into main with commit 4eb8ef2 Feb 6, 2025
17 checks passed
@kontura kontura deleted the mblaha/sdbus-cpp-2 branch February 6, 2025 10:48
@m-blaha
Copy link
Member Author

m-blaha commented Feb 6, 2025

Created a specialized tracking issue for fixing dnf5daemon-client with sdbus-cpp 2: #2040

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants