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

Make the list for package actions unique so it can be passed to salt (bsc#1232042) #9571

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion java/code/src/com/redhat/rhn/manager/action/ActionManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -2009,10 +2009,36 @@ private static List<Map<String, Long>> removeDuplicatedName(List<Map<String, Lon
public static void addPackageActionDetails(Collection<Action> actions,
List<Map<String, Long>> packageMaps) {
if (packageMaps != null) {
List<Map<String, Long>> pkgMaps;

if (actions.iterator().next().getActionType().equals(ActionFactory.TYPE_PACKAGES_REMOVE)) {
// our packages.pkgremove state is handling duplicates
pkgMaps = packageMaps;
}
else {
long noarch = PackageFactory.lookupPackageArchByLabel("noarch").getId();
long all = PackageFactory.lookupPackageArchByLabel("all-deb").getId();
Map<String, Map<String, Long>> uPkgMap = new HashMap<>();
// For other salt pkg states (pkg.installed), name + arch must be unique.
for (Map<String, Long> p : packageMaps) {
long archId = p.getOrDefault("arch_id", noarch);
String name = String.valueOf(p.get("name_id"));
if (archId == noarch || archId == all) {
if (uPkgMap.keySet().stream().noneMatch(k -> k.startsWith(name + "."))) {
uPkgMap.put(name, p);
}
}
else if (!uPkgMap.containsKey(name)) {
String key = name + "." + p.get("arch_id");
uPkgMap.put(key, p);
rjmateus marked this conversation as resolved.
Show resolved Hide resolved
}
}
pkgMaps = new ArrayList<>(uPkgMap.values());
}
List<Map<String, Object>> paramList =
actions.stream().flatMap(action -> {
String packageParameter = getPackageParameter(action);
return packageMaps.stream().map(packageMap -> {
return pkgMaps.stream().map(packageMap -> {
Map<String, Object> params = new HashMap<>();
params.put("action_id", action.getId());
params.put("name_id", packageMap.get("name_id"));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Make the list for package actions unique so it can be passed
to salt (bsc#1232042)
Loading