Skip to content

Commit

Permalink
Merge pull request #344 from jfdenise/GAL-361
Browse files Browse the repository at this point in the history
Fix for GAL-361, Feature pack config stability level improperly constrains provisioning
  • Loading branch information
jfdenise authored Apr 3, 2024
2 parents 783b1ae + 466ef8a commit bbd490f
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 45 deletions.
12 changes: 1 addition & 11 deletions api/src/main/java/org/jboss/galleon/api/ProvisioningImpl.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016-2023 Red Hat, Inc. and/or its affiliates
* Copyright 2016-2024 Red Hat, Inc. and/or its affiliates
* and other contributors as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -16,7 +16,6 @@
*/
package org.jboss.galleon.api;

import java.io.IOException;
import java.io.InputStream;
import java.net.URLClassLoader;
import java.nio.file.Files;
Expand All @@ -42,7 +41,6 @@
import org.jboss.galleon.progresstracking.ProgressCallback;
import org.jboss.galleon.progresstracking.ProgressTracker;
import org.jboss.galleon.universe.UniverseResolver;
import org.jboss.galleon.util.IoUtils;
import org.jboss.galleon.core.builder.ProvisioningContextBuilder;
import org.jboss.galleon.diff.FsDiff;
import org.jboss.galleon.impl.ProvisioningUtil;
Expand All @@ -61,7 +59,6 @@ class ProvisioningImpl implements Provisioning {
private boolean recordState;
private final Map<String, ProgressTracker<?>> progressTrackers = new HashMap<>();

private final Path tmp;
private final Map<FPID, LocalFP> locals;

private final String coreVersion;
Expand All @@ -78,12 +75,6 @@ class ProvisioningImpl implements Provisioning {
this.locals = builder.getLocals();
this.recordState = builder.isRecordState();
loader = GalleonBuilder.getCallerClassLoader(coreVersion, universeResolver);
try {
tmp = Files.createTempDirectory("galleon-tmp");
} catch (IOException ex) {
throw new ProvisioningException(ex);
}

}

/**
Expand Down Expand Up @@ -169,7 +160,6 @@ private ProvisioningContext buildProvisioningContext() throws ProvisioningExcept

@Override
public void close() {
IoUtils.recursiveDelete(tmp);
try {
for (ProvisioningContext ctx : contexts) {
ctx.close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,14 @@ public class FeaturePackRuntime extends FeaturePackLayout implements FeaturePack
}
// Filter out the packages that are not at the right stability level
final Map<String, PackageRuntime> filteredPackages = new LinkedHashMap<>(tmpPackages.size());
Stability minStability= rt.getMinPackageStability(getSpec().getPackageStability());
Stability stability= rt.getPackageStability(getSpec().getPackageStability());
for(Map.Entry<String, PackageRuntime> entry : tmpPackages.entrySet()) {
Stability stability = entry.getValue().getSpec().getStability() == null ? Stability.DEFAULT : entry.getValue().getSpec().getStability();
if (minStability.enables(stability)) {
Stability packageStability = entry.getValue().getSpec().getStability() == null ? Stability.DEFAULT : entry.getValue().getSpec().getStability();
if (stability.enables(packageStability)) {
filteredPackages.put(entry.getKey(), entry.getValue());
} else {
if (rt.getMessageWriter().isVerboseEnabled()) {
rt.getMessageWriter().verbose("Excluding package '" + entry.getKey() + "'. Its stability '" + stability + "' is lower than the expected '" + minStability +"' stability");
rt.getMessageWriter().verbose("Excluding package '" + entry.getKey() + "'. Its stability '" + packageStability + "' is lower than the expected '" + stability +"' stability");
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,31 +282,27 @@ private ProvisioningRuntime doBuild() throws ProvisioningException {
}

/**
* The min config stability is constrained by the feature-pack stability that is the minimal for a
* given feature-pack. The stability set by the user can only reduce the scope.
* The config stability is by default the one declared in the feature-pack. if a user specify a config stability,
* this level is used.
*/
public Stability getMinConfigStability(Stability featurePackStability) {
Stability minStability= featurePackStability == null ? Stability.DEFAULT : featurePackStability;
public Stability getConfigStability(Stability featurePackStability) {
Stability stability= featurePackStability == null ? Stability.DEFAULT : featurePackStability;
if (getUserConfigStability() != null) {
if (minStability.enables(getUserConfigStability())) {
minStability = getUserConfigStability();
}
stability = getUserConfigStability();
}
return minStability;
return stability;
}

/**
* The min package stability is constrained by the feature-pack stability that is the minimal for a
* given feature-pack. The stability set by the user can only reduce the scope.
* The package stability is by default the one declared in the feature-pack. if a user specify a config stability,
* this level is used.
*/
public Stability getMinPackageStability(Stability featurePackStability) {
Stability minStability= featurePackStability == null ? Stability.DEFAULT : featurePackStability;
public Stability getPackageStability(Stability featurePackStability) {
Stability stability= featurePackStability == null ? Stability.DEFAULT : featurePackStability;
if (getUserPackageStability() != null) {
if (minStability.enables(getUserPackageStability())) {
minStability = getUserPackageStability();
}
stability = getUserPackageStability();
}
return minStability;
return stability;
}

public Stability getUserConfigStability() {
Expand Down Expand Up @@ -968,10 +964,10 @@ private void processConfigItemContainer(ConfigItemContainer ciContainer) throws
fpStability = fp.getSpec().getConfigStability();
}
}
Stability minStability = getMinConfigStability(fpStability);
if (!minStability.enables(featureStability)) {
Stability stability = getConfigStability(fpStability);
if (!stability.enables(featureStability)) {
if (messageWriter.isVerboseEnabled()) {
messageWriter.verbose(configStack.id + ". Excluding feature '" + fconfig.getSpecId().getName() + "'. Its stability '" + featureStability + "' is lower than the expected '" + minStability +"' stability");
messageWriter.verbose(configStack.id + ". Excluding feature '" + fconfig.getSpecId().getName() + "'. Its stability '" + featureStability + "' is lower than the expected '" + stability +"' stability");
}
continue;
}
Expand All @@ -980,9 +976,9 @@ private void processConfigItemContainer(ConfigItemContainer ciContainer) throws
for (String p : fconfig.getParams().keySet()) {
FeatureParameterSpec ps = spec.getSpec().getParam(p);
Stability paramStability = ps.getStability() == null ? Stability.DEFAULT : ps.getStability();
if (!minStability.enables(paramStability)) {
if (!stability.enables(paramStability)) {
if (messageWriter.isVerboseEnabled()) {
messageWriter.verbose(configStack.id + ". Excluding parameter '" + p + "' from feature '" + fconfig.getSpecId().getName() + "'. Its stability '" + paramStability + "' is lower than the expected '" + minStability +"' stability");
messageWriter.verbose(configStack.id + ". Excluding parameter '" + p + "' from feature '" + fconfig.getSpecId().getName() + "'. Its stability '" + paramStability + "' is lower than the expected '" + stability +"' stability");
}
toRemove.add(p);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ protected ProvisioningConfig provisioningConfig() throws ProvisioningDescription
@Override
protected ProvisionedState provisionedState() throws ProvisioningDescriptionException {
return ProvisionedState.builder()
.addFeaturePack(ProvisionedFeaturePack.builder(FP1_GAV).addPackage("p").addPackage("pDefault").addPackage("pCommunity").build())
.addFeaturePack(ProvisionedFeaturePack.builder(FP1_GAV).addPackage("p").addPackage("pCommunity").addPackage("pDefault").build())
.addConfig(ProvisionedConfigBuilder.builder()
.setName("configA")
.addFeature(ProvisionedFeatureBuilder.builder(ResolvedFeatureId.create(new ResolvedSpecId(FP1_GAV.getProducer(), "specNoStability"), "id", "1")))
Expand All @@ -55,13 +55,17 @@ protected ProvisionedState provisionedState() throws ProvisioningDescriptionExce
builder(ResolvedFeatureId.builder(new ResolvedSpecId(FP1_GAV.getProducer(), "specDefault")).
setParam("id", "1").build()).setConfigParam("idDefault", "1").setConfigParam("idCommunity", "1").build())
.build())
.addFeaturePack(ProvisionedFeaturePack.builder(FP2_GAV).addPackage("p").addPackage("pDefault").build())
.addFeaturePack(ProvisionedFeaturePack.builder(FP2_GAV).addPackage("p").addPackage("pCommunity").addPackage("pDefault").build())
.addConfig(ProvisionedConfigBuilder.builder()
.setName("configB")
.addFeature(ProvisionedFeatureBuilder.builder(ResolvedFeatureId.create(new ResolvedSpecId(FP2_GAV.getProducer(), "specNoStability"), "id", "1")))
.addFeature(ProvisionedFeatureBuilder.
builder(ResolvedFeatureId.builder(new ResolvedSpecId(FP2_GAV.getProducer(), "specCommunity")).
setParam("id", "1").build()).setConfigParam("idDefault", "1").setConfigParam("idCommunity", "1").build())
.addFeature(ProvisionedFeatureBuilder.
builder(ResolvedFeatureId.builder(new ResolvedSpecId(FP2_GAV.getProducer(), "specDefault")).
setParam("id", "1").build()).setConfigParam("idDefault", "1").build())
setParam("id", "1").build()).setConfigParam("idDefault", "1").setConfigParam("idCommunity", "1").build())

.build())
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ protected ProvisionedState provisionedState() throws ProvisioningDescriptionExce
builder(ResolvedFeatureId.builder(new ResolvedSpecId(FP1_GAV.getProducer(), "specDefault")).
setParam("id", "1").build()).setConfigParam("idDefault", "1").build())
.build())
.addFeaturePack(ProvisionedFeaturePack.builder(FP2_GAV).addPackage("p").addPackage("pDefault").build())
.addFeaturePack(ProvisionedFeaturePack.builder(FP2_GAV).addPackage("p").addPackage("pDefault").addPackage("pCommunity").build())
.addConfig(ProvisionedConfigBuilder.builder()
.setName("configB")
.addFeature(ProvisionedFeatureBuilder.builder(ResolvedFeatureId.create(new ResolvedSpecId(FP2_GAV.getProducer(), "specNoStability"), "id", "1")))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,22 @@ protected ProvisionedState provisionedState() throws ProvisioningDescriptionExce
builder(ResolvedFeatureId.builder(new ResolvedSpecId(FP1_GAV.getProducer(), "specDefault")).
setParam("id", "1").build()).setConfigParam("idDefault", "1").setConfigParam("idCommunity", "1").build())
.build())
.addFeaturePack(ProvisionedFeaturePack.builder(FP2_GAV).addPackage("p").addPackage("pDefault").build())
.addFeaturePack(ProvisionedFeaturePack.builder(FP2_GAV).addPackage("p").addPackage("pDefault").addPackage("pCommunity").addPackage("pPreview").addPackage("pExperimental").build())
.addConfig(ProvisionedConfigBuilder.builder()
.setName("configB")
.addFeature(ProvisionedFeatureBuilder.builder(ResolvedFeatureId.create(new ResolvedSpecId(FP2_GAV.getProducer(), "specNoStability"), "id", "1")))
.addFeature(ProvisionedFeatureBuilder.
builder(ResolvedFeatureId.builder(new ResolvedSpecId(FP2_GAV.getProducer(), "specExperimental")).
setParam("id", "1").build()).setConfigParam("idDefault", "1").setConfigParam("idCommunity", "1").setConfigParam("idPreview", "1").setConfigParam("idExperimental", "1").build())
.addFeature(ProvisionedFeatureBuilder.
builder(ResolvedFeatureId.builder(new ResolvedSpecId(FP2_GAV.getProducer(), "specPreview")).
setParam("id", "1").build()).setConfigParam("idDefault", "1").setConfigParam("idCommunity", "1").setConfigParam("idPreview", "1").setConfigParam("idExperimental", "1").build())
.addFeature(ProvisionedFeatureBuilder.
builder(ResolvedFeatureId.builder(new ResolvedSpecId(FP2_GAV.getProducer(), "specCommunity")).
setParam("id", "1").build()).setConfigParam("idDefault", "1").setConfigParam("idCommunity", "1").setConfigParam("idPreview", "1").build())
.addFeature(ProvisionedFeatureBuilder.
builder(ResolvedFeatureId.builder(new ResolvedSpecId(FP2_GAV.getProducer(), "specDefault")).
setParam("id", "1").build()).setConfigParam("idDefault", "1").build())
setParam("id", "1").build()).setConfigParam("idDefault", "1").setConfigParam("idCommunity", "1").build())
.build())
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,19 @@ protected ProvisionedState provisionedState() throws ProvisioningDescriptionExce
builder(ResolvedFeatureId.builder(new ResolvedSpecId(FP1_GAV.getProducer(), "specDefault")).
setParam("id", "1").build()).setConfigParam("idDefault", "1").setConfigParam("idCommunity", "1").build())
.build())
.addFeaturePack(ProvisionedFeaturePack.builder(FP2_GAV).addPackage("p").addPackage("pDefault").build())
.addFeaturePack(ProvisionedFeaturePack.builder(FP2_GAV).addPackage("p").addPackage("pDefault").addPackage("pCommunity").addPackage("pPreview").build())
.addConfig(ProvisionedConfigBuilder.builder()
.setName("configB")
.addFeature(ProvisionedFeatureBuilder.builder(ResolvedFeatureId.create(new ResolvedSpecId(FP2_GAV.getProducer(), "specNoStability"), "id", "1")))
.addFeature(ProvisionedFeatureBuilder.
builder(ResolvedFeatureId.builder(new ResolvedSpecId(FP2_GAV.getProducer(), "specPreview")).
setParam("id", "1").build()).setConfigParam("idDefault", "1").setConfigParam("idCommunity", "1").setConfigParam("idPreview", "1").build())
.addFeature(ProvisionedFeatureBuilder.
builder(ResolvedFeatureId.builder(new ResolvedSpecId(FP2_GAV.getProducer(), "specCommunity")).
setParam("id", "1").build()).setConfigParam("idDefault", "1").setConfigParam("idCommunity", "1").setConfigParam("idPreview", "1").build())
.addFeature(ProvisionedFeatureBuilder.
builder(ResolvedFeatureId.builder(new ResolvedSpecId(FP2_GAV.getProducer(), "specDefault")).
setParam("id", "1").build()).setConfigParam("idDefault", "1").build())
setParam("id", "1").build()).setConfigParam("idDefault", "1").setConfigParam("idCommunity", "1").build())
.build())
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ protected ProvisioningConfig provisioningConfig() throws ProvisioningDescription
@Override
protected ProvisionedState provisionedState() throws ProvisioningDescriptionException {
return ProvisionedState.builder()
.addFeaturePack(ProvisionedFeaturePack.builder(FP1_100_GAV).addPackage("fp1_1default").addPackage("fp1_2noStability").build())
.addFeaturePack(ProvisionedFeaturePack.builder(FP1_100_GAV).addPackage("fp1_1default").addPackage("fp1_2noStability").addPackage("fp1_3experimental").build())
.addFeaturePack(ProvisionedFeaturePack.builder(FP2_100_GAV).addPackage("fp2_1default").addPackage("fp2_2noStability").addPackage("fp2_3community").addPackage("fp2_4preview").addPackage("fp2_5experimental").build())
.build();
}
Expand Down

0 comments on commit bbd490f

Please sign in to comment.