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

dnf5: Run transaction test for offline transactions #1672

Merged
merged 2 commits into from
Sep 17, 2024
Merged

Conversation

m-blaha
Copy link
Member

@m-blaha m-blaha commented Sep 3, 2024

A serialized offline transaction consists only of local packages
downloaded to the <system state dir>/offline location. Unfortunately,
PGP checks for these packages are disabled by default due to the
localpkg_gpgcheck option default value.
Instead of testing the serialized transaction, this patch performs an
RPM transaction test on the originally resolved transaction, which still
retains information about the repositories from which the packages were
downloaded.
This approach also saves time required for deserialization and resolving
the testing transaction.

Resolves: #1668
Resolves: #1667

Tests: rpm-software-management/ci-dnf-stack#1549

@m-blaha
Copy link
Member Author

m-blaha commented Sep 3, 2024

The original approach had one advantage that the exactly same transaction that would be performed after dnf offline reboot was tested. Do you think it makes sense to at least try to resolve the serialized transaction (although it takes a long time so we should properly inform the user on what's going on). @evan-goode @jan-kolarik

Copy link
Member

@evan-goode evan-goode left a comment

Choose a reason for hiding this comment

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

I'm fine with this, I tested upgrading F39->F40 and it works.

Do you think it makes sense to at least try to resolve the serialized transaction (although it takes a long time so we should properly inform the user on what's going on).

I think we can skip it. The main reason I implemented it this way was that it seemed to not be possible to test the (unserialized) offline transaction because the RPMs are all stored in the same directory. But that turned out to be due to a different bug.

Assuming the transaction serialization logic is reliable, testing the serialized transaction is unnecessary and costs time.

@@ -321,6 +321,27 @@ void Context::Impl::load_repos(bool load_system) {
}

void Context::Impl::store_offline(libdnf5::base::Transaction & transaction) {
// Test the transaction
Copy link
Contributor

Choose a reason for hiding this comment

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

Scenario:

  1. a new transaction is tested
  2. get_status() of the offline transaction status is tested - if there is already an offline transaction in the queue and an AbortedbyUserError exception is thrown, the tested transaction is discarded
  3. serialize the transaction under test

Can we change the order? Test new transaction only if get_status() test passes?

  1. get_status() of offline transaction status is tested
  2. a new transaction is tested
  3. serialize the transaction under test

Copy link
Member Author

Choose a reason for hiding this comment

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

That's a good point. Maybe we should do the status test even before downloading transaction packages.

Copy link
Member Author

Choose a reason for hiding this comment

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

I've added a commit with such optimization. Now the offline transaction status is checked before the download phase.

A serialized offline transaction consists only of local packages
downloaded to the `<system state dir>/offline` location. Unfortunately,
PGP checks for these packages are disabled by default due to the
`localpkg_gpgcheck` option default value.
Instead of testing the serialized transaction, this patch performs an
RPM transaction test on the originally resolved transaction, which still
retains information about the repositories from which the packages were
downloaded.
This approach also saves time required for deserialization and resolving
the testing transaction.
The transaction package download can be a lengthy and network intensive
operation. Begin the download only after the user confirms that the
previously scheduled offline transaction can be canceled.
@m-blaha
Copy link
Member Author

m-blaha commented Sep 16, 2024

Rebased due to the conflicts.

@jan-kolarik
Copy link
Member

Sorry for the late reply. I agree with Evan that if the serialization is reliable and well-covered by tests (if not, we should address that in a follow-up PR), there's no need for serialized transaction testing.

@pkratoch pkratoch self-assigned this Sep 17, 2024
@pkratoch pkratoch added this pull request to the merge queue Sep 17, 2024
Merged via the queue into main with commit a1a66ce Sep 17, 2024
8 of 20 checks passed
@pkratoch pkratoch deleted the mblaha/offline-pgp branch September 17, 2024 11:47
kontura added a commit to kontura/dnf5 that referenced this pull request Sep 20, 2024
A serialized offline transaction consists only of local packages
downloaded to the `<system state dir>/offline` location. Unfortunately,
PGP checks for these packages are disabled by default due to the
`localpkg_gpgcheck` option default value.
Instead of testing the serialized transaction, this patch performs an
RPM transaction test on the originally resolved transaction, which still
retains information about the repositories from which the packages were
downloaded.
This approach also saves time required for deserialization and resolving
the testing transaction.

This ports the fix from rpm-software-management#1672
to dnf5daemon.
github-merge-queue bot pushed a commit that referenced this pull request Sep 20, 2024
A serialized offline transaction consists only of local packages
downloaded to the `<system state dir>/offline` location. Unfortunately,
PGP checks for these packages are disabled by default due to the
`localpkg_gpgcheck` option default value.
Instead of testing the serialized transaction, this patch performs an
RPM transaction test on the originally resolved transaction, which still
retains information about the repositories from which the packages were
downloaded.
This approach also saves time required for deserialization and resolving
the testing transaction.

This ports the fix from #1672
to dnf5daemon.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants