Skip to content

Commit

Permalink
Merge pull request #28380 from gsmet/2.13.1-backports-2
Browse files Browse the repository at this point in the history
2.13.1 backports 2
  • Loading branch information
gsmet committed Oct 4, 2022
2 parents c26ea0e + 4a29d46 commit 1532056
Show file tree
Hide file tree
Showing 20 changed files with 206 additions and 32 deletions.
4 changes: 2 additions & 2 deletions bom/application/pom.xml
Expand Up @@ -138,7 +138,7 @@
<reactive-streams.version>1.0.3</reactive-streams.version>
<jboss-logging.version>3.5.0.Final</jboss-logging.version>
<mutiny.version>1.7.0</mutiny.version>
<kafka3.version>3.2.1</kafka3.version>
<kafka3.version>3.2.3</kafka3.version>
<lz4.version>1.8.0</lz4.version> <!-- dependency of the kafka-clients that could be overridden by other imported BOMs in the platform -->
<snappy.version>1.1.8.4</snappy.version>
<strimzi-test-container.version>0.100.0</strimzi-test-container.version>
Expand All @@ -148,7 +148,7 @@
<aws-lambda-java-events.version>3.11.0</aws-lambda-java-events.version>
<aws-xray.version>2.11.2</aws-xray.version>
<azure-functions-java-library.version>1.4.2</azure-functions-java-library.version>
<kotlin.version>1.7.10</kotlin.version>
<kotlin.version>1.7.20</kotlin.version>
<kotlin.coroutine.version>1.6.4</kotlin.coroutine.version>
<kotlin-serialization.version>1.4.0</kotlin-serialization.version>
<kubernetes-client.version>5.12.4</kubernetes-client.version> <!-- Please check with Java Operator SDK team before updating -->
Expand Down
2 changes: 1 addition & 1 deletion build-parent/pom.xml
Expand Up @@ -20,7 +20,7 @@
<!-- These properties are needed in order for them to be resolvable by the generated projects -->
<!-- Quarkus uses jboss-parent and it comes with 3.8.1-jboss-1, we don't want that in the templates -->
<compiler-plugin.version>3.8.1</compiler-plugin.version>
<kotlin.version>1.7.10</kotlin.version>
<kotlin.version>1.7.20</kotlin.version>
<dokka.version>1.7.10</dokka.version>
<scala.version>2.13.8</scala.version>
<scala-maven-plugin.version>4.7.1</scala-maven-plugin.version>
Expand Down
Expand Up @@ -97,7 +97,7 @@ public void shouldReturnMultipleOutputSourceDirectories() {

@Test
public void shouldNotFailOnProjectDependenciesWithoutMain() throws IOException {
var kotlinVersion = System.getProperty("kotlin_version", "1.7.10");
var kotlinVersion = System.getProperty("kotlin_version", "1.7.20");
var settingFile = testProjectDir.resolve("settings.gradle.kts");
var mppProjectDir = testProjectDir.resolve("mpp");
var quarkusProjectDir = testProjectDir.resolve("quarkus");
Expand Down
2 changes: 1 addition & 1 deletion devtools/gradle/gradle.properties
@@ -1,2 +1,2 @@
version = 999-SNAPSHOT
kotlin_version = 1.7.10
kotlin_version = 1.7.20
Expand Up @@ -335,7 +335,13 @@ private RegistryImage toRegistryImage(ImageReference imageReference, Optional<St
registryImage.addCredentialRetriever(credentialRetrieverFactory.dockerConfig());
String dockerConfigEnv = System.getenv().get("DOCKER_CONFIG");
if (dockerConfigEnv != null) {
registryImage.addCredentialRetriever(credentialRetrieverFactory.dockerConfig(Path.of(dockerConfigEnv)));
Path dockerConfigPath = Path.of(dockerConfigEnv);
if (Files.isDirectory(dockerConfigPath)) {
// this matches jib's behaviour,
// see https://github.com/GoogleContainerTools/jib/blob/master/jib-maven-plugin/README.md#authentication-methods
dockerConfigPath = dockerConfigPath.resolve("config.json");
}
registryImage.addCredentialRetriever(credentialRetrieverFactory.dockerConfig(dockerConfigPath));
}
}
return registryImage;
Expand Down Expand Up @@ -804,4 +810,4 @@ public boolean test(Path path) {
return path.getFileName().toString().endsWith(".class");
}
}
}
}
@@ -1,5 +1,7 @@
package io.quarkus.kubernetes.deployment;

import static io.quarkus.deployment.pkg.steps.JarResultBuildStep.DEFAULT_FAST_JAR_DIRECTORY_NAME;
import static io.quarkus.deployment.pkg.steps.JarResultBuildStep.QUARKUS_RUN_JAR;
import static io.quarkus.kubernetes.deployment.Constants.KUBERNETES;
import static io.quarkus.kubernetes.spi.KubernetesDeploymentTargetBuildItem.mergeList;

Expand Down Expand Up @@ -42,7 +44,9 @@
import io.quarkus.deployment.builditem.GeneratedFileSystemResourceBuildItem;
import io.quarkus.deployment.builditem.LaunchModeBuildItem;
import io.quarkus.deployment.pkg.PackageConfig;
import io.quarkus.deployment.pkg.builditem.LegacyJarRequiredBuildItem;
import io.quarkus.deployment.pkg.builditem.OutputTargetBuildItem;
import io.quarkus.deployment.pkg.builditem.UberJarRequiredBuildItem;
import io.quarkus.deployment.util.FileUtil;
import io.quarkus.kubernetes.spi.ConfigurationSupplierBuildItem;
import io.quarkus.kubernetes.spi.ConfiguratorBuildItem;
Expand Down Expand Up @@ -93,6 +97,8 @@ public void preventContainerPush(ContainerImageConfig containerImageConfig,
@BuildStep(onlyIfNot = IsTest.class)
public void build(ApplicationInfoBuildItem applicationInfo,
OutputTargetBuildItem outputTarget,
List<UberJarRequiredBuildItem> uberJarRequired,
List<LegacyJarRequiredBuildItem> legacyJarRequired,
PackageConfig packageConfig,
KubernetesConfig kubernetesConfig,
OpenshiftConfig openshiftConfig,
Expand Down Expand Up @@ -125,8 +131,7 @@ public void build(ApplicationInfoBuildItem applicationInfo,
.map(DeploymentTargetEntry::getName)
.collect(Collectors.toSet());

Path artifactPath = outputTarget.getOutputDirectory()
.resolve(String.format(OUTPUT_ARTIFACT_FORMAT, outputTarget.getBaseName(), packageConfig.getRunnerSuffix()));
Path artifactPath = getRunner(outputTarget, packageConfig, uberJarRequired, legacyJarRequired);

try {
// by passing false to SimpleFileWriter, we ensure that no files are actually written during this phase
Expand Down Expand Up @@ -240,4 +245,33 @@ public void build(ApplicationInfoBuildItem applicationInfo,
}

}

/**
* This method is based on the logic in {@link io.quarkus.deployment.pkg.steps.JarResultBuildStep#buildRunnerJar}.
* Note that we cannot consume the {@link io.quarkus.deployment.pkg.builditem.JarBuildItem} because it causes build cycle
* exceptions since we need to support adding generated resources into the JAR file (see
* https://github.com/quarkusio/quarkus/pull/20113).
*/
private Path getRunner(OutputTargetBuildItem outputTarget,
PackageConfig packageConfig,
List<UberJarRequiredBuildItem> uberJarRequired,
List<LegacyJarRequiredBuildItem> legacyJarRequired) {
if (!legacyJarRequired.isEmpty() || packageConfig.type.equalsIgnoreCase(PackageConfig.LEGACY)
|| !uberJarRequired.isEmpty() || packageConfig.type.equalsIgnoreCase(PackageConfig.UBER_JAR)) {
// the jar is a legacy jar or uber jar, the next logic applies:
return outputTarget.getOutputDirectory()
.resolve(outputTarget.getBaseName() + packageConfig.getRunnerSuffix() + ".jar");
}

// otherwise, it's a thin jar:
Path buildDir;

if (packageConfig.outputDirectory.isPresent()) {
buildDir = outputTarget.getOutputDirectory();
} else {
buildDir = outputTarget.getOutputDirectory().resolve(DEFAULT_FAST_JAR_DIRECTORY_NAME);
}

return buildDir.resolve(QUARKUS_RUN_JAR);
}
}
Expand Up @@ -17,6 +17,7 @@ private static PortBuilder convert(PortConfig port) {
port.path.ifPresent(v -> b.withPath(v));
port.hostPort.ifPresent(v -> b.withHostPort(v));
port.containerPort.ifPresent(v -> b.withContainerPort(v));
b.withProtocol(port.protocol);
return b;
}
}
Expand Up @@ -153,17 +153,41 @@ public Uni<SecurityIdentity> apply(TenantConfigContext tenantContext) {
LOG.debugf("Authentication has failed, error: %s, description: %s", error, errorDescription);

if (oidcTenantConfig.authentication.errorPath.isPresent()) {
URI absoluteUri = URI.create(context.request().absoluteURI());
Uni<TenantConfigContext> resolvedContext = resolver.resolveContext(context);
return resolvedContext.onItem()
.transformToUni(new Function<TenantConfigContext, Uni<? extends SecurityIdentity>>() {
@Override
public Uni<SecurityIdentity> apply(TenantConfigContext tenantContext) {
URI absoluteUri = URI.create(context.request().absoluteURI());

String userQuery = null;

// This is an original redirect from IDP, check if the original request path and query need to be restored
CodeAuthenticationStateBean stateBean = getCodeAuthenticationBean(parsedStateCookieValue,
tenantContext);
if (stateBean != null && stateBean.getRestorePath() != null) {
String restorePath = stateBean.getRestorePath();
int userQueryIndex = restorePath.indexOf("?");
if (userQueryIndex >= 0 && userQueryIndex + 1 < restorePath.length()) {
userQuery = restorePath.substring(userQueryIndex + 1);
}
}

StringBuilder errorUri = new StringBuilder(buildUri(context,
isForceHttps(oidcTenantConfig),
absoluteUri.getAuthority(),
oidcTenantConfig.authentication.errorPath.get()));
errorUri.append('?').append(getRequestParametersAsQuery(absoluteUri, requestParams, oidcTenantConfig));
StringBuilder errorUri = new StringBuilder(buildUri(context,
isForceHttps(oidcTenantConfig),
absoluteUri.getAuthority(),
oidcTenantConfig.authentication.errorPath.get()));
errorUri.append('?')
.append(getRequestParametersAsQuery(absoluteUri, requestParams, oidcTenantConfig));
if (userQuery != null) {
errorUri.append('&').append(userQuery);
}

String finalErrorUri = errorUri.toString();
LOG.debugf("Error URI: %s", finalErrorUri);
return Uni.createFrom().failure(new AuthenticationRedirectException(finalErrorUri));
String finalErrorUri = errorUri.toString();
LOG.debugf("Error URI: %s", finalErrorUri);
return Uni.createFrom().failure(new AuthenticationRedirectException(finalErrorUri));
}
});
} else {
LOG.error(
"Authentication has failed but no error handler is found, completing the code flow with HTTP status 401");
Expand Down
Expand Up @@ -6,6 +6,7 @@
import org.jboss.shrinkwrap.api.asset.StringAsset;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

Expand Down Expand Up @@ -42,6 +43,7 @@ public JavaArchive get() {

//see https://github.com/quarkusio/quarkus/issues/19180
@Test
@Disabled("flaky")
public void testContinuousTestingScenario1() {
ContinuousTestingTestUtils utils = new ContinuousTestingTestUtils();
var result = utils.waitForNextCompletion();
Expand All @@ -66,6 +68,7 @@ public void testContinuousTestingScenario1() {
}

@Test
@Disabled("flaky")
public void testContinuousTestingScenario2() {
ContinuousTestingTestUtils utils = new ContinuousTestingTestUtils();
var result = utils.waitForNextCompletion();
Expand Down
Expand Up @@ -6,6 +6,7 @@
import org.jboss.shrinkwrap.api.asset.StringAsset;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

Expand Down Expand Up @@ -37,6 +38,7 @@ public JavaArchive get() {
* See https://github.com/quarkusio/quarkus/issues/19180.
*/
@Test
@Disabled("flaky")
public void testContinuousTestingScenario3() {
ContinuousTestingTestUtils utils = new ContinuousTestingTestUtils();
var result = utils.waitForNextCompletion();
Expand Down
2 changes: 1 addition & 1 deletion independent-projects/arc/tests/pom.xml
Expand Up @@ -48,7 +48,7 @@
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib</artifactId>
<version>1.7.10</version>
<version>1.7.20</version>
<scope>test</scope>
</dependency>

Expand Down
Expand Up @@ -2,7 +2,7 @@
package io.quarkus.it.kubernetes;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.io.IOException;
import java.nio.file.Path;
Expand All @@ -11,6 +11,7 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

import io.fabric8.kubernetes.api.model.ContainerPort;
import io.fabric8.kubernetes.api.model.HasMetadata;
import io.fabric8.kubernetes.api.model.Service;
import io.fabric8.kubernetes.api.model.apps.Deployment;
Expand All @@ -22,12 +23,14 @@

public class KubernetesServiceMappingTest {

private static final String APP_NAME = "kubernetes-service-mapping";

@RegisterExtension
static final QuarkusProdModeTest config = new QuarkusProdModeTest()
.withApplicationRoot((jar) -> jar.addClasses(GreetingResource.class))
.setApplicationName("kubernetes-service-mapping")
.setApplicationName(APP_NAME)
.setApplicationVersion("0.1-SNAPSHOT")
.withConfigurationResource("kubernetes-service-mapping.properties")
.withConfigurationResource(APP_NAME + ".properties")
.setLogFileName("k8s.log")
.setForcedDependencies(List.of(Dependency.of("io.quarkus", "quarkus-kubernetes", Version.getVersion())));

Expand All @@ -51,7 +54,16 @@ public void assertGeneratedResources() throws IOException {
assertThat(d.getSpec()).satisfies(deploymentSpec -> {
assertThat(deploymentSpec.getTemplate()).satisfies(t -> {
assertThat(t.getSpec()).satisfies(podSpec -> {

List<ContainerPort> ports = podSpec.getContainers().get(0).getPorts();
assertThat(ports.size()).isEqualTo(2);
assertTrue(ports.stream().anyMatch(port -> "http".equals(port.getName())
&& port.getContainerPort() == 8080
&& "TCP".equals(port.getProtocol())),
() -> "http port not found in the pod containers!");
assertTrue(ports.stream().anyMatch(port -> "debug".equals(port.getName())
&& port.getContainerPort() == 5005
&& "UDP".equals(port.getProtocol())),
() -> "debug port not found in the pod containers!");
});
});
});
Expand All @@ -62,10 +74,19 @@ public void assertGeneratedResources() throws IOException {
assertThat(m.getName()).isEqualTo("kubernetes-service-mapping");
});
assertThat(s.getSpec()).satisfies(serviceSpec -> {
assertThat(serviceSpec.getPorts()).singleElement().satisfies(p -> {
assertEquals(8080, p.getTargetPort().getIntVal());
assertEquals(8080, p.getPort());
});
assertThat(serviceSpec.getPorts().size()).isEqualTo(2);
assertTrue(serviceSpec.getPorts().stream().anyMatch(port -> "http".equals(port.getName())
&& port.getTargetPort().getIntVal() == 8080
// Dekorate issue: https://github.com/dekorateio/dekorate/issues/1068
// && "TCP".equals(port.getProtocol())
&& port.getPort() == 8080),
() -> "http port not found in the service!");
assertTrue(serviceSpec.getPorts().stream().anyMatch(port -> "debug".equals(port.getName())
&& port.getTargetPort().getIntVal() == 5005
// Dekorate issue: https://github.com/dekorateio/dekorate/issues/1068
// && "UDP".equals(port.getProtocol())
&& port.getPort() == 5005),
() -> "debug port not found in the service!");
});
});

Expand Down
@@ -0,0 +1,66 @@
package io.quarkus.it.kubernetes;

import static org.assertj.core.api.Assertions.assertThat;

import java.io.IOException;
import java.nio.file.Path;
import java.util.List;

import org.assertj.core.api.AbstractObjectAssert;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

import io.fabric8.kubernetes.api.model.EnvVar;
import io.fabric8.kubernetes.api.model.HasMetadata;
import io.fabric8.kubernetes.api.model.PodSpec;
import io.quarkus.builder.Version;
import io.quarkus.maven.dependency.Dependency;
import io.quarkus.test.ProdBuildResults;
import io.quarkus.test.ProdModeTestResults;
import io.quarkus.test.QuarkusProdModeTest;

public class OpenshiftWithKubernetesConfigTest {

private static final String NAME = "openshift-with-kubernetes-config";

@RegisterExtension
static final QuarkusProdModeTest config = new QuarkusProdModeTest()
.withApplicationRoot((jar) -> jar.addClasses(GreetingResource.class))
.setApplicationName(NAME)
.setApplicationVersion("0.1-SNAPSHOT")
.setForcedDependencies(List.of(Dependency.of("io.quarkus", "quarkus-openshift", Version.getVersion()),
Dependency.of("io.quarkus", "quarkus-kubernetes-config", Version.getVersion())));

@ProdBuildResults
private ProdModeTestResults prodModeTestResults;

@Test
public void assertGeneratedResources() throws IOException {
Path kubernetesDir = prodModeTestResults.getBuildDir().resolve("kubernetes");

assertThat(kubernetesDir)
.isDirectoryContaining(p -> p.getFileName().endsWith("openshift.json"))
.isDirectoryContaining(p -> p.getFileName().endsWith("openshift.yml"));
List<HasMetadata> openshiftList = DeserializationUtil.deserializeAsList(
kubernetesDir.resolve("openshift.yml"));

assertThat(openshiftList).filteredOn(h -> "DeploymentConfig".equals(h.getKind())).singleElement().satisfies(h -> {
assertThat(h.getMetadata()).satisfies(m -> {
assertThat(m.getName()).isEqualTo(NAME);
assertThat(m.getLabels().get("app.openshift.io/runtime")).isEqualTo("quarkus");
});

AbstractObjectAssert<?, ?> specAssert = assertThat(h).extracting("spec");
specAssert.extracting("template").extracting("spec").isInstanceOfSatisfying(PodSpec.class,
podSpec -> {
assertThat(podSpec.getContainers()).singleElement().satisfies(container -> {
List<EnvVar> envVars = container.getEnv();
assertThat(envVars).anySatisfy(envVar -> {
assertThat(envVar.getName()).isEqualTo("JAVA_APP_JAR");
assertThat(envVar.getValue()).isEqualTo("/deployments/quarkus-run.jar");
});
});
});
});
}
}

0 comments on commit 1532056

Please sign in to comment.