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

goal: Fix group packages removal (RhBug:2173927) #329

Merged
merged 1 commit into from
Mar 14, 2023

Conversation

m-blaha
Copy link
Member

@m-blaha m-blaha commented Mar 3, 2023

This commit fixes a problem where group packages were not being removed along with their respective groups. The issue was caused by the algorithm for determining whether another installed package requires the group package. Previously, it took into account all packages that were installed, regardless of whether they were part of any group being removed.

To address the issue, the algorithm now only takes into account packages that are not part of any group currently being removed. For example, if there are two groups installed on the system:

Grp1 with packages
    Pkg1 which requires Dep1
Grp2 with packages
    Dep1

The new algorithm will correctly remove both Pkg1 and Dep1 packages when both Grp1 and Grp2 are being removed.

This situation can even occur with only one group being removed - in case that the group package requires one of its own provides. These self requirements are quite common in rpmdb and they also caused group package not to be removed. The patch fixes also this issue.

Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2173927
Test: rpm-software-management/ci-dnf-stack#1230

@m-blaha
Copy link
Member Author

m-blaha commented Mar 6, 2023

I've just realized that there still are cases where dnf5 group remove does not remove all group packages it could:

GrpA : Pkg1 (requires Dep1 which requires Dep11)
GrpB : Dep11

In case of dnf5 group remove Grp1 Grp2 the Dep11 package stays on the system even though it can be removed.

@m-blaha m-blaha force-pushed the mblaha/remove_group_packages branch from c427b24 to 37b46ec Compare March 6, 2023 12:28
@m-blaha m-blaha added ready for review and removed blocked Further work on issue or PR is blocked by something else labels Mar 6, 2023
}
rpm_goal.add_remove(packages_to_remove_ids, cfg_main.clean_requirements_on_remove().get_value());
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this need to be updated: clean_requirements_on_remove -> get_clean_requirements_on_remove_option since #327 was merged. Sorry for the delay.

Copy link
Member

Choose a reason for hiding this comment

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

Hmm this is interesting, I didn't think of it before. Because all tests are passing, everything is green, but I suppose after merging it as it is, it wouldn't be compilable. Can we improve that with like running the CI stack in the environment where the commit is already rebased and merged?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think that already happens, the problem is it ran before merging the incompatible changes. I believe if we re-run the CI now it would fail to compile.

Copy link
Contributor

Choose a reason for hiding this comment

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

I have tried to re-run it just now to make sure.

Copy link
Member

@jan-kolarik jan-kolarik Mar 14, 2023

Choose a reason for hiding this comment

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

Allright, then just maybe automatic re-running workflows for pending pull requests? But that's probably expensive... At least there could be some warning that the checks are not valid anymore, it is confusing and probably dangerous 🙂 I created a follow-up issue to not forget about that.

@@ -1429,9 +1429,15 @@ void Goal::Impl::add_group_install_to_goal(
}

void Goal::Impl::add_group_remove_to_goal(
base::Transaction & transaction,
[[maybe_unused]] base::Transaction & transaction,
Copy link
Contributor

Choose a reason for hiding this comment

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

Can I ask why are we keeping the unused parameter?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure, I forgot to remove it :)

rpm_goal.add_reason_change(pkg, transaction::TransactionItemReason::DEPENDENCY, std::nullopt);
continue;
}
remove_candidates.emplace_back(std::move(pkg));
Copy link
Contributor

@kontura kontura Mar 14, 2023

Choose a reason for hiding this comment

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

I am curious are you using std::vector<rpm::Package> remove_candidates instead of PackageSet for efficiency gains? If yes I would like to note that I think you cannot std::move the pkg because it is const, AFAIK it is being copied.

If PackageSet was used it could then later also be added to the goal_tmp without the loop.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, right. I've changed it to PackageSet.

This commit fixes a problem where group packages were not being removed
along with their respective groups. The issue was caused by the
algorithm for determining whether another installed package requires the
group package. Previously, it took into account all packages that were
installed, regardless of whether they were part of any group being
removed.

To address the issue, the algorithm now only takes into account packages
that are not part of any group currently being removed. For example, if
there are two groups installed on the system:

    Grp1 with packages
        Pkg1 which requires Dep1
    Grp2 with packages
        Dep1

The new algorithm will correctly remove both Pkg1 and Dep1 packages when
both Grp1 and Grp2 are being removed.

This situation can even occur with only one group being removed - in
case that the group package requires one of its own provides. These self
requirements are quite common in rpmdb and they also caused group
package not to be removed. The patch fixes also this issue.

Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2173927
@m-blaha m-blaha force-pushed the mblaha/remove_group_packages branch from 37b46ec to c46ccc4 Compare March 14, 2023 16:32
@kontura kontura merged commit 520edcb into main Mar 14, 2023
@kontura kontura deleted the mblaha/remove_group_packages branch March 14, 2023 17:17
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.

3 participants