coreos/rpm-ostree

Rebase to container image failed (with local package installed)

HuijingHei opened this issue · 2 comments

Describe the bug

Install local rpm foo-1.2-3.x86_64.rpm, then export the current commit to container image, then rebase to it failed with error: Package 'foo-1.2-3.x86_64' is already in the base

Reproduction steps

  1. Start fedora-coreos
    [coreos-assembler]$ cosa run --qemu-image ../data/fedora-coreos-40.20240123.91.0-qemu.x86_64.qcow2 -m 4096 --bind-ro /usr/lib/coreos-assembler/tests/kola/rpm-ostree/upgrades/,/run/workdir
  2. Install local rpm
[root@cosa-devsh ~]# cp /run/workdir/data/rpm-repos/0/packages/x86_64/foo-1.2-3.x86_64.rpm .
[root@cosa-devsh ~]# rpm-ostree install foo-1.2-3.x86_64.rpm
Added:
  foo-1.2-3.x86_64
Changes queued for next boot. Run "systemctl reboot" to start a reboot

[root@cosa-devsh ~]# ostree admin status
  fedora-coreos 6ee463a6c4af929a9f5ba044b3d332fe9f7c9fff87ea8f3619c2e0273406b89f.0 (staged)
    origin: <unknown origin type>
* fedora-coreos 6ec195d018868a8a02f585356a4b65112e6a37ac3e810a8165e6608db1919821.0
    origin: <unknown origin type>

  1. Export the current commit to container image, then rebase to it
[root@cosa-devsh ~]# ostree container encapsulate --repo=/ostree/repo $(rpm-ostree status --json | jq -r '.deployments[0].checksum') containers-storage:localhost/test && rpm-ostree rebase ostree-unverified-image:containers-storage:localhost/test
sha256:b7a5470d2e81e1d58509fc7d98d91fe73931714a83981cd4892cfb4322560811
Pulling manifest: ostree-unverified-image:containers-storage:localhost/test
Importing: ostree-unverified-image:containers-storage:localhost/test (digest: sha256:b7a5470d2e81e1d58509fc7d98d91fe73931714a83981cd4892cfb4322560811)
ostree chunk layers needed: 1 (807.8 MB)
Checking out tree 780177a... done
error: Package 'foo-1.2-3.x86_64' is already in the base

Expected behavior

Should succeed without error.

Actual behavior

Failed with error: Package 'foo-1.2-3.x86_64' is already in the base

System details

[root@cosa-devsh ~]# rpm-ostree --version 
rpm-ostree:
 Version: '2024.1'
 Git: fa4f25990e663a015ffc40cb798236bd81c9493c
 Features:
  - rust
  - compose
  - container
  - fedora-integration

Additional information

No response

This error is by design. It works to do e.g. rpm-ostree install foo where foo is already in the base (in which case it doesn't do anything since the request is already fulfilled -- this is called "dormant" or "inactive" in the code/docs), but for local RPMs (i.e. rpm-ostree install foo.rpm), I sided on making that a hard error because the user wants an explicit RPM version in there, which would constitute more of an override. IOW, you can have inactive repo package layering requests, but not inactive local package layering requests (but you can have inactive local package override requests).

As mentioned in #4806 (comment), likely what you want here is to export the base commit (which doesn't contain foo) instead and not the layered commit (which does).

Going to mark this as closed. We could have a discussion around blurring the line between layering and overrides in a more general ticket I guess? Not sure how much it's worth trying to change that at this point though.

Going to mark this as closed. We could have a discussion around blurring the line between layering and overrides in a more general ticket I guess? Not sure how much it's worth trying to change that at this point though.

Thanks! LGTM. Seems more complicated for container image, or can add doc about this in case others might hit the same error.