Skip to content

rpmostreed-transaction-types: don't use base-db when idempotent#5510

Merged
jmarrero merged 2 commits intocoreos:mainfrom
jmarrero:idempotent-base
Dec 1, 2025
Merged

rpmostreed-transaction-types: don't use base-db when idempotent#5510
jmarrero merged 2 commits intocoreos:mainfrom
jmarrero:idempotent-base

Conversation

@jmarrero
Copy link
Copy Markdown
Member

@jmarrero jmarrero commented Oct 14, 2025

When booted from a container image, skip the base commit rpmdb check
during package installation transactions. Container images don't have
meaningful base-db separation like traditional ostree commits do.

This fixes idempotent layering on booted hosts when deployed via
container, where packages already present in the base image would
incorrectly fail. Now, if the DNF transaction is empty (all packages
already in base), we properly exit cleanly.

Also adds tests for idempotent layering scenarios with container
images.

Assisted-by: Claude Code
Fixes #5496

@openshift-ci
Copy link
Copy Markdown

openshift-ci bot commented Oct 14, 2025

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@cgwalters
Copy link
Copy Markdown
Member

Offhand this seems a bit complicated to me; you mentioned in chat I think if we should be using the rpmdb for source of truth here and I think that would make sense; we already are doing that in other cases.

It'd be really useful to have a test case for this of course, can we dig in in #5496 for what cases are broken?

@jmarrero jmarrero force-pushed the idempotent-base branch 4 times, most recently from 774d474 to f77722d Compare October 21, 2025 06:00
@jmarrero jmarrero marked this pull request as ready for review October 24, 2025 13:14
@jmarrero
Copy link
Copy Markdown
Member Author

/gemini review

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request correctly fixes an issue with idempotent transactions for container-based systems by properly detecting when a transaction results in no changes. The logic added to rpmostree-sysroot-upgrader.cxx and rpmostreed-transaction-types.cxx correctly handles the special case where layered packages are already present in the base container image. The new test case is comprehensive and validates the fix. The changes are solid, but I have a few suggestions to improve code conciseness and script robustness.

Comment thread src/daemon/rpmostreed-transaction-types.cxx
Comment thread tests/kolainst/destructive/idempotent-layering Outdated
Comment thread tests/kolainst/destructive/idempotent-layering Outdated
Comment thread tests/kolainst/destructive/idempotent-layering Outdated
@jmarrero jmarrero changed the title rpmostreed-transaction-types: fix idempotent check base packages rpmostreed-transaction-types: don't use base-db when idempotent Oct 24, 2025
@jmarrero
Copy link
Copy Markdown
Member Author

@cgwalters anything scary here beyond CI failures It looks like the failures are unrelated, gonna try to start looking at them now and see if I can fix them in #5516.

Copy link
Copy Markdown
Member

@cgwalters cgwalters left a comment

Choose a reason for hiding this comment

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

Overall looks sane to me! two optionals

Comment thread src/daemon/rpmostree-sysroot-upgrader.cxx Outdated
Comment thread src/daemon/rpmostree-sysroot-upgrader.cxx Outdated
@jmarrero
Copy link
Copy Markdown
Member Author

/gemini review

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request correctly addresses idempotent package layering on container-based systems by skipping the base rpmdb check when a transaction is idempotent. The introduction of the rpmostree_dnf_context_has_empty_transaction helper function is a good refactoring that improves code clarity and reuse. The changes are well-contained, and the addition of a new test case ensures the fix is properly verified. Overall, this is a solid improvement.

Comment thread src/daemon/rpmostree-sysroot-upgrader.cxx Outdated
@openshift-ci
Copy link
Copy Markdown

openshift-ci bot commented Oct 27, 2025

@jmarrero: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/kola-upgrade dc3a279 link true /test kola-upgrade
ci/prow/fcos-e2e dc3a279 link true /test fcos-e2e

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

Comment thread src/daemon/rpmostreed-transaction-types.cxx Outdated
@jmarrero jmarrero force-pushed the idempotent-base branch 2 times, most recently from 31254d6 to 4c320c4 Compare November 21, 2025 19:52
@jmarrero jmarrero closed this Nov 26, 2025
auto-merge was automatically disabled November 26, 2025 19:00

Pull request was closed

When booted from a container image, skip the base commit rpmdb check
during package installation transactions. Container images don't have
meaningful base-db separation like traditional ostree commits do.

This fixes idempotent layering on booted hosts when deployed via
container, where packages already present in the base image would
incorrectly fail.  Now, if the DNF transaction is empty (all packages
already in base), we properly exit cleanly.

Also adds tests for idempotent layering scenarios with container
images.

Signed-off-by: Joseph Marrero Corchado <jmarrero@redhat.com>
@jmarrero
Copy link
Copy Markdown
Member Author

/gemini review

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a fix for idempotent layering on container-based systems. The changes are well-structured and correctly address the issue where rpm-ostree install --idempotent would fail if the package was already present in the base container image.

The core of the solution involves:

  • Introducing an allow_empty_transaction flag to prevent errors on empty DNF transactions for idempotent operations.
  • Skipping the base RPMDB check for container-based deployments, which is appropriate since they don't have the same base/layered separation as traditional ostree commits.
  • Adjusting the layering_changed logic to correctly handle no-op layering on containers.
  • Adding a comprehensive test case that validates the new behavior in various idempotent scenarios.

The code is clear, and the changes are logically sound. The addition of the rpmostree_dnf_context_has_empty_transaction helper function is a good refactoring that improves code clarity. Overall, this is a solid improvement.

@jmarrero
Copy link
Copy Markdown
Member Author

jmarrero@toolbx ~/d/cosa-build> cosa kola run  --output-dir /tmp/kolaself -E /home/jmarrero/development/github/coreos/rpm-ostree/tests/kolainst/destructive/ 'ext.rpm-ostree.destructive.layering-local' 'ext.rpm-ostree.destructive.idempotent-layering' 'ext.rpm-ostree.destructive.container-rebase-upgrade' 'ext.rpm-ostree.destructive.layering-useradd' 'ext.rpm-ostree.nondestructive.misc.sh'
kola -p qemu run -E /home/jmarrero/development/github/coreos/rpm-ostree/tests/kolainst/destructive/ ext.rpm-ostree.destructive.layering-local ext.rpm-ostree.destructive.idempotent-layering ext.rpm-ostree.destructive.container-rebase-upgrade ext.rpm-ostree.destructive.layering-useradd ext.rpm-ostree.nondestructive.misc.sh --output-dir /tmp/kolaself
=== RUN   ext.rpm-ostree.nondestructive.misc.sh
=== RUN   ext.rpm-ostree.destructive.layering-useradd
=== RUN   ext.rpm-ostree.destructive.layering-local
=== RUN   ext.rpm-ostree.destructive.container-rebase-upgrade
=== RUN   ext.rpm-ostree.destructive.idempotent-layering
--- PASS: ext.rpm-ostree.nondestructive.misc.sh (31.78s)
--- PASS: ext.rpm-ostree.destructive.idempotent-layering (201.58s)
--- PASS: ext.rpm-ostree.destructive.layering-local (86.73s)
--- PASS: ext.rpm-ostree.destructive.container-rebase-upgrade (168.36s)
--- PASS: ext.rpm-ostree.destructive.layering-useradd (80.14s)
PASS, output in /tmp/kolaself
jmarrero@toolbx ~/d/cosa-build>
jmarrero@toolbx ~/d/cosa-build> cosa run
Fedora CoreOS 42.20251126.dev.3
Tracker: https://github.com/coreos/fedora-coreos-tracker
Discuss: https://discussion.fedoraproject.org/tag/coreos

Last login: Wed Nov 26 20:39:52 2025
core@cosa-devsh:~$ cat /etc/os-release
NAME="Fedora Linux"
VERSION="42.20251126.dev.3 (CoreOS)"
RELEASE_TYPE=stable
ID=fedora
VERSION_ID=42
VERSION_CODENAME=""
PLATFORM_ID="platform:f42"
PRETTY_NAME="Fedora CoreOS 42.20251126.dev.3"
ANSI_COLOR="0;38;2;60;110;180"
LOGO=fedora-logo-icon
CPE_NAME="cpe:/o:fedoraproject:fedora:42"
HOME_URL="https://getfedora.org/coreos/"
DOCUMENTATION_URL="https://docs.fedoraproject.org/en-US/fedora-coreos/"
SUPPORT_URL="https://github.com/coreos/fedora-coreos-tracker/"
BUG_REPORT_URL="https://github.com/coreos/fedora-coreos-tracker/"
REDHAT_BUGZILLA_PRODUCT="Fedora"
REDHAT_BUGZILLA_PRODUCT_VERSION=42
REDHAT_SUPPORT_PRODUCT="Fedora"
REDHAT_SUPPORT_PRODUCT_VERSION=42
SUPPORT_END=2026-05-13
VARIANT="CoreOS"
VARIANT_ID=coreos
OSTREE_VERSION='42.20251126.dev.3'

Locally the tests pass with F42, the tests failing on the Jenkins run are the same in other current PRs and I think it's just stuff we need to fix as they broke with the update to CoreOS F43. I think this is ready to be merged.

@jmarrero jmarrero merged commit b54f9b8 into coreos:main Dec 1, 2025
16 of 18 checks passed
@jmarrero jmarrero mentioned this pull request Jan 22, 2026
jmarrero added a commit to jmarrero/rpm-ostree that referenced this pull request Jan 28, 2026
…ystems

PR coreos#5510 introduced an early return optimization for container-based
deployments to handle idempotent package layering. However, this early
return checked only `remove_changed` (package removals) and not override
changes, causing `rpm-ostree override reset --all` to silently return
without staging a new deployment on container-based systems.

The issue occurs because:
1. `skip_base_check` is TRUE for container-based ostree hosts
2. `no_overrides` (the -a flag) sets `changed = TRUE` but not `remove_changed`
3. The early return condition `!remove_changed` was satisfied, skipping deployment

This fix adds an `override_changed` tracking variable that is set when
overrides are reset, and includes it in the early return condition. Now
when `rpm-ostree override reset --all` is called, the deployment is
properly staged.

Also extends the idempotent-layering test to cover this scenario:
- Performs a kernel override on a container-based deployment
- Tests that `override reset --all` properly stages a new deployment
- Verifies the pending deployment has no overrides

This would have caught the regression introduced in PR coreos#5510.

Fixes: coreos#5510
Assisted-by: Claude (OpenCode)
Signed-off-by: Joseph Marrero Corchado <jmarrero@redhat.com>
jmarrero added a commit to jmarrero/rpm-ostree that referenced this pull request Jan 28, 2026
…osts

PR coreos#5510 introduced an early return optimization for container-based
deployments to handle idempotent package layering. However, this early
return checked only `remove_changed` (package removals) and not override
changes, causing `rpm-ostree override reset --all` to silently return
without staging a new deployment on container-based systems.

The issue occurs because:
1. `skip_base_check` is TRUE for container-based ostree hosts
2. `no_overrides` (the -a flag) sets `changed = TRUE` but not `remove_changed`
3. The early return condition `!remove_changed` was satisfied, skipping deployment

This fix adds an `override_changed` tracking variable that is set when
overrides are reset, and includes it in the early return condition. Now
when `rpm-ostree override reset --all` is called, the deployment is
properly staged.

Also extends the idempotent-layering test to cover this scenario:
- Performs a kernel override on a container-based deployment
- Tests that `override reset --all` properly stages a new deployment
- Verifies the pending deployment has no overrides

This would have caught the regression introduced in PR coreos#5510.

Fixes: coreos#5510
Assisted-by: Claude (OpenCode)
Signed-off-by: Joseph Marrero Corchado <jmarrero@redhat.com>
jmarrero added a commit to jmarrero/rpm-ostree that referenced this pull request Jan 28, 2026
PR coreos#5510 introduced an early return optimization for container-based
deployments to handle idempotent package layering. However, this early
return checked only `remove_changed` (package removals) and not override
changes, causing `rpm-ostree override reset --all` to silently return
without staging a new deployment on container-based systems.

The issue occurs because:
1. `skip_base_check` is TRUE for container-based ostree hosts
2. `no_overrides` (the -a flag) sets `changed = TRUE` but not `remove_changed`
3. The early return condition `!remove_changed` was satisfied, skipping deployment

This fix adds an `override_changed` tracking variable that is set when
overrides are reset, and includes it in the early return condition. Now
when `rpm-ostree override reset --all` is called, the deployment is
properly staged.

Also extends the idempotent-layering test to cover this scenario:
- Performs a kernel override on a container-based deployment
- Tests that `override reset --all` properly stages a new deployment
- Verifies the pending deployment has no overrides

This would have caught the regression introduced in PR coreos#5510.

Fixes: coreos#5510
Assisted-by: Claude (OpenCode)
Signed-off-by: Joseph Marrero Corchado <jmarrero@redhat.com>
jmarrero added a commit to jmarrero/rpm-ostree that referenced this pull request Jan 28, 2026
PR coreos#5510 introduced an early return optimization for container-based
deployments to handle idempotent package layering. However, this early
return checked only `remove_changed` (package removals) and not override
changes, causing `rpm-ostree override reset --all` to silently return
without staging a new deployment on container-based systems.

The issue occurs because:
1. `skip_base_check` is TRUE for container-based ostree hosts
2. `no_overrides` (the -a flag) sets `changed = TRUE` but not `remove_changed`
3. The early return condition `!remove_changed` was satisfied, skipping deployment

This fix adds an `override_changed` tracking variable that is set when
overrides are reset, and includes it in the early return condition. Now
when `rpm-ostree override reset --all` is called, the deployment is
properly staged.

Also extends the idempotent-layering test to cover this scenario:
- Performs a kernel override on a container-based deployment
- Tests that `override reset --all` properly stages a new deployment
- Verifies the pending deployment has no overrides

This would have caught the regression introduced in PR coreos#5510.

Fixes: coreos#5510
Assisted-by: Claude (OpenCode)
Signed-off-by: Joseph Marrero Corchado <jmarrero@redhat.com>
jmarrero added a commit to jmarrero/rpm-ostree that referenced this pull request Feb 4, 2026
PR coreos#5510 introduced an early return optimization for container-based
deployments to handle idempotent package layering. However, this early
return checked only `remove_changed` (package removals) and not override
changes, causing `rpm-ostree override reset --all` to silently return
without staging a new deployment on container-based systems.

The issue occurs because:
1. `skip_base_check` is TRUE for container-based ostree hosts
2. `no_overrides` (the -a flag) sets `changed = TRUE` but not `remove_changed`
3. The early return condition `!remove_changed` was satisfied, skipping deployment

This fix adds an `override_changed` tracking variable that is set when
overrides are reset, and includes it in the early return condition. Now
when `rpm-ostree override reset --all` is called, the deployment is
properly staged.

Also extends the idempotent-layering test to cover this scenario:
- Performs a kernel override on a container-based deployment
- Tests that `override reset --all` properly stages a new deployment
- Verifies the pending deployment has no overrides

This would have caught the regression introduced in PR coreos#5510.

Fixes: coreos#5510
Assisted-by: Claude (OpenCode)
Signed-off-by: Joseph Marrero Corchado <jmarrero@redhat.com>
jmarrero added a commit to jmarrero/rpm-ostree that referenced this pull request Feb 4, 2026
PR coreos#5510 introduced an early return optimization for container-based
deployments to handle idempotent package layering. However, this early
return checked only `remove_changed` (package removals) and not override
changes, causing `rpm-ostree override reset --all` to silently return
without staging a new deployment on container-based systems.

The issue occurs because:
1. `skip_base_check` is TRUE for container-based ostree hosts
2. `no_overrides` (the -a flag) sets `changed = TRUE` but not `remove_changed`
3. The early return condition `!remove_changed` was satisfied, skipping deployment

This fix adds an `override_changed` tracking variable that is set when
overrides are reset, and includes it in the early return condition. Now
when `rpm-ostree override reset --all` is called, the deployment is
properly staged.

Also extends the idempotent-layering test to cover this scenario:
- Performs a kernel override on a container-based deployment
- Tests that `override reset --all` properly stages a new deployment
- Verifies the pending deployment has no overrides

This would have caught the regression introduced in PR coreos#5510.

Fixes: coreos#5510
Assisted-by: Claude (OpenCode)
Signed-off-by: Joseph Marrero Corchado <jmarrero@redhat.com>
jmarrero added a commit to jmarrero/rpm-ostree that referenced this pull request Mar 9, 2026
… systems

PR coreos#5510 introduced an early return optimization for container-based
deployments to handle idempotent package layering. However, this early
return did not check whether the base image had changed, causing
`rpm-ostree upgrade` to silently return success without staging a new
deployment when upgrading container-based systems without layered packages.

The issue occurs because:
1. `skip_base_check` is TRUE for container-based ostree hosts
2. When pulling a new base image, `base_changed = TRUE` → `changed = TRUE`
3. But the early return condition only checked `origin_changed` (layering,
   remove, override changes) and `have_refspec_or_revision`
4. Since `changed` was not checked, the early return triggered even when
   a new base image was available

This fix adds `!changed` to the early return condition, ensuring that
if a new base image was pulled, the deployment proceeds normally.

Closes: coreos#5567
Fixes: 4d4196e ("rpmostreed-transaction-types: don't use base-db when idempotent")
Assisted-by: Claude (OpenCode)
Signed-off-by: Joseph Marrero Corchado <jmarrero@redhat.com>
jmarrero added a commit to jmarrero/rpm-ostree that referenced this pull request Mar 9, 2026
PR coreos#5510 introduced an early return for container-based deployments
to handle idempotent package layering, but it failed to check whether
the base image itself had changed. This caused `rpm-ostree upgrade`
to silently return success without staging a new deployment.

Fold `remove_changed` and `override_changed` into the `changed`
variable so the early return only triggers when truly nothing changed.

Also fix a related crash in `rpmostree_context_assemble()` when
`--idempotent --apply-live` is used on a package already in the base
image: the empty transaction path hit `g_assert_not_reached()` instead
of returning through `rpmostree_context_assemble_end()`.

The test is updated to add disk space (`minDisk: 20`), container
cleanup between phases, and corrected assertions for the upgrade
regression scenarios.

Closes: coreos#5567
Fixes: 4d4196e ("rpmostreed-transaction-types: don't use base-db when idempotent")
Assisted-by: Claude Opus 4.6 (OpenCode)
Signed-off-by: Joseph Marrero Corchado <jmarrero@redhat.com>
jmarrero added a commit to jmarrero/rpm-ostree that referenced this pull request Mar 9, 2026
PR coreos#5510 introduced an early return for container-based deployments
to handle idempotent package layering, but it failed to check whether
the base image itself had changed. This caused `rpm-ostree upgrade`
to silently return success without staging a new deployment.

Fold `remove_changed` and `override_changed` into the `changed`
variable so the early return only triggers when truly nothing changed.

Also fix a related crash in `rpmostree_context_assemble()` when
`--idempotent --apply-live` is used on a package already in the base
image: the empty transaction path hit `g_assert_not_reached()` instead
of returning through `rpmostree_context_assemble_end()`.

Closes: coreos#5567
Fixes: 4d4196e ("rpmostreed-transaction-types: don't use base-db when idempotent")
Assisted-by: Claude (OpenCode)
Signed-off-by: Joseph Marrero Corchado <jmarrero@redhat.com>
jmarrero added a commit to jmarrero/rpm-ostree that referenced this pull request Mar 9, 2026
PR coreos#5510 introduced an early return for container-based deployments
to handle idempotent package layering, but it failed to check whether
the base image itself had changed. This caused `rpm-ostree upgrade`
to silently return success without staging a new deployment.

Fold `remove_changed` and `override_changed` into the `changed`
variable so the early return only triggers when truly nothing changed.

Also fix a related crash in `rpmostree_context_assemble()` when
`--idempotent --apply-live` is used on a package already in the base
image: the empty transaction path hit `g_assert_not_reached()` instead
of returning through `rpmostree_context_assemble_end()`.

Closes: coreos#5567
Fixes: 4d4196e ("rpmostreed-transaction-types: don't use base-db when idempotent")
Assisted-by: Claude Opus 4.6 (OpenCode)
Signed-off-by: Joseph Marrero Corchado <jmarrero@redhat.com>
jmarrero added a commit to jmarrero/rpm-ostree that referenced this pull request Mar 9, 2026
PR coreos#5510 introduced an early return for container-based deployments
to handle idempotent package layering, but it failed to check whether
the base image itself had changed. This caused `rpm-ostree upgrade`
to silently return success without staging a new deployment.

Fold `remove_changed` and `override_changed` into the `changed`
variable so the early return only triggers when truly nothing changed.

Also fix a related crash in `rpmostree_context_assemble()` when
`--idempotent --apply-live` is used on a package already in the base
image: the empty transaction path hit `g_assert_not_reached()` instead
of returning through `rpmostree_context_assemble_end()`.

Closes: coreos#5567
Fixes: 4d4196e ("rpmostreed-transaction-types: don't use base-db when idempotent")
Assisted-by: Claude Opus 4.6 (OpenCode)
Signed-off-by: Joseph Marrero Corchado <jmarrero@redhat.com>
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.

rpm-ostree --unchanged-exit-77 and --idempotent didn't work

2 participants