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

Add transaction.test() #251

Merged
merged 1 commit into from
Feb 13, 2023

Conversation

evan-goode
Copy link
Member

Allows dry running a transaction using RPMTRANS_FLAG_TEST by calling transaction.verify(), regardless of what tsflags are set on the base config. So you could run:

    libdnf::Goal goal(base);
    auto transaction = goal.resolve();
    auto result = transaction.verify()
    // check result of verification, possibly change the transaction

    transaction.run(...)

without creating a whole new base with the RPMTRANS_FLAG_TEST flag set.

Example use case: https://bugzilla.redhat.com/show_bug.cgi?id=2109660

@pmatilai
Copy link
Member

Please call it "test" or "dry-run" such, but not "verify". Verify is already overloaded as a term (in rpm context) and we do not need more confusion in that area.

@glum23
Copy link
Contributor

glum23 commented Jan 26, 2023

I'd say when this PR will be merged, execute_transaction function from dnf-behave-tests/dnf/steps/cmd.py should be updated.

@evan-goode evan-goode changed the title Add transaction.verify() Add transaction.test() Jan 26, 2023
@evan-goode
Copy link
Member Author

Changed to transaction.test().

evan-goode added a commit to evan-goode/ci-dnf-stack that referenced this pull request Feb 3, 2023
@evan-goode evan-goode marked this pull request as ready for review February 3, 2023 22:26
evan-goode added a commit to evan-goode/ci-dnf-stack that referenced this pull request Feb 7, 2023
@j-mracek
Copy link
Contributor

j-mracek commented Feb 9, 2023

@evan-goode May I ask you to resolve the merge conflicts?

@evan-goode
Copy link
Member Author

Done.

@j-mracek j-mracek self-assigned this Feb 10, 2023
@@ -81,6 +81,12 @@ class Transaction {
/// @return the transaction groups.
std::vector<libdnf::base::TransactionGroup> & get_transaction_groups() const;

/// Check the transaction by running it with RPMTRANS_FLAG_TEST. This check
/// is performed automatically by run(); it is redundant to call test()
/// before calling run().
Copy link
Contributor

Choose a reason for hiding this comment

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

There is one thing that deserves to be documented - import of GPG keys. If I am correct - test in DNF5 and in DNF also imports GPG keys. It is let say incorrect - test is not supposed to do permanent changes. On the other hand - we need that behavior for workflow in system upgrade and offline upgrades.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks, it's a good idea to make that explicit. Is the language correct here?

/// Check the transaction by running it with RPMTRANS_FLAG_TEST. Packages
/// will be downloaded, public keys will be installed, and transaction
/// checks will be performed, but no changes to the package set will be
/// made. These checks are performed automatically by run(); it is
/// redundant to call test() before calling run().

Copy link
Contributor

Choose a reason for hiding this comment

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

I believe that this is incorrect - Packages will be downloaded. The method does not download packages.

Copy link
Contributor

Choose a reason for hiding this comment

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

About public keys will be installed - this is not wrong, but it performs complex tasks related to signed rpm keys verification. First of all - the test of keys is only applied when configuration requires it. The workflow - it tries to verify signature using already imported keys in rpm-db. If it fails then it downloads keys, request approval for import (callback), than it imports keys and request the verification of the RPM signature.
install vs. import keys into RPM DB - I somehow do not prefer install.

Copy link
Contributor

@j-mracek j-mracek Feb 13, 2023

Choose a reason for hiding this comment

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

to the package set - what about to add installed in the statement - to the installed package set`.

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 believe that this is incorrect - Packages will be downloaded. The method does not download packages.

Thanks, yes of course, oops!

About public keys will be installed - this is not wrong...

Changed to "the import of any necessary public keys will be requested".

to the package set - what about to add installed in the statement - to the installed package set`.

Done.

@evan-goode evan-goode force-pushed the evan-goode/verify branch 2 times, most recently from 3a28716 to a34e6eb Compare February 13, 2023 14:49
Allows dry running a transaction using RPMTRANS_FLAG_TEST by calling
transaction.test(), regardless of what tsflags are set on the base
config. So you could run:

    libdnf::Goal goal(base);
    auto transaction = goal.resolve();
    auto result = transaction.test()
    // check result of test, possibly change the transaction

    transaction.run(...)

without creating a whole new `base` with the RPMTRANS_FLAG_TEST flag
set.
@j-mracek
Copy link
Contributor

LGTM

@j-mracek j-mracek merged commit b1d47d5 into rpm-software-management:main Feb 13, 2023
evan-goode added a commit to evan-goode/ci-dnf-stack that referenced this pull request Feb 17, 2023
evan-goode added a commit to evan-goode/ci-dnf-stack that referenced this pull request Feb 20, 2023
Requires rpm-software-management/dnf5#251

Signed-off-by: Evan Goode <mail@evangoo.de>
kontura pushed a commit to rpm-software-management/ci-dnf-stack that referenced this pull request Feb 21, 2023
Requires rpm-software-management/dnf5#251

Signed-off-by: Evan Goode <mail@evangoo.de>
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.

5 participants