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

transaction.run() doesn't raise an error if it fails because of not enough disk space #1074

Closed
bcl opened this issue Dec 7, 2023 · 4 comments
Assignees
Labels
Priority: MEDIUM Triaged Someone on the DNF 5 team has read the issue and determined the next steps to take

Comments

@bcl
Copy link

bcl commented Dec 7, 2023

I ran into this while checking the dnf5 branch of lorax against Fedora 40 in a VM without enough disk space. I'm using python3-libdnf5-5.1.8-1.fc40.x86_64.

If there isn't enough space to download the rpms it will raise an error as expected.
But if there is enough for the download, but not enough to install them, transaction.run() returns without raising an error. I also checked transaction.get_problems() and it doesn't indicate a problem.

@jan-kolarik
Copy link
Member

Hi, I was checking the situation compared to the dnf4 and it seems we are not setting the RPMPROB_FILTER_DISKSPACE filter to get those problems from the RPM transaction run in libdnf5::rpm::Transaction::run().

@jan-kolarik jan-kolarik added Triaged Someone on the DNF 5 team has read the issue and determined the next steps to take Priority: MEDIUM labels Dec 12, 2023
@m-blaha m-blaha self-assigned this Dec 12, 2023
@m-blaha
Copy link
Member

m-blaha commented Dec 13, 2023

I did some testing and here's what I've found:

  • The transaction.get_problems() doesn't have the best name. It's actually a bit misleading since it only returns problems found during resolving. And it doesn't return a list of problems, just flags indicating the types of problems encountered (like package not found, package excluded, etc.). To get the actual resolving problems, you need to use the transaction.get_resolve_logs_as_strings() or transaction.get_resolve_logs() functions.
  • In case of insufficient disk space, transaction.run() returns the value 5, which corresponds to the Transaction::TransactionRunResult::ERROR_RPM_RUN enum value. Unfortunately, this enum class is not exported to Python bindings. (Export Transaction::TransactionRunResult::ERROR_RPM_RUN enum class to Python bindings #1095)
  • To get more info about RPM transaction problems, there's the transaction.get_transaction_problems() method. It returns a vector of strings that's similar to what dnf5 would print on the command line. For example:
    [
    'installing package glibc-2.37-14.fc38.x86_64 needs 2MB more space on the / filesystem',
    'installing package acpi-1.7-20.fc38.x86_64 needs 2MB more space on the / filesystem'
    ]

@m-blaha
Copy link
Member

m-blaha commented Dec 18, 2023

Sorry for the confusion. The required TransactionRunResult enum class is indeed exported to python. To handle errors during transaction run (including not enough disk space) you need to do something like:

run_result = transaction.run()
if run_result != libdnf5.base.Transaction.TransactionRunResult_SUCCESS:
    for problem in transaction.get_transaction_problems():
        print(problem)

bcl added a commit to bcl/lorax that referenced this issue Dec 18, 2023
Thanks to the discussion in
rpm-software-management/dnf5#1074 lorax will
now correctly log installation size errors like:

The transaction process has ended abruptly:
installing package llvm-libs-17.0.6-2.fc40.x86_64 needs 107MB more space on the / filesystem
installing package libXv-1.0.12-1.fc40.x86_64 needs 107MB more space on the / filesystem
installing package libXcomposite-0.4.6-1.fc40.x86_64 needs 107MB more space on the / filesystem
@bcl
Copy link
Author

bcl commented Dec 18, 2023

Thanks, that works great!

@bcl bcl closed this as completed Dec 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority: MEDIUM Triaged Someone on the DNF 5 team has read the issue and determined the next steps to take
Projects
Archived in project
Development

No branches or pull requests

3 participants