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

Openshift and Docker Extension Dependencies not activating from an activated Maven Profile #26589

Closed
abeosoft opened this issue Jul 6, 2022 · 11 comments · Fixed by #26926
Closed
Labels
Milestone

Comments

@abeosoft
Copy link

abeosoft commented Jul 6, 2022

Describe the bug

I have a project that uses the Docker and Openshift extensions. I created a maven profile for the Openshift/Docker build. I am using standard Quarkus flags/Environment Variables to configure and activate certain features. I prefer using Maven profiles to isolate different configurations geared towards different environments (local: Minikube vs, Dev: Openshift)
When I add the dependencies in the profile only without including them in the top level Dependencies element, the image doesn't get built or pushed to Openshift. If I add the dependencies at the top level, everything works perfectly
fine and the image is successfully built and deployed to Openshift.

  • Maven Profile

<profile> <id>dev</id> <dependencies> <dependency> <groupId>io.quarkus</groupId> <artifactId>quarkus-container-image-docker</artifactId> </dependency> <dependency> <groupId>io.quarkus</groupId> <artifactId>quarkus-openshift</artifactId> </dependency> </dependencies> </profile>

  • Maven Command

% mvn clean package -Pdev \ -Dquarkus.application.name=my-app \ -Dquarkus.container-image.build=true \ -Dquarkus.container-image.push=true \ -Dquarkus.container-image.builder=docker \ -Dquarkus.container-image.name=my-app\ -Dquarkus.container-image.group=my-team\ -Dquarkus.container-image.tag=v1 \ -Dquarkus.container-image.registry=docker.corp.io \ -Dquarkus.container-image.username=… \ -Dquarkus.container-image.password=…. \ -Dquarkus.kubernetes.deploy=true \ -Dquarkus.kubernetes.deployment-target=openshift \ -Dquarkus.kubernetes-client.trust-certs=true \ -Dquarkus.openshift.labels.application=my-app \ -Dquarkus.openshift.deployment-kind=DeploymentConfig

Expected behavior

When a Maven profile is included, extensions included in the Profile dependencies should activate

Actual behavior

Openshift & Docker Extensions are not activating when included in a declared Maven profile

How to Reproduce?

Create a Quarkus project
Add a Maven profile
Include extensions for Docker & Openshift
Run a Maven command as shown above.
The image will not be built/deployed

Output of uname -a or ver

Darwin Kernel Version 21.5.0

Output of java -version

openjdk version "11.0.15" 2022-04-19 OpenJDK Runtime Environment GraalVM CE 22.1.0 (build 11.0.15+10-jvmci-22.1-b06) OpenJDK 64-Bit Server VM GraalVM CE 22.1.0 (build 11.0.15+10-jvmci-22.1-b06, mixed mode)

GraalVM version (if different from Java)

No response

Quarkus version or git rev

2.9.2.Final and 2.10.1.Final

Build tool (ie. output of mvnw --version or gradlew --version)

3.8.5

Additional information

I have also encountered another issue when running regular maven package build with both docker and openshift extension dependencies are included in the top level dependencies element

  • Maven Command:

% mvn clean package -Dquarkus.container-image.build=false -Dquarkus.container-image.push=false -Dquarkus.kubernetes.deploy=false

  • Error

[ERROR] Failed to execute goal io.quarkus.platform:quarkus-maven-plugin:2.10.1.Final:build (default) on project my-app: Failed to build quarkus application: io.quarkus.builder.BuildException: Build failure: Build failed due to errors [ERROR] [error]: Build step io.quarkus.container.image.deployment.ContainerImageProcessor#publishImageInfo threw an exception: java.lang.IllegalStateException: quarkus-container-image-openshift and quarkus-container-image-docker were detected, at most one container-image extension can be present. [ERROR] Either remove the unneeded ones, or select one by adding the property 'quarkus.container-image.builder=<extension name (without the container-image- prefix)>' in application.properties or as a system property. [ERROR] at io.quarkus.container.image.deployment.ContainerImageCapabilitiesUtil.getActiveContainerImageCapability(ContainerImageCapabilitiesUtil.java:33) [ERROR] at io.quarkus.container.image.deployment.ContainerImageProcessor.ensureSingleContainerImageExtension(ContainerImageProcessor.java:106) [ERROR] at io.quarkus.container.image.deployment.ContainerImageProcessor.publishImageInfo(ContainerImageProcessor.java:52) [ERROR] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [ERROR] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) [ERROR] at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [ERROR] at java.base/java.lang.reflect.Method.invoke(Method.java:566) [ERROR] at io.quarkus.deployment.ExtensionLoader$3.execute(ExtensionLoader.java:944) [ERROR] at io.quarkus.builder.BuildContext.run(BuildContext.java:277) [ERROR] at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18) [ERROR] at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449) [ERROR] at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1478) [ERROR] at java.base/java.lang.Thread.run(Thread.java:829) [ERROR] at org.jboss.threads.JBossThread.run(JBossThread.java:501) [ERROR] -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

@abeosoft abeosoft added the kind/bug Something isn't working label Jul 6, 2022
@quarkus-bot
Copy link

quarkus-bot bot commented Jul 6, 2022

/cc @geoand, @iocanel, @quarkusio/devtools

@geoand
Copy link
Contributor

geoand commented Jul 7, 2022

Do you have a sample project you could share?

Thanks

@geoand geoand added the triage/needs-reproducer We are waiting for a reproducer. label Jul 7, 2022
@abeosoft
Copy link
Author

abeosoft commented Jul 10, 2022

Thanks for the follow-up. yes, I created a sample repository that has the dependencies I need. If you run a simple ./mvnw compile quarkus:dev, you will get an error complaining about the two dependencies: Openshift and Docker being declared. Please refer to the last section in the README file for a sample command. I have seen in one of the forums that there is an option in Quarkus to conditionally include extensions. Can you please point to an article/tutorial in the Quarkus documentation?

Sample Github repository: https://github.com/abeosoft/quarkus-openshift-deploy

Thank you

@geoand geoand removed the triage/needs-reproducer We are waiting for a reproducer. label Jul 11, 2022
@geoand
Copy link
Contributor

geoand commented Jul 11, 2022

Your sample contains both quarkus-container-image-docker and quarkus-openshift as top level dependencies so the error you are seeing is expected.

@geoand geoand closed this as not planned Won't fix, can't repro, duplicate, stale Jul 11, 2022
@geoand geoand added the triage/invalid This doesn't seem right label Jul 11, 2022
@abeosoft
Copy link
Author

I need to build a docker image and then deploy to Openshift. So, how would I conditionally enable an extension? A sample pom.xml will be appreciated. Are there any particular Quarkus best practices or recommendations for deploying to Kubernetes using a CI/CD platform like Jenkins/ArgoCD, etc?

Thank you

@geoand
Copy link
Contributor

geoand commented Jul 13, 2022

I don't have a sample pom, but you would need to make sure that only one extension that makes container images is present in any profile (or alternatively, set the property indicated by the error message).

@abeosoft
Copy link
Author

abeosoft commented Jul 13, 2022

Thanks, 😄 👍

@geoand
Copy link
Contributor

geoand commented Jul 13, 2022

🙏🏼

@abeosoft
Copy link
Author

abeosoft commented Jul 18, 2022

I added the property as you recommended, but I am still getting a build error. Basically, I commented out the docker builder extension dependency and added the following property:

quarkus.container-image.builder=quarkus-container-image-docker

It is not clear what property/value should be. I also tried setting this property in the application.properties, and got the same error

quarkus.container-image.builder=quarkus-docker

Error:

[ERROR] Failed to execute goal io.quarkus.platform:quarkus-maven-plugin:2.10.2.Final:build (build) on project ......... Failed to build quarkus application: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
[ERROR] 	[error]: Build step io.quarkus.kubernetes.deployment.KubernetesDeployer#deploy threw an exception: java.lang.RuntimeException: A Kubernetes deployment was requested but no extension was found to build a container image. Consider adding one of following extensions: "quarkus-container-image-docker", "quarkus-container-image-s2i", "quarkus-container-image-openshift", "quarkus-container-image-buildpack", "quarkus-container-image-jib".
[ERROR] 	at io.quarkus.kubernetes.deployment.KubernetesDeployer.deploy(KubernetesDeployer.java:124)
[ERROR] 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[ERROR] 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[ERROR] 	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[ERROR] 	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
[ERROR] 	at io.quarkus.deployment.ExtensionLoader$3.execute(ExtensionLoader.java:944)
[ERROR] 	at io.quarkus.builder.BuildContext.run(BuildContext.java:277)
[ERROR] 	at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
[ERROR] 	at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449)
[ERROR] 	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1478)
[ERROR] 	at java.base/java.lang.Thread.run(Thread.java:829)
[ERROR] 	at org.jboss.threads.JBossThread.run(JBossThread.java:501)
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

@geoand geoand reopened this Jul 26, 2022
@quarkus-bot quarkus-bot bot removed the triage/invalid This doesn't seem right label Jul 26, 2022
@geoand
Copy link
Contributor

geoand commented Jul 26, 2022

I opened #26926 to improve the error message

geoand added a commit that referenced this issue Jul 26, 2022
Improve error message when multiple container image extensions are present
@geoand
Copy link
Contributor

geoand commented Jul 26, 2022

Closed by #26926

@geoand geoand closed this as completed Jul 26, 2022
@geoand geoand added this to the 2.12 - main milestone Jul 26, 2022
@gsmet gsmet modified the milestones: 2.12 - main, 2.11.1.Final Jul 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants