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

dnf always fails when used with ostree based systems instead of warning. #2108

Closed
m2Giles opened this issue Jul 9, 2024 · 11 comments · Fixed by #2121
Closed

dnf always fails when used with ostree based systems instead of warning. #2108

m2Giles opened this issue Jul 9, 2024 · 11 comments · Fixed by #2121

Comments

@m2Giles
Copy link

m2Giles commented Jul 9, 2024

#2053 has landed in Fedora 40.

This ends up breaking dnf completely when being used in a CI pipeline with an ostree system. We currently use dnf for building akmods in CI.

Note, that it says it should warn a user but exits with an operation aborted. From the docstring it does not sound like the intended behavior?

@bsherman
Copy link

bsherman commented Jul 9, 2024

Adding some detail...

It looks like the CliError causes the command to return a non-zero exit status, which breaks akmods when run on ostree systems.

An akmods log snippet for quick reference:

2024/07/09 03:39:32 akmodsbuild: + exit 0
2024/07/09 03:39:32 akmods: Installing newly built rpms
2024/07/09 03:39:32 akmods: DNF detected
Dependencies resolved.
================================================================================
 Package                           Arch   Version            Repository    Size
================================================================================
Installing:
 kmod-nvidia-6.8.11-300.fc40.x86_64
                                   x86_64 3:555.58.02-1.fc40 @commandline  41 M

Transaction Summary
================================================================================
Install  1 Package

Total size: 41 M
Installed size: 41 M

*** This system is managed with ostree.  Changes to the system
*** made with dnf will be lost with the next ostree-based update.
*** If you do not want to lose these changes, use 'rpm-ostree'.

Operation aborted.
2024/07/09 03:39:32 akmods: Could not install newly built RPMs. You can find them and the logfile in:
2024/07/09 03:39:32 akmods: /var/cache/akmods/nvidia/555.58.02-1-for-6.8.11-300.fc40.x86_64.failed.log
+ exit 1

@ppisar
Copy link
Contributor

ppisar commented Jul 10, 2024

@dcantrell, can you explain whether your commit intended an error or just a warning? If it were an error, how should users override the error to perform a temporary change which will be lost on next ostree-based update?

@dcantrell
Copy link
Contributor

Initially it was supposed to be an error, but now consensus is that it should be a warning. I also need to update is_container() based on changes that came along later. I will get a patch for this so it is fixed up.

@YaLTeR
Copy link

YaLTeR commented Jul 17, 2024

Is there really no way to disable this for now? It completely breaks the workflow of temporarily installing packages with dnf for development/testing into a sudo ostree admin unlocked system (knowing and intending for all changes to be rolled back on reboot).

@travier
Copy link

travier commented Jul 17, 2024

We have #2110 in progress

@jmarrero
Copy link
Contributor

Is the idea that even if we stop the operation on read-only systems we should exit with 0?

@jmarrero
Copy link
Contributor

jmarrero commented Jul 18, 2024

To be clear these reports seem to me like they are all happening in CI using a ostree/bootc container or with ostree admin unlock. If so the patch in #2110 should fix this without needing to change the exit code and message to a warning. When we find a bootc host we will exit with an error. However when running on a container or on a unlocked system, dnf should run just like before because it is not a bootc host at that point it's just another container running a build. On a read-only system dnf never has been able to modify the system, so the exit code 1 in that case makes sense to me.

@mripard
Copy link

mripard commented Aug 2, 2024

I'm also affected by this. I was using dnf with --installroot as a debootstrap-ish tool, so the system installed was never affecting the "host" system.

I'm not sure how to fix it properly, but maybe looking at whether we affect the ostree system or not would work (like, anything under /mnt or /media would work, but /usr obviously wouldn't).

@ppisar
Copy link
Contributor

ppisar commented Aug 5, 2024

We could change the check to take --installroot path into account:

  • Either by requiring --installroot to be /, like this:
    os.path.isfile('/run/ostree-booted') and not os.access('/usr/', os.W_OK) and conf._get_value('installroot') == '/'
  • or by extending the check with a writeability check for non-root --installroot path, like this:
    os.path.isfile('/run/ostree-booted') and not os.access('/usr/', os.W_OK) and (conf._get_value('installroot') == '/' or not os.access(conf._get_value('installroot'), os.W_OK))

I would probably place the extending conditions out of _is_bootc_host() function, or wrap the function into a new _is_bootc_installroot() function.

Another approach would be adding new tri-state option, e.g. --image-mode={true,false,auto}, defaulting to auto being equivalent to the current behavior. False would force DNF to this-is-not-a-read-only-OSTree system, while True the opposite. User would get a way to override the detection.

@ppisar
Copy link
Contributor

ppisar commented Aug 15, 2024

Bootc people, Is root filesystem (/) never writable on bootc systems? I'm deliberating whether it is necessary to check that installroot differs from /.

Currently bootc system has / read-only even if usr-overlay is writable. That of course does not play well when installing packages that write out of /usr.

ppisar added a commit to ppisar/dnf that referenced this issue Aug 15, 2024
Some people use --installroot on a read-only bootc system to install
a system into a chroot subtree. However, current bootc check did not
take into account --installroot and rejected the operation.

This patch augments the check for a writable installroot being
different from /.

The comparison for / is there to deal with bootc systems with
a writeable /. Currently it's uncerain whether systems like that
exist.

Resolves: rpm-software-management#2108
ppisar added a commit to ppisar/dnf that referenced this issue Aug 15, 2024
Some people use --installroot on a read-only bootc system to install
a system into a chroot subtree. However, current bootc check did not
take into account --installroot and rejected the operation.

This patch augments the check for a writable installroot being
different from /.

The comparison for / is there to deal with bootc systems with
a writeable /. Currently it's uncerain whether systems like that
exist.

Resolves: rpm-software-management#2108
@ppisar
Copy link
Contributor

ppisar commented Aug 15, 2024

@mripard and others using --installroot, I developed a fix in #2121. Any comments and testing are appreciated.

ppisar added a commit to ppisar/dnf that referenced this issue Aug 22, 2024
Some people use --installroot on a read-only bootc system to install
a system into a chroot subtree. However, current bootc check did not
take into account --installroot and rejected the operation.

This patch augments the check for the installroot being different
from /.

It's pointless to check for installroot writability here because
installroot is written before this check when updating the
repositories and computing a transaction. Moving this check sooner
would not help because some directories (/opt, /) are kept read-only
even on writable bootc.

Resolves: rpm-software-management#2108
@github-project-automation github-project-automation bot moved this from Backlog to Done in DNF team Aug 22, 2024
ppisar added a commit to ppisar/dnf that referenced this issue Aug 28, 2024
Upstream commit: a1aa8d0

Some people use --installroot on a read-only bootc system to install
a system into a chroot subtree. However, current bootc check did not
take into account --installroot and rejected the operation.

This patch augments the check for the installroot being different
from /.

It's pointless to check for installroot writability here because
installroot is written before this check when updating the
repositories and computing a transaction. Moving this check sooner
would not help because some directories (/opt, /) are kept read-only
even on writable bootc.

Resolves: rpm-software-management#2108
Resolves: https://issues.redhat.com/browse/RHEL-49670
ppisar added a commit to ppisar/dnf that referenced this issue Aug 28, 2024
Upstream commit: a1aa8d0

Some people use --installroot on a read-only bootc system to install
a system into a chroot subtree. However, current bootc check did not
take into account --installroot and rejected the operation.

This patch augments the check for the installroot being different
from /.

It's pointless to check for installroot writability here because
installroot is written before this check when updating the
repositories and computing a transaction. Moving this check sooner
would not help because some directories (/opt, /) are kept read-only
even on writable bootc.

Resolves: rpm-software-management#2108
Resolves: https://issues.redhat.com/browse/RHEL-49670
ppisar added a commit to ppisar/dnf that referenced this issue Aug 28, 2024
Upstream commit: a1aa8d0

Some people use --installroot on a read-only bootc system to install
a system into a chroot subtree. However, current bootc check did not
take into account --installroot and rejected the operation.

This patch augments the check for the installroot being different
from /.

It's pointless to check for installroot writability here because
installroot is written before this check when updating the
repositories and computing a transaction. Moving this check sooner
would not help because some directories (/opt, /) are kept read-only
even on writable bootc.

Resolves: rpm-software-management#2108
Resolves: https://issues.redhat.com/browse/RHEL-49670
ppisar added a commit to ppisar/dnf that referenced this issue Aug 28, 2024
Upstream commit: a1aa8d0

Some people use --installroot on a read-only bootc system to install
a system into a chroot subtree. However, current bootc check did not
take into account --installroot and rejected the operation.

This patch augments the check for the installroot being different
from /.

It's pointless to check for installroot writability here because
installroot is written before this check when updating the
repositories and computing a transaction. Moving this check sooner
would not help because some directories (/opt, /) are kept read-only
even on writable bootc.

Resolves: rpm-software-management#2108
Resolves: https://issues.redhat.com/browse/RHEL-49670
ppisar added a commit to ppisar/dnf that referenced this issue Aug 28, 2024
Upstream commit: a1aa8d0

Some people use --installroot on a read-only bootc system to install
a system into a chroot subtree. However, current bootc check did not
take into account --installroot and rejected the operation.

This patch augments the check for the installroot being different
from /.

It's pointless to check for installroot writability here because
installroot is written before this check when updating the
repositories and computing a transaction. Moving this check sooner
would not help because some directories (/opt, /) are kept read-only
even on writable bootc.

Resolves: rpm-software-management#2108
Resolves: https://issues.redhat.com/browse/RHEL-49670
ppisar added a commit to ppisar/dnf that referenced this issue Sep 20, 2024
Upstream commit: a1aa8d0

Some people use --installroot on a read-only bootc system to install
a system into a chroot subtree. However, current bootc check did not
take into account --installroot and rejected the operation.

This patch augments the check for the installroot being different
from /.

It's pointless to check for installroot writability here because
installroot is written before this check when updating the
repositories and computing a transaction. Moving this check sooner
would not help because some directories (/opt, /) are kept read-only
even on writable bootc.

Resolves: rpm-software-management#2108
Resolves: https://issues.redhat.com/browse/RHEL-49671
ppisar added a commit to ppisar/dnf that referenced this issue Sep 20, 2024
Upstream commit: a1aa8d0

Some people use --installroot on a read-only bootc system to install
a system into a chroot subtree. However, current bootc check did not
take into account --installroot and rejected the operation.

This patch augments the check for the installroot being different
from /.

It's pointless to check for installroot writability here because
installroot is written before this check when updating the
repositories and computing a transaction. Moving this check sooner
would not help because some directories (/opt, /) are kept read-only
even on writable bootc.

Resolves: rpm-software-management#2108
Resolves: https://issues.redhat.com/browse/RHEL-49671
kontura pushed a commit that referenced this issue Sep 24, 2024
Upstream commit: a1aa8d0

Some people use --installroot on a read-only bootc system to install
a system into a chroot subtree. However, current bootc check did not
take into account --installroot and rejected the operation.

This patch augments the check for the installroot being different
from /.

It's pointless to check for installroot writability here because
installroot is written before this check when updating the
repositories and computing a transaction. Moving this check sooner
would not help because some directories (/opt, /) are kept read-only
even on writable bootc.

Resolves: #2108
Resolves: https://issues.redhat.com/browse/RHEL-49670
kontura pushed a commit that referenced this issue Sep 24, 2024
Upstream commit: a1aa8d0

Some people use --installroot on a read-only bootc system to install
a system into a chroot subtree. However, current bootc check did not
take into account --installroot and rejected the operation.

This patch augments the check for the installroot being different
from /.

It's pointless to check for installroot writability here because
installroot is written before this check when updating the
repositories and computing a transaction. Moving this check sooner
would not help because some directories (/opt, /) are kept read-only
even on writable bootc.

Resolves: #2108
Resolves: https://issues.redhat.com/browse/RHEL-49671
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

8 participants