jkube
jkube copied to clipboard
OpenShiftBuildTask: ocBuild Generator - WebApp
Description
Child of #31 Equivalent of and blocked by #1207
ocBuild Gradle task works with WebApp Generator.
- [x] S2i build works fine (Tomcat/default) https://github.com/eclipse/jkube/pull/1405
- [x] S2i build works fine (Jetty) https://github.com/eclipse/jkube/pull/1405
- [x] S2i build works fine (WildFly AppServer):
- https://github.com/eclipse/jkube/pull/1351
- https://github.com/eclipse/jkube/pull/1403
I seems to work with tomcat and jetty. But with wildfly:
Receiving source from STDIN as archive ...
time="2022-03-07T16:34:06Z" level=info msg="Not using native diff for overlay, this may cause degraded performance for building images: kernel has CONFIG_OVERLAY_FS_REDIRECT_DIR enabled"
I0307 16:34:06.450687 1 defaults.go:102] Defaulting to storage driver "overlay" with options [mountopt=metacopy=on].
Caching blobs under "/var/cache/blobs".
Trying to pull docker.io/jboss/wildfly:25.0.0.Final...
Getting image source signatures
Copying blob sha256:13776e8da872e356f0bbdbfab6aa37486ab7e73d556fdc58f06c26bac2902787
Copying blob sha256:0b43aea4eeb16fc134b944c49d91361b8dbb2b3c9991493c32c4231532c7b46d
Copying blob sha256:8116b2f7ca5a25285f697c0d16f2a79aa2b67bdc4eef91f3f97e178888c48741
Copying blob sha256:f26d32e28c292aba76defcdd67c267000d31a6ac3ebdab5c850aba90ef834927
Copying blob sha256:f87ff222252edd5fa0a4db15454cbad5e1e3e0fbe6d21cf89236a9516e870c08
Copying config sha256:85669404084756ad51914d98c460b5b83f45848b2ec9567f08b262170db264e4
Writing manifest to image destination
Storing signatures
Generating dockerfile with builder image jboss/wildfly:25.0.0.Final
error: build error: image "jboss" must specify a user that is numeric and within the range of allowed users
~~Does your configuration change the image user, it should be 1000:1000?~~
OK, our generator defines the user as jboss:jboss:jboss, this must be something new for the current OpenShift version.
this is strange, it's trying to use jboss/wildfly:25.0.0.Final as base image, but I see
jkube-kit/generator/webapp/target/classes/META-INF/jkube/default-images.properties
19:wildfly.upstream.docker=jboss/wildfly:25.0.0.Final
20:wildfly.upstream.s2i=quay.io/wildfly/wildfly-centos7:26.0
21:wildfly.upstream.istag=wildfly:26.0
should be using quay.io/wildfly/wildfly-centos7:26.0 as it is an s2i build.
Are you sure you're running an S2i build and not an OpenShift Docker build?
This part looks suspicious: Generating dockerfile with builder image jboss/wildfly:25.0.0.Final
with Maven it is working fine:
[INFO] oc: Starting Build webapp-wildfly-datasource-s2i
[INFO] oc: Waiting for build webapp-wildfly-datasource-s2i-1 to complete...
[INFO] oc: time="2022-03-08T09:10:52Z" level=info msg="Not using native diff for overlay, this may cause degraded performance for building images: kernel has CONFIG_OVERLAY_FS_REDIRECT_DIR enabled"
[INFO] oc: I0308 09:10:52.392643 1 defaults.go:102] Defaulting to storage driver "overlay" with options [mountopt=metacopy=on].
[INFO] oc: Caching blobs under "/var/cache/blobs".
[INFO] oc: Trying to pull quay.io/wildfly/wildfly-centos7:26.0...
And build success
Maybe something wrong in the gradle project setup? it looks like something is not triggering in the Generator.
In gradle
> Task :ocBuild
oc: Running in OpenShift mode
oc: Running generator webapp
oc: webapp: Using jboss/wildfly:25.0.0.Final as base image for webapp
oc: Using OpenShift build with strategy S2I
I am going to debug to see the difference.
what is strange is that the log Using OpenShift build with strategy S2I is after webapp: Using jboss/wildfly:25.0.0.Final as base image for webapp
debugging in progress:
https://github.com/eclipse/jkube/blob/master/jkube-kit%2Fgenerator%2Fapi%2Fsrc%2Fmain%2Fjava%2Forg%2Feclipse%2Fjkube%2Fgenerator%2Fapi%2FFromSelector.java#L43
strategy is null
I am going to provide a fix to OpenShiftBuildTask.java:
diff --git a/gradle-plugin/openshift/src/main/java/org/eclipse/jkube/gradle/plugin/task/OpenShiftBuildTask.java b/gradle-plugin/openshi>
index ef0f8b0c..03d66aec 100644
--- a/gradle-plugin/openshift/src/main/java/org/eclipse/jkube/gradle/plugin/task/OpenShiftBuildTask.java
+++ b/gradle-plugin/openshift/src/main/java/org/eclipse/jkube/gradle/plugin/task/OpenShiftBuildTask.java
@@ -31,6 +31,7 @@ public class OpenShiftBuildTask extends KubernetesBuildTask implements OpenShift
@Override
protected BuildServiceConfig.BuildServiceConfigBuilder buildServiceConfigBuilder() {
return super.buildServiceConfigBuilder()
+ .jKubeBuildStrategy(getOpenShiftExtension().getBuildStrategyOrDefault())
.openshiftPullSecret(getOpenShiftExtension().getOpenshiftPullSecretOrDefault())
.s2iBuildNameSuffix(getOpenShiftExtension().getS2iBuildNameSuffixOrDefault())
.s2iImageStreamLookupPolicyLocal(getOpenShiftExtension().getS2iImageStreamLookupPolicyLocalOrDefault())
ok after debugging with @manusa finally the fix is
diff --git a/gradle-plugin/kubernetes/src/main/java/org/eclipse/jkube/gradle/plugin/task/AbstractJKubeTask.java b/gradle-plugin/kuberne>
index f2085b10..259fff03 100644
--- a/gradle-plugin/kubernetes/src/main/java/org/eclipse/jkube/gradle/plugin/task/AbstractJKubeTask.java
+++ b/gradle-plugin/kubernetes/src/main/java/org/eclipse/jkube/gradle/plugin/task/AbstractJKubeTask.java
@@ -152,6 +152,7 @@ public abstract class AbstractJKubeTask extends DefaultTask implements Kubernete
.project(kubernetesExtension.javaProject)
.logger(kitLogger)
.runtimeMode(kubernetesExtension.getRuntimeMode())
+ .strategy(kubernetesExtension.getBuildStrategyOrDefault())
.useProjectClasspath(kubernetesExtension.getUseProjectClassPathOrDefault());
}
.jKubeBuildStrategy(getOpenShiftExtension().getBuildStrategyOrDefault()) is already called in TaskUtil. So BuildServiceConfig has the right strategy s2i. But when we generate the GeneratorContextBuilder it is not using the information from it.
In mid term we need to see if we could avoid initializing things twice in GeneratorContextBuilder and BuildServiceConfig. Maybe the GeneratorContextBuilder should pick from the BuildServiceConfig.
This has probably survived after a few releases because for most of the rest of the supported frameworks ---> Generators, the image is the same for S2I and Docker-compatible builds. This change will fix the issue for every other Generator that provides different images for Docker and S2I. As soon as we finish with enrichers we need to start working on the E2E tests so we identify this problems earlier.
Now deploying quickstarts/gradle/webapp-wildfly:
[0m[0m09:17:21,123 INFO [org.jboss.weld.Version] (MSC service thread 1-2) WELD-000900: 3.1.8 (Final)
[0m[31m09:17:21,513 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("deploy") failed - address: ([("deployment" => "ROOT.war")]) - failure description: {
"WFLYCTL0412: Required services that are not installed:" => ["jboss.jdbc-driver.h2"],
"WFLYCTL0180: Services with missing/unavailable dependencies" => ["jboss.data-source.\"jboss.naming.context.java.jboss.datasources.JKubeCommitersDS\" is missing [jboss.jdbc-driver.h2]"]
}
[0m[0m09:17:21,630 INFO [org.jboss.as.server] (ServerService Thread Pool -- 36) WFLYSRV0010: Deployed "ROOT.war" (runtime-name : "ROOT.war")
[0m[0m09:17:21,631 INFO [org.jboss.as.controller] (Controller Boot Thread) WFLYCTL0183: Service status report
WFLYCTL0184: New missing/unsatisfied dependencies:
service jboss.jdbc-driver.h2 (missing) dependents: [service jboss.data-source."jboss.naming.context.java.jboss.datasources.JKubeCommitersDS"]
WFLYCTL0448: 21 additional services are down due to their dependencies being missing or failed
[0m[0m09:17:21,723 INFO [org.jboss.as.server] (Controller Boot Thread) WFLYSRV0212: Resuming server
[0m[31m09:17:21,724 ERROR [org.jboss.as] (Controller Boot Thread) WFLYSRV0026: WildFly Full 26.0.0.Final (WildFly Core 18.0.0.Final) started (with errors) in 4602ms - Started 311 of 574 services (24 services failed or missing dependencies, 337 services are lazy, passive or on-demand)
[0m[0m09:17:21,725 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0060: Http management interface listening on http://0.0.0.0:9990/management
[0m[0m09:17:21,725 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0054: Admin console is not enabled
it looks like it is missing h2 drivers.
It seems it could be enabled by passing GALEON_PROVISION_LAYERS env variable with datasources-web-server to the s2i build. https://github.com/wildfly/wildfly-s2i/blob/wf-18.0/README.md
I managed to get rid of these errors by passing manually GALEON_PROVISION_LAYERS=datasources-web-server
Now I get the JBoss Wildfly main page instead of the app :/
This is strange because: https://github.com/eclipse/jkube/blob/master/jkube-kit/generator/webapp/src/main/java/org/eclipse/jkube/generator/webapp/handler/WildFlyAppSeverHandler.java#L109
@Override
public Map<String, String> getEnv() {
// Applicable for s2i image - ignored for Docker
return Collections.singletonMap("GALLEON_PROVISION_LAYERS", "cloud-server,web-clustering");
}
But I am not sure to see this env variable in the generated buildconfig
looks like it doesn't work, GALLEON_PROVISION_LAYERS=cloud-server,web-clustering should be passed to the build config where it looks like here it is env for the final built image.
Can this one be closed? @sunix
Kind reminder, Can this one be closed? @sunix