Skip to content

Extend Options with allow_erasing and allow_downgrade#4938

Open
vaibhavdaren wants to merge 3 commits into
mainfrom
vaibhav-options-allow-downgrade-erasing
Open

Extend Options with allow_erasing and allow_downgrade#4938
vaibhavdaren wants to merge 3 commits into
mainfrom
vaibhav-options-allow-downgrade-erasing

Conversation

@vaibhavdaren
Copy link
Copy Markdown
Contributor

@vaibhavdaren vaibhavdaren commented May 29, 2026

Some artifact testing scenarios require the package manager to take actions it
would otherwise refuse by default:

  • Obsoletes conflicts: When a system package explicitly obsoletes the artifact
    under test, DNF blocks the install. allow_erasing (--allowerasing) permits
    DNF to remove the conflicting system package so the target artifact can be installed.
  • Transitive downgrades: DNF5 refuses to downgrade a transitive dependency even
    when the requested artifact requires an older version. allow_downgrade
    (--allow-downgrade) unlocks this for DNF5 (DNF4 already permits it by default).

Both options extend the existing Options dataclass and are wired into the DNF
engine family. YumEngine raises a PrepareError when allow_erasing is requested
since yum has no equivalent flag.

@vaibhavdaren vaibhavdaren marked this pull request as draft May 29, 2026 00:43
Copy link
Copy Markdown
Contributor

@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 adds allow_erasing and allow_downgrade options to the package manager. Raise a PrepareError if allow_erasing is requested under YumEngine, as yum does not support --allowerasing.

Comment thread tmt/package_managers/dnf.py
@LecrisUT
Copy link
Copy Markdown
Member

The PR description is too literal and unusable as a commit description. Keep it simple to only the reason of the implementation, not the literal implementation

@vaibhavdaren vaibhavdaren added this to the 1.75 milestone Jun 2, 2026
@vaibhavdaren vaibhavdaren force-pushed the vaibhav-options-allow-downgrade-erasing branch from 724f3f4 to 7b5d803 Compare June 2, 2026 10:45
@github-project-automation github-project-automation Bot moved this to backlog in planning Jun 2, 2026
@vaibhavdaren vaibhavdaren moved this from backlog to review in planning Jun 2, 2026
@vaibhavdaren vaibhavdaren self-assigned this Jun 2, 2026
@vaibhavdaren vaibhavdaren added area | package managers Changes related to implementations of package managers plugin | artifact Related to the `prepare/artifact` plugin. ci | full test Pull request is ready for the full test execution labels Jun 2, 2026
@vaibhavdaren vaibhavdaren marked this pull request as ready for review June 2, 2026 10:47
@LecrisUT
Copy link
Copy Markdown
Member

LecrisUT commented Jun 2, 2026

I would need the test cases to figure out if we are blocked by this. I don't suspect allow_downgrading to be necessary since the downgrading across system update is a current issue in Fedora, i.e. I suspect the default is already to allow the downgrade.

allow_erasing is the more difficult case to think of the scenario. Can you elaborate on what the system and artifact repo look like and the packages interactions?

@vaibhavdaren
Copy link
Copy Markdown
Contributor Author

Here is the breakdown for both flags and the specific package interactions that require them (these correspond to tests T8 and T9 in our validation matrix:

1. Why we need allow_downgrade (DNF5 only)

While DNF5 will automatically downgrade a package if you directly request an older NVRA that has a higher repo priority, it blocks the transaction if downgrading that package requires downgrading a transitive dependency.

The Scenario (Test T8):

  • System state: Guest has foo-1.4 installed.
  • Artifact repo: Contains foo-devel-1.1.
  • Interaction: foo-devel-1.1 has a strict requirement: Requires: foo = 1.1.
  • Result: If we run dnf5 install foo-devel-1.1, DNF5 will refuse to silently downgrade the already-installed foo-1.4 to satisfy foo-devel-1.1. It fails the transaction. Passing --allow-downgrade explicitly permits DNF5 to cascade the downgrade to the transitive dependency. (DNF4 does this automatically, which is why the engine routes this flag only to DNF5).

2. Why we need allow_erasing (DNF4 & DNF5)

The primary driver for --allowerasing is handling Obsoletes replacements. If the base system contains a next-generation package that explicitly obsoletes the package the artifact is trying to test, DNF will block the install rather than removing the installed system package.

The Scenario (Test T9):

  • System state: Guest has foo-ng-1.4 installed. The spec file for foo-ng contains Provides: foo and Obsoletes: foo < 1.4.
  • Artifact repo: Contains the older/original foo-1.1 (this is the artifact we must enforce and test).
  • Interaction: We tell DNF to install foo-1.1. DNF sees a conflict because the system already has foo-ng which obsoletes it.
  • Result: Without --allowerasing, DNF aborts. With --allowerasing, DNF is permitted to erase the conflicting foo-ng from the base image and cleanly install our target artifact foo-1.1.

Comment thread tmt/package_managers/__init__.py Outdated
allow_untrusted: bool = False

#: If set, allow erasing conflicting or obsoleting packages (``--allowerasing``).
#: Supported by DNF4 and DNF5.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

When support for this flag gets added to the emerge package manager, no-one will recall there's a list of package managers supporting it at this place. Good note, but better suited for the dnf package manager plugin.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Moved the documentation to dnf in 4458573.

Add two new fields to the package manager Options container:

- allow_erasing: emits --allowerasing via DnfEngine._extra_dnf_options,
  supported by both DNF4 and DNF5. Allows the resolver to erase packages
  that conflict with or are obsoleted by a requested install.

- allow_downgrade: emits --allow-downgrade via a Dnf5Engine override only.
  DNF4 handles transitive dependency downgrades automatically; passing this
  flag to DNF4 would cause a fatal error on RHEL guests.

No callers of the new fields are introduced in this commit.
@vaibhavdaren vaibhavdaren force-pushed the vaibhav-options-allow-downgrade-erasing branch 2 times, most recently from 06a8f60 to 4458573 Compare June 4, 2026 10:03
@vaibhavdaren vaibhavdaren requested a review from LecrisUT June 4, 2026 10:06
Comment thread tmt/package_managers/dnf.py
@therazix therazix removed this from the 1.75 milestone Jun 5, 2026
@teemtee teemtee deleted a comment from ingatipeter025-web Jun 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area | package managers Changes related to implementations of package managers ci | full test Pull request is ready for the full test execution plugin | artifact Related to the `prepare/artifact` plugin.

Projects

Status: review

Development

Successfully merging this pull request may close these issues.

6 participants