Open cmoulliard opened 11 months ago
/cc @geoand (jib,kubernetes), @iocanel (kubernetes)
Can you try without -Dquarkus.container-image.build=true
please?
If I remove the parameter, then no build (I think so) is taking place. I got another non related error when deployment is taking place
args:
- '-s'
- /workspace/maven-settings/settings.xml
- quarkus:deploy
- '-B'
- '-Dquarkus.kubernetes.deploy=true'
- '-Dquarkus.log.level=DEBUG'
- '-Dmaven.repo.local=/.m2'
command:
- /usr/bin/mvn
computeResources: {}
env:
- name: DOCKER_HOST
value: tcp://localhost:2376
- name: TESTCONTAINERS_RYUK_DISABLED
value: 'true'
image: gcr.io/cloud-builders/mvn@sha256:57523fc43394d6d9d2414ee8d1c85ed7a13460cbb268c3cd16d28cfb3859e641
name: mvn-goals
workingDir: /workspace/project-dir/.
=>
INFO] Downloaded from maven.org: https://repo1.maven.org/maven2/io/quarkus/platform/quarkus-bom-quarkus-platform-properties/3.0.3.Final/quarkus-bom-quarkus-platform-properties-3.0.3.Final.properties (668 B at 18 kB/s)
[WARNING] [io.quarkus.runtime.logging.LoggingSetupRecorder] Log level TRACE for category 'org.testcontainers' set below minimum logging level DEBUG, promoting it to DEBUG. Set the build time configuration property 'quarkus.log.category."org.testcontainers".min-level' to 'TRACE' to avoid this warning
[INFO] [io.quarkus.kubernetes.deployment.KubernetesDeployer] Deploying to kubernetes server: https://10.96.0.1:443/ in namespace: default.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:34 min
[INFO] Finished at: 2023-12-04T08:08:53Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal io.quarkus.platform:quarkus-maven-plugin:3.0.3.Final:deploy (default-cli) on project quarkus-helloworld: 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: io.fabric8.kubernetes.client.KubernetesClientException: Failure executing: DELETE at: https://10.96.0.1:443/api/v1/namespaces/default/services/quarkus-helloworld. Message: Forbidden!Configured service account doesn't have access. Service account may have been revoked. services "quarkus-helloworld" is forbidden: User "system:serviceaccount:default:default" cannot delete resource "services" in API group "" in the namespace "default".
-Dquarkus.kubernetes.deploy=true
should be enough to trigger the build
Actually, -Dquarkus.kubernetes.deploy=true
works with mnv package
. When using the CLI you should be following https://quarkus.io/blog/quarkus-cli/#deploying-using-the-quarkus-cli
Remarks:
gcr.io/cloud-builders/mvn
maven package
, we are getting back the same error. Take care that doing the test locally is completely different from doing that in a container (= pod) !Params
args:
- '-s'
- /workspace/maven-settings/settings.xml
- package
- '-DskipTests'
- '-B'
- '-Dquarkus.kubernetes.deploy=true'
- '-Dquarkus.log.level=DEBUG'
- '-Dmaven.repo.local=/.m2'
command:
- /usr/bin/mvn
computeResources: {}
env:
- name: DOCKER_HOST
value: tcp://localhost:2376
- name: TESTCONTAINERS_RYUK_DISABLED
value: 'true'
image: gcr.io/cloud-builders/mvn@sha256:57523fc43394d6d9d2414ee8d1c85ed7a13460cbb268c3cd16d28cfb3859e641
name: mvn-goals
workingDir: /workspace/project-dir/.
=>
[ERROR] Failed to execute goal io.quarkus.platform:quarkus-maven-plugin:3.0.3.Final:build (default) on project quarkus-helloworld: Failed to build quarkus application: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
[ERROR] [error]: Build step io.quarkus.container.image.jib.deployment.JibProcessor#buildFromJar threw an exception: java.lang.IllegalStateException: No container runtime was found. Make sure you have either Docker or Podman installed in your environment.
[ERROR] at io.quarkus.runtime.util.ContainerRuntimeUtil.detectContainerRuntime([ContainerRuntimeUtil.java:52](http://containerruntimeutil.java:52/))
[ERROR] at io.quarkus.runtime.util.ContainerRuntimeUtil.detectContainerRuntime([ContainerRuntimeUtil.java:38](http://containerruntimeutil.java:38/))
[ERROR] at io.quarkus.container.image.jib.deployment.JibProcessor.createContainerizer([JibProcessor.java:290](http://jibprocessor.java:290/))
[ERROR] at io.quarkus.container.image.jib.deployment.JibProcessor.containerize([JibProcessor.java:235](http://jibprocessor.java:235/))
[ERROR] at io.quarkus.container.image.jib.deployment.JibProcessor.buildFromJar([JibProcessor.java:181](http://jibprocessor.java:181/))
So the problem is coming from this code which is returning No container runtime
- https://github.com/quarkusio/quarkus/blob/4c3264e59521a72121423ff7783cc3572905ea33/core/runtime/src/main/java/io/quarkus/runtime/util/ContainerRuntimeUtil.java#L41-L65
I have the impression that there is no logic at all.
Why ? If I just include the parameter - -Dquarkus.container-image.image=quay.io/ch007m/quarkus-dev-vm:latest
and we remove -Dquarkus.container-image.build=true
then jib is working properly
- quarkus:deploy
- -B
- -Dquarkus.container-image.image=quay.io/ch007m/quarkus-dev-vm:latest
- -Dquarkus.kubernetes.deploy=true
- -Dquarkus.log.level=DEBUG
taskRef:
==>
[maven-generate-deploy : mvn-goals] [INFO] --- quarkus-maven-plugin:3.0.3.Final:deploy (default-cli) @ quarkus-helloworld ---
[maven-generate-deploy : mvn-goals] [WARNING] [io.quarkus.runtime.logging.LoggingSetupRecorder] Log level TRACE for category 'org.testcontainers' set below minimum logging level DEBUG, promoting it to DEBUG. Set the build time configuration property 'quarkus.log.category."org.testcontainers".min-level' to 'TRACE' to avoid this warning
[maven-generate-deploy : mvn-goals] [INFO] [io.quarkus.container.image.jib.deployment.JibProcessor] Starting (local) container image build for jar using jib.
[maven-generate-deploy : mvn-goals] [WARNING] [io.quarkus.container.image.jib.deployment.JibProcessor] Base image 'registry.access.redhat.com/ubi8/openjdk-11-runtime:1.15' does not use a specific image digest - build may not be reproducible
[maven-generate-deploy : mvn-goals] [INFO] [io.quarkus.container.image.jib.deployment.JibProcessor] Using base image with digest: sha256:6ae709d227dfbf76b1b5b705fd14d55e471cade405f492e04b4866c1a4ab1425
[maven-generate-deploy : mvn-goals] [INFO] ------------------------------------------------------------------------
[maven-generate-deploy : mvn-goals] [INFO] BUILD FAILURE
[maven-generate-deploy : mvn-goals] [INFO] ------------------------------------------------------------------------
[maven-generate-deploy : mvn-goals] [INFO] Total time: 13.794 s
[maven-generate-deploy : mvn-goals] [INFO] Finished at: 2023-12-05T14:30:50Z
[maven-generate-deploy : mvn-goals] [INFO] ------------------------------------------------------------------------
[maven-generate-deploy : mvn-goals] [ERROR] Failed to execute goal io.quarkus.platform:quarkus-maven-plugin:3.0.3.Final:deploy (default-cli) on project quarkus-helloworld: Failed to build quarkus application: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
[maven-generate-deploy : mvn-goals] [ERROR] [error]: Build step io.quarkus.container.image.jib.deployment.JibProcessor#buildFromJar threw an exception: java.lang.RuntimeException: Unable to create container image
[maven-generate-deploy : mvn-goals] [ERROR] at io.quarkus.container.image.jib.deployment.JibProcessor.containerize(JibProcessor.java:255)
[maven-generate-deploy : mvn-goals] [ERROR] at io.quarkus.container.image.jib.deployment.JibProcessor.buildFromJar(JibProcessor.java:181)
[maven-generate-deploy : mvn-goals] [ERROR] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[maven-generate-deploy : mvn-goals] [ERROR] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[maven-generate-deploy : mvn-goals] [ERROR] at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[maven-generate-deploy : mvn-goals] [ERROR] at java.base/java.lang.reflect.Method.invoke(Method.java:564)
[maven-generate-deploy : mvn-goals] [ERROR] at io.quarkus.deployment.ExtensionLoader$3.execute(ExtensionLoader.java:909)
[maven-generate-deploy : mvn-goals] [ERROR] at io.quarkus.builder.BuildContext.run(BuildContext.java:282)
[maven-generate-deploy : mvn-goals] [ERROR] at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
[maven-generate-deploy : mvn-goals] [ERROR] at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2513)
[maven-generate-deploy : mvn-goals] [ERROR] at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1538)
[maven-generate-deploy : mvn-goals] [ERROR] at java.base/java.lang.Thread.run(Thread.java:832)
[maven-generate-deploy : mvn-goals] [ERROR] at org.jboss.threads.JBossThread.run(JBossThread.java:501)
[maven-generate-deploy : mvn-goals] [ERROR] Caused by: com.google.cloud.tools.jib.api.RegistryUnauthorizedException: Unauthorized for quay.io/ch007m/quarkus-dev-vm
[maven-generate-deploy : mvn-goals] [ERROR] at com.google.cloud.tools.jib.registry.RegistryEndpointCaller.call(RegistryEndpointCaller.java:163)
[maven-generate-deploy : mvn-goals] [ERROR] at com.google.cloud.tools.jib.registry.RegistryEndpointCaller.call(RegistryEndpointCaller.java:114)
[maven-generate-deploy : mvn-goals] [ERROR] at com.google.cloud.tools.jib.registry.RegistryClient.callRegistryEndpoint(RegistryClient.java:623)
[maven-generate-deploy : mvn-goals] [ERROR] at com.google.cloud.tools.jib.registry.RegistryClient.pushBlob(RegistryClient.java:549)
[maven-generate-deploy : mvn-goals] [ERROR] at com.google.cloud.tools.jib.builder.steps.PushBlobStep.call(PushBlobStep.java:89)
[maven-generate-deploy : mvn-goals] [ERROR] at com.google.cloud.tools.jib.builder.steps.PushLayerStep.call(PushLayerStep.java:92)
[maven-generate-deploy : mvn-goals] [ERROR] at com.google.cloud.tools.jib.builder.steps.PushLayerStep.call(PushLayerStep.java:33)
[maven-generate-deploy : mvn-goals] [ERROR] at com.google.common.util.concurrent.TrustedListenableFutureTask$TrustedFutureInterruptibleTask.runInterruptibly(TrustedListenableFutureTask.java:131)
[maven-generate-deploy : mvn-goals] [ERROR] at com.google.common.util.concurrent.InterruptibleTask.run(InterruptibleTask.java:74)
[maven-generate-deploy : mvn-goals] [ERROR] at com.google.common.util.concurrent.TrustedListenableFutureTask.run(TrustedListenableFutureTask.java:82)
[maven-generate-deploy : mvn-goals] [ERROR] at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
[maven-generate-deploy : mvn-goals] [ERROR] at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
[maven-generate-deploy : mvn-goals] [ERROR] at java.base/java.lang.Thread.run(Thread.java:832)
[maven-generate-deploy : mvn-goals] [ERROR] Caused by: com.google.cloud.tools.jib.http.ResponseException: 401 UNAUTHORIZED
[maven-generate-deploy : mvn-goals] [ERROR] POST https://quay.io/v2/ch007m/quarkus-dev-vm/blobs/uploads/
[maven-generate-deploy : mvn-goals] [ERROR] {"errors":[{"code":"UNAUTHORIZED","detail":{},"message":"access to the requested resource is not authorized"}]}
[maven-generate-deploy : mvn-goals] [ERROR]
[maven-generate-deploy : mvn-goals] [ERROR] at com.google.cloud.tools.jib.http.FailoverHttpClient.call(FailoverHttpClient.java:355)
[maven-generate-deploy : mvn-goals] [ERROR] at com.google.cloud.tools.jib.http.FailoverHttpClient.call(FailoverHttpClient.java:266)
[maven-generate-deploy : mvn-goals] [ERROR] at com.google.cloud.tools.jib.registry.RegistryEndpointCaller.call(RegistryEndpointCaller.java:138)
[maven-generate-deploy : mvn-goals] [ERROR] ... 12 more
[maven-generate-deploy : mvn-goals] [ERROR] Caused by: com.google.api.client.http.HttpResponseException: 401 UNAUTHORIZED
[maven-generate-deploy : mvn-goals] [ERROR] POST https://quay.io/v2/ch007m/quarkus-dev-vm/blobs/uploads/
[maven-generate-deploy : mvn-goals] [ERROR] {"errors":[{"code":"UNAUTHORIZED","detail":{},"message":"access to the requested resource is not authorized"}]}
[maven-generate-deploy : mvn-goals] [ERROR]
[maven-generate-deploy : mvn-goals] [ERROR] at com.google.api.client.http.HttpResponseException$Builder.build(HttpResponseException.java:293)
[maven-generate-deploy : mvn-goals] [ERROR] at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:1118)
[maven-generate-deploy : mvn-goals] [ERROR] at com.google.cloud.tools.jib.http.FailoverHttpClient.call(FailoverHttpClient.java:349)
[maven-generate-deploy : mvn-goals] [ERROR] ... 14 more
[maven-generate-deploy : mvn-goals] [ERROR] -> [Help 1]
[maven-generate-deploy : mvn-goals] [ERROR]
NOTE: There is an unauthorized error which is not at all related to the fact that jib worked now !
Is this still an issue?
Yes. I did a new test using 3.9.2 and got again same error with a project having jib extension
[ERROR] Failed to execute goal io.quarkus.platform:quarkus-maven-plugin:3.9.2:deploy (default-cli) on project my-quarkus-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.jib.deployment.JibProcessor#buildFromJar threw an exception:
java.lang.IllegalStateException: No container runtime was found. Make sure you have either Docker or Podman installed in your environment.
[ERROR] at io.quarkus.deployment.util.ContainerRuntimeUtil.detectContainerRuntime(ContainerRuntimeUtil.java:58)
[ERROR] at io.quarkus.deployment.util.ContainerRuntimeUtil.detectContainerRuntime(ContainerRuntimeUtil.java:44)
[ERROR] at io.quarkus.container.image.jib.deployment.JibProcessor.createContainerizer(JibProcessor.java:307)
[ERROR] at io.quarkus.container.image.jib.deployment.JibProcessor.containerize(JibProcessor.java:252)
[ERROR] at io.quarkus.container.image.jib.deployment.JibProcessor.buildFromJar(JibProcessor.java:197)
[ERROR] at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
[ERROR] at java.base/java.lang.reflect.Method.invoke(Method.java:580)
[ERROR] at io.quarkus.deployment.ExtensionLoader$3.execute(ExtensionLoader.java:849)
[ERROR] at io.quarkus.builder.BuildContext.run(BuildContext.java:256)
[ERROR] at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
[
- 'quarkus:deploy'
- '-B'
- '-Dquarkus.kubernetes.deploy=false'
- '-Dquarkus.container-image.build=true'
kubectl apply -f ./k8s
I had the same issue, but it turned out I had forgotten to specify -Dquarkus.container-image.push=true
, which meant a local build was done, which does require docker (as also detailed here).
I know, I think, why we have this issue as quarkus executes
commands
// https://github.com/quarkusio/quarkus/blob/7c176b698e1c86228ebd08de2c248d2c2dcf90d0/core/deployment/src/main/java/io/quarkus/deployment/util/ContainerRuntimeUtil.java#L234
private static String getVersionOutputFor(ContainerRuntime containerRuntime) {
Process versionProcess = null;
try {
final ProcessBuilder pb = new ProcessBuilder(containerRuntime.getExecutableName(), "--version")
.redirectErrorStream(true);
versionProcess = pb.start();
final int timeoutS = 10;
if (versionProcess.waitFor(timeoutS, TimeUnit.SECONDS)) {
return new String(versionProcess.getInputStream().readAllBytes(), StandardCharsets.UTF_8);
} else {
log.debugf("Failure. It took command %s more than %d seconds to execute.", containerRuntime.getExecutableName(),
timeoutS);
return "";
}
}
to determine if a docker
, podman
executable returns a response.
Of course, that works locally as the user has most probably installed podman
or docker
but when the code is executed in a pod using as image by example maven
then no executable like docker or podman exist.
In this case, we should adopt a different strategy which is perhaps to curl the HTTP API endpoint
Example performed within a podman VM on macos where the API is exposed as service
curl -s --unix-socket /run/user/501/podman/podman.sock http://10.89.0.1:2375/v4.4.0/libpod/info
{"host":{"arch":"arm64","buildahVersion":"1.35.4","cgroupManager":"systemd","cgroupVersion":"v2","cgroupControllers":["cpu","io","memory","pids"],"conmon":{"package":"conmon-2.1.10-1.fc40.aarch64","path":"/usr/bin/conmon","version":"conmon version 2.1.10, commit: "},"cpus":6,"cpuUtilization":{"userPercent":3.01,"systemPercent":1.5,"idlePercent":95.49},"databaseBackend":"sqlite","distribution":{"distribution":"fedora","variant":"coreos","version":"40"},"eventLogger":"journald","freeLocks":2048,"hostname":"localhost.localdomain","idMappings":{"gidmap":[{"container_id":0,"host_id":1000,"size":1},{"container_id":1,"host_id":100000,"size":1000000}],"uidmap":[{"container_id":0,"host_id":501,"size":1},...
We sdhould review the logic of the build image plugin as at the beginning of the code processed Tescontaine has been able to find the proper information and can access the container API/Server. See hereafter
[INFO] --- quarkus:3.15.1:build (default) @ code-with-quarkus ---
[INFO] Testcontainers version: 1.20.1
[INFO] Found Docker environment with Environment variables, system properties and defaults. Resolved dockerHost=tcp://10.89.0.1:2375
[INFO] Docker host IP address is 10.89.0.1
[INFO] Connected to docker:
Server Version: 5.0.3
API Version: 1.41
Operating System: fedora
Total Memory: 5487 MB
[WARNING]
********************************************************************************
Ryuk has been disabled. This can cause unexpected behavior in your environment.
********************************************************************************
[INFO] Checking the system...
[INFO] ✔︎ Docker server version should be at least 1.6.0
[INFO] [io.quarkus.container.image.docker.common.deployment.CommonProcessor] Starting (local) container image build for jar using podman
[INFO] [io.quarkus.kubernetes.deployment.PropertyUtil] Kubernetes manifests are generated with 'The container port http' having default value '8080'. The app and manifests will get out of sync if the property 'quarkus.http.port' is changed at runtime.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 36.435 s
[INFO] Finished at: 2024-10-03T14:00:33Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal io.quarkus.platform:quarkus-maven-plugin:3.15.1:build (default) on project code-with-quarkus: Failed to build quarkus application: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
[ERROR] [error]: Build step io.quarkus.container.image.podman.deployment.PodmanProcessor#podmanBuildFromJar threw an exception: java.lang.IllegalStateException: No container runtime was found. Make sure you have either Docker or Podman installed in your environment.
[ERROR] at io.quarkus.deployment.util.ContainerRuntimeUtil.detectContainerRuntime([ContainerRuntimeUtil.java:72](http://containerruntimeutil.java:72/))
[ERROR] at io.quarkus.deployment.util.ContainerRuntimeUtil.detectContainerRuntime([ContainerRuntimeUtil.java:55](http://containerruntimeutil.java:55/))
[ERROR] at io.quarkus.deployment.util.ContainerRuntimeUtil.detectContainerRuntime([ContainerRuntimeUtil.java:51](http://containerruntimeutil.java:51/))
[ERROR] at io.quarkus.container.image.docker.common.deployment.CommonProcessor.lambda$getExecutableName$9([CommonProcessor.java:262](http://commonprocessor.java:262/))
...`
FYI: @iocanel @geoand
I have no knowledge of podman, so I can't comment. But if you want to provide a PR addressing the issue, that would be great
I have no knowledge of podman, so I can't comment.
This is completely independent of the executable detected within the code docker
or podman
as the ProcessBuilder()
will always fail when executed in a container or pod (= container) as the container, most probably, will never include such executables
I will (try) work on a PR as soon as I will masterize the logic of the plugin
Describe the bug
JIB build fails when maven build of a quarkus application runs in a Tekton's pod. The code is looking about docker binary
Expected behavior
Jib build should work without Docker binary included part of the container image
Actual behavior
No response
How to Reproduce?
Steps to reproduce:
Deploy a Pipeline and create a PipelineRun able to build a quarkus project using jib extension
Output of
uname -a
orver
Linux 5.19.6-300.fc37.x86_64
Output of
java -version
N/A
Quarkus version or git rev
3.0.3.Final
Build tool (ie. output of
mvnw --version
orgradlew --version
)No response
Additional information
No response