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

add new mandatory channels for products which are already synchronized #9402

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
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,58 @@ public void ensureSUSEProductChannelData() {
}
}

/**
* Add new mandatory channels for products which are already synchronized
*/
public void addNewMandatoryChannelsForSyncedProducts() {
List<String> installedChannelLabels = getInstalledChannelLabels();

List<Tuple2<SUSEProductSCCRepository, MgrSyncStatus>> availableChannels =
TimeUtils.logTime(LOG, "getAvailableCHannels", this::getAvailableChannels).stream().map(e -> {
MgrSyncStatus status = installedChannelLabels.contains(e.getChannelLabel()) ?
MgrSyncStatus.INSTALLED : MgrSyncStatus.AVAILABLE;
return new Tuple2<>(e, status);
}).toList();

List<SUSEProduct> allSUSEProducts = SUSEProductFactory.findAllSUSEProducts();

List<SUSEProduct> roots = allSUSEProducts.stream()
.filter(SUSEProduct::isBase)
.toList();

Map<Long, List<Tuple2<SUSEProductSCCRepository, MgrSyncStatus>>> byProductId = availableChannels.stream()
.collect(Collectors.groupingBy(p -> p.getA().getProduct().getId()));
Map<Long, List<Tuple2<SUSEProductSCCRepository, MgrSyncStatus>>> byRootId = availableChannels.stream()
.collect(Collectors.groupingBy(p -> p.getA().getRootProduct().getId()));

roots.stream()
.filter(p -> byProductId.containsKey(p.getId()))
.forEach(root -> {
Map<SUSEProduct, List<Tuple2<SUSEProductSCCRepository, MgrSyncStatus>>> byProduct =
byRootId.get(root.getId()).stream()
//.filter(p -> !p.getA().getProduct().equals(root))
.collect(Collectors.groupingBy(e -> e.getA().getProduct()));

byProduct.forEach((product, prdReposWithStat) -> {

Map<MgrSyncStatus, List<Tuple2<SUSEProductSCCRepository, MgrSyncStatus>>> reposByStatus =
prdReposWithStat.stream()
.filter(x -> x.getA().isMandatory())
.collect(Collectors.groupingBy(Tuple2::getB));
if (!reposByStatus.get(MgrSyncStatus.INSTALLED).isEmpty() &&
!reposByStatus.get(MgrSyncStatus.AVAILABLE).isEmpty()) {
reposByStatus.get(MgrSyncStatus.AVAILABLE)
.forEach(c -> {
LOG.warn("Adding new mandatory channel '{}' for product '{}'",
c.getA().getChannelLabel(), product.getFriendlyName());
addChannel(c.getA().getChannelLabel(), null);
});
}

});
});
}

/**
* Returns all available products in user-friendly format.
* @return list of all available products
Expand Down Expand Up @@ -592,6 +644,7 @@ private void refreshRepositoriesAuthentication(String mirrorUrl, boolean exclude
}
finally {
ensureSUSEProductChannelData();
addNewMandatoryChannelsForSyncedProducts();
linkAndRefreshContentSource(mirrorUrl);
ManagerInfoFactory.setLastMgrSyncRefresh();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- automatic add new mandatory channels for products which are already synchronized
Loading