From 3bd23e8ba28b709056f9d4ed9d50f8eb1c5521ae Mon Sep 17 00:00:00 2001 From: R Searls Date: Wed, 6 Sep 2023 16:20:28 -0400 Subject: [PATCH] requested revisions to PR 83 --- demos/pom.xml | 20 + demos/ws-bootable-jar-example/README.md | 17 + .../jaxws/maven/bootable-jar-openshift | 0 .../ws-bootable-jar-example/jaxws/pom.xml | 7 - .../jaxws/scripts/property.cli | 0 .../main/java/org/jboss/jaxws/Endpoint.java | 0 .../java/org/jboss/jaxws/EndpointImpl.java | 3 +- .../src/main/webapp/WEB-INF/jboss-web.xml | 0 ...ildflyBootableOpenShiftJarApplication.java | 4 +- .../SoapWildflyBootableOpenShiftJarTest.java | 0 ...it.platform.launcher.TestExecutionListener | 0 .../jaxws/src/test/resources/logback.xml | 0 .../ws-bootable-jar-example/pom.xml | 81 ++-- deployments/pom.xml | 1 - .../jaxws/maven/bootable-jar-baremetal | 0 testsuite/pom.xml | 6 - .../intersmash/tools/IntersmashConfig.java | 13 - ...egacyWildflyImageOpenShiftApplication.java | 78 ---- .../LegacyWildflyOpenShiftApplication.java | 45 --- ...egacyWildflyImageOpenShiftProvisioner.java | 364 ------------------ ...ldflyImageOpenShiftProvisionerFactory.java | 34 -- ...ersmash.tools.provision.ProvisionerFactory | 1 - 22 files changed, 63 insertions(+), 611 deletions(-) create mode 100644 demos/pom.xml create mode 100644 demos/ws-bootable-jar-example/README.md rename {deployments => demos}/ws-bootable-jar-example/jaxws/maven/bootable-jar-openshift (100%) rename {deployments => demos}/ws-bootable-jar-example/jaxws/pom.xml (89%) rename {deployments => demos}/ws-bootable-jar-example/jaxws/scripts/property.cli (100%) rename {deployments => demos}/ws-bootable-jar-example/jaxws/src/main/java/org/jboss/jaxws/Endpoint.java (100%) rename {deployments => demos}/ws-bootable-jar-example/jaxws/src/main/java/org/jboss/jaxws/EndpointImpl.java (98%) rename {deployments => demos}/ws-bootable-jar-example/jaxws/src/main/webapp/WEB-INF/jboss-web.xml (100%) rename {deployments => demos}/ws-bootable-jar-example/jaxws/src/test/java/org/jboss/jaxws/SoapWildflyBootableOpenShiftJarApplication.java (95%) rename {deployments => demos}/ws-bootable-jar-example/jaxws/src/test/java/org/jboss/jaxws/SoapWildflyBootableOpenShiftJarTest.java (100%) rename {deployments => demos}/ws-bootable-jar-example/jaxws/src/test/resources/META-INF/services/org.junit.platform.launcher.TestExecutionListener (100%) rename {deployments => demos}/ws-bootable-jar-example/jaxws/src/test/resources/logback.xml (100%) rename {deployments => demos}/ws-bootable-jar-example/pom.xml (79%) delete mode 100644 deployments/ws-bootable-jar-example/jaxws/maven/bootable-jar-baremetal delete mode 100644 tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/application/openshift/LegacyWildflyImageOpenShiftApplication.java delete mode 100644 tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/application/openshift/LegacyWildflyOpenShiftApplication.java delete mode 100644 tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/LegacyWildflyImageOpenShiftProvisioner.java delete mode 100644 tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/LegacyWildflyImageOpenShiftProvisionerFactory.java diff --git a/demos/pom.xml b/demos/pom.xml new file mode 100644 index 000000000..5d3b2eec1 --- /dev/null +++ b/demos/pom.xml @@ -0,0 +1,20 @@ + + + 4.0.0 + + org.jboss.intersmash + intersmash-parent + 0.0.1-SNAPSHOT + ../pom.xml + + + intersmash-demos + pom + + + ws-bootable-jar-example + + + diff --git a/demos/ws-bootable-jar-example/README.md b/demos/ws-bootable-jar-example/README.md new file mode 100644 index 000000000..42e1f8733 --- /dev/null +++ b/demos/ws-bootable-jar-example/README.md @@ -0,0 +1,17 @@ +ws-bootable-jar-example +======================= + +This module provides a simple POC webservice's jaxws application that is built as a bootable jar consisting of Wildfly and the jaxws war file, and then deployed to OpenShift, and tested. + +The jaxws module builds 2 archives, the webservice's war file and a bootable jar to be run on OpenShift + +This module demonstrates building a fresh (relatively current) version of Wildfly using Galleon for inclusion in the bootable jar, as compared to pulling a pre-existing Wildfly image from a public repository. The process enables the user to build a most currently version of Wildfly for testing. + +Module, demos, is not declared in intersmash's root pom.xml file. This example must be run from directory, demos. The user will also require a test.properties file with the appropriate OpenShift reference and configuration information. The test can be run with cmd. + + mvn test -pl ws-bootable-jar-example/ -amd -Dtest=SoapWildflyBootableOpenShiftJarTest \ + -Dxtf.test_properties.path=/ABSOLUTE/PATH/TO/test.properties + +or if test.properties resides in the demos directory cmd, + + mvn test -pl ws-bootable-jar-example/ -amd -Dtest=SoapWildflyBootableOpenShiftJarTest diff --git a/deployments/ws-bootable-jar-example/jaxws/maven/bootable-jar-openshift b/demos/ws-bootable-jar-example/jaxws/maven/bootable-jar-openshift similarity index 100% rename from deployments/ws-bootable-jar-example/jaxws/maven/bootable-jar-openshift rename to demos/ws-bootable-jar-example/jaxws/maven/bootable-jar-openshift diff --git a/deployments/ws-bootable-jar-example/jaxws/pom.xml b/demos/ws-bootable-jar-example/jaxws/pom.xml similarity index 89% rename from deployments/ws-bootable-jar-example/jaxws/pom.xml rename to demos/ws-bootable-jar-example/jaxws/pom.xml index 0a7bb9b19..1a1f16272 100644 --- a/deployments/ws-bootable-jar-example/jaxws/pom.xml +++ b/demos/ws-bootable-jar-example/jaxws/pom.xml @@ -42,12 +42,6 @@ ${project.parent.parent.parent.basedir}/ide-config - 11 - 11 - UTF-8 - - - 3.0.0-M5 6.2.0.Final @@ -101,7 +95,6 @@ org.apache.maven.plugins maven-surefire-plugin - ${version.maven-surefire-plugin} + + + + ${project.basedir}/../../license-header + + + + + @@ -274,63 +292,10 @@ - - - - - - bootable-jar-baremetal - - - maven/bootable-jar-baremetal - - - - - - org.wildfly.plugins - wildfly-jar-maven-plugin - - - - - bootable-baremetal - - ${project.build.finalName}-bootable-baremetal.jar - - process-test-sources - - package - - - - - - - org.apache.maven.plugins - maven-install-plugin - - - install-bootable-jar-baremetal - generate-test-resources - - install-file - - - ${project.groupId} - ${project.artifactId} - ${project.version} - jar - bootable-baremetal - ${project.build.directory}/${project.build.finalName}-bootable-baremetal.jar - - - - + com.diffplug.spotless + spotless-maven-plugin + ${version.spotless-maven-plugin} diff --git a/deployments/pom.xml b/deployments/pom.xml index 34df36da0..c8e019a67 100644 --- a/deployments/pom.xml +++ b/deployments/pom.xml @@ -18,7 +18,6 @@ intersmash-deployments-shared intersmash-deployments-provider openshift-jakarta-sample-standalone - ws-bootable-jar-example diff --git a/deployments/ws-bootable-jar-example/jaxws/maven/bootable-jar-baremetal b/deployments/ws-bootable-jar-example/jaxws/maven/bootable-jar-baremetal deleted file mode 100644 index e69de29bb..000000000 diff --git a/testsuite/pom.xml b/testsuite/pom.xml index 878f8317f..cfe780c8e 100644 --- a/testsuite/pom.xml +++ b/testsuite/pom.xml @@ -20,8 +20,6 @@ UTF-8 ${project.parent.basedir}/ide-config - 6.0.0 - 2.0.1 @@ -50,10 +48,6 @@ io.fabric8 openshift-client - - io.fabric8 - kubernetes-model-core - diff --git a/tools/intersmash-tools-core/src/main/java/org/jboss/intersmash/tools/IntersmashConfig.java b/tools/intersmash-tools-core/src/main/java/org/jboss/intersmash/tools/IntersmashConfig.java index 05eeb2312..56afc1152 100644 --- a/tools/intersmash-tools-core/src/main/java/org/jboss/intersmash/tools/IntersmashConfig.java +++ b/tools/intersmash-tools-core/src/main/java/org/jboss/intersmash/tools/IntersmashConfig.java @@ -238,19 +238,6 @@ public static String bootableJarImageURL() { return XTFConfig.get(BOOTABLE_JAR_IMAGE_URL); } - // rls test start ------------------- - private static final String LEGACY_WILDFLY_IMAGE_URL = "intersmash.legacy.wildfly.image"; - private static final String LEGACY_WILDFLY_RUNTIME_IMAGE_URL = "intersmash.legacy.wildfly.runtime.image"; - - public static String legacyWildflyImageURL() { - return XTFConfig.get(LEGACY_WILDFLY_IMAGE_URL); - } - - public static String legacyWildflyRuntimeImageURL() { - return XTFConfig.get(LEGACY_WILDFLY_RUNTIME_IMAGE_URL); - } - // rls test end ------------------- - public static String wildflyImageURL() { return XTFConfig.get(WILDFLY_IMAGE_URL); } diff --git a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/application/openshift/LegacyWildflyImageOpenShiftApplication.java b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/application/openshift/LegacyWildflyImageOpenShiftApplication.java deleted file mode 100644 index a6bee4661..000000000 --- a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/application/openshift/LegacyWildflyImageOpenShiftApplication.java +++ /dev/null @@ -1,78 +0,0 @@ -/** - * Copyright (C) 2023 Red Hat, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jboss.intersmash.tools.application.openshift; - -import java.nio.file.Path; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.jboss.intersmash.tools.application.openshift.input.BinarySourceBuilder; -import org.jboss.intersmash.tools.application.openshift.input.BuildInput; -import org.jboss.intersmash.tools.application.openshift.input.BuildInputBuilder; -import org.jboss.intersmash.tools.application.openshift.input.GitSourceBuilder; - -import cz.xtf.builder.builders.pod.PersistentVolumeClaim; -import cz.xtf.builder.builders.pod.VolumeMount; -import io.fabric8.kubernetes.api.model.EnvVar; - -public interface LegacyWildflyImageOpenShiftApplication extends LegacyWildflyOpenShiftApplication, HasEnvVars { - - /** - * Use the {@link BuildInputBuilder} to get instances implementing the {@link BuildInput} interface. - * - * @see GitSourceBuilder - * @see BinarySourceBuilder - * @return {@link BuildInput} instance for application - */ - BuildInput getBuildInput(); - - /** - * Setup mount points to Legacy Wildfly (i.e. javax.* based) pod and persistent volume claims to be created. - * @return A {@link Map} instance storing PVCs needed by the WILDFLY application service - */ - default Map> getPersistentVolumeClaimMounts() { - return Collections.emptyMap(); - } - - @Override - default List getEnvVars() { - return Collections.emptyList(); - } - - /** - * Override this in the implementation class to return a non-null value in case you want to create a ping service - * to be used for DNS_PING clustering. The provisioner will take care of setting up all the ENV variables needed - * for clustering to work. - * If this method returns null, no service will be created. - * - * @return The name of the ping-service that will be created. - */ - default String getPingServiceName() { - return null; - } - - /** - * Gives a chance at modifying local sources before they are uploaded to the builder image; only works when - * performing a binary build from local sources - * @param mavenProjectRoot path to maven project root - * @return - */ - default Path prepareProjectSources(Path mavenProjectRoot) { - return mavenProjectRoot; - }; -} diff --git a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/application/openshift/LegacyWildflyOpenShiftApplication.java b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/application/openshift/LegacyWildflyOpenShiftApplication.java deleted file mode 100644 index dcebe045d..000000000 --- a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/application/openshift/LegacyWildflyOpenShiftApplication.java +++ /dev/null @@ -1,45 +0,0 @@ -/** - * Copyright (C) 2023 Red Hat, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jboss.intersmash.tools.application.openshift; - -import java.util.Collections; -import java.util.List; - -import io.fabric8.kubernetes.api.model.Secret; - -/** - * This interface is not supposed to be implemented by user Applications. See the "Mapping of implemented provisioners" - * section of Intersmash README.md file for the up-to-date list of supported end users Applications. - */ -public interface LegacyWildflyOpenShiftApplication extends OpenShiftApplication, HasSecrets { - - // - // Legacy Wildfly (i.e. javax.* based)/Application configuration - // - - default List getCliScript() { - return Collections.emptyList(); - } - - // - // OpenShift configuration - // - - @Override - default List getSecrets() { - return Collections.emptyList(); - } -} diff --git a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/LegacyWildflyImageOpenShiftProvisioner.java b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/LegacyWildflyImageOpenShiftProvisioner.java deleted file mode 100644 index 4e2ad0aef..000000000 --- a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/LegacyWildflyImageOpenShiftProvisioner.java +++ /dev/null @@ -1,364 +0,0 @@ -/** - * Copyright (C) 2023 Red Hat, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jboss.intersmash.tools.provision.openshift; - -import java.io.File; -import java.nio.file.Path; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Set; -import java.util.stream.Collectors; - -import org.assertj.core.util.Strings; -import org.jboss.intersmash.tools.IntersmashConfig; -import org.jboss.intersmash.tools.application.openshift.LegacyWildflyImageOpenShiftApplication; -import org.jboss.intersmash.tools.application.openshift.LegacyWildflyOpenShiftApplication; -import org.jboss.intersmash.tools.application.openshift.input.BinarySource; -import org.jboss.intersmash.tools.application.openshift.input.BuildInput; -import org.jboss.intersmash.tools.application.openshift.input.GitSource; -import org.slf4j.event.Level; - -import cz.xtf.builder.builders.ApplicationBuilder; -import cz.xtf.builder.builders.PVCBuilder; -import cz.xtf.builder.builders.pod.PersistentVolumeClaim; -import cz.xtf.builder.builders.pod.VolumeMount; -import cz.xtf.builder.builders.route.TransportProtocol; -import cz.xtf.core.bm.BinaryBuild; -import cz.xtf.core.bm.BinaryBuildFromFile; -import cz.xtf.core.bm.BinarySourceBuild; -import cz.xtf.core.bm.BuildManagers; -import cz.xtf.core.bm.ManagedBuildReference; -import cz.xtf.core.event.helpers.EventHelper; -import cz.xtf.core.openshift.OpenShiftWaiters; -import cz.xtf.core.waiting.failfast.FailFastCheck; -import io.fabric8.kubernetes.api.model.EnvVar; -import io.fabric8.kubernetes.api.model.Pod; -import io.fabric8.kubernetes.api.model.Secret; -import lombok.NonNull; -import lombok.extern.slf4j.Slf4j; - -/** - * Class deploys a Wildfly legacy (i.e. javax.* based) application based on {@link LegacyWildflyOpenShiftApplication} - */ -@Slf4j -public class LegacyWildflyImageOpenShiftProvisioner implements OpenShiftProvisioner { - - private final LegacyWildflyImageOpenShiftApplication application; - private final String CLI_LAUNCH_SCRIPT = "CLI_LAUNCH_SCRIPT"; - private FailFastCheck ffCheck = () -> false; - - public LegacyWildflyImageOpenShiftProvisioner(@NonNull LegacyWildflyImageOpenShiftApplication application) { - this.application = application; - } - - @Override - public LegacyWildflyImageOpenShiftApplication getApplication() { - return application; - } - - @Override - public void deploy() { - deployImage(); - } - - @Override - public void undeploy() { - OpenShiftUtils.deleteResourcesWithLabel(openShift, APP_LABEL_KEY, application.getName()); - // when using git repo S2I process creates some custom maps and build pods - openShift.getConfigMaps() - .stream() - .filter(cfMap -> cfMap.getMetadata().getName().startsWith(application.getName())) - .forEach(openShift::deleteConfigMap); - openShift.getPods() - .stream() - .filter(pod -> pod.getMetadata().getName().startsWith(application.getName())) - .forEach(openShift::deletePod); - } - - @Override - public void scale(int replicas, boolean wait) { - openShift.scale(application.getName(), replicas); - if (wait) { - waitForReplicas(replicas); - } - } - - public void waitForReplicas(int replicas) { - OpenShiftWaiters.get(openShift, ffCheck).areExactlyNPodsReady(replicas, application.getName()).level(Level.DEBUG) - .waitFor(); - WaitersUtil.serviceEndpointsAreReady(openShift, getApplication().getName(), replicas, 8080) - .level(Level.DEBUG) - .waitFor(); - if (replicas > 0) { - WaitersUtil.routeIsUp(getUrl(application.getName(), false)) - .level(Level.DEBUG) - .waitFor(); - } - } - - private ApplicationBuilder getAppBuilder() { - BuildInput buildInput = application.getBuildInput(); - Objects.requireNonNull(buildInput); - - if (BinarySource.class.isAssignableFrom(buildInput.getClass())) { - BinarySource binarySource = (BinarySource) buildInput; - log.debug("Create application builder from source (path: {}).", binarySource.getArchive().toString()); - - List environmentVariables = new ArrayList<>(application.getEnvVars()); - - File archiveFile = binarySource.getArchive().toFile(); - if (archiveFile.isDirectory()) { - /* - S2I Binary build which takes as input the source code of a maven project located on the local filesystem; - - This kind of build corresponds to the following workflows: - - 1. "Maven Project": The maven build is run inside the builder image, - E.g.: - - oc new-build --name=wildfly-build-from-source-code \ - --labels=intersmash.app=wildfly-test-app \ - --binary=true \ - --strategy=source \ - --env=ADMIN_USERNAME=admin \ - --env=ADMIN_PASSWORD=pass.1234 \ - --env=MAVEN_ARGS_APPEND="-Dwildfly.ee-feature-pack.location=org.wildfly:wildfly-galleon-pack:27.0.0.Alpha4 -Dwildfly.cloud-feature-pack.location=org.wildfly.cloud:wildfly-cloud-galleon-pack:2.0.0.Alpha4" \ - --image=quay.io/wildfly/wildfly-s2i-jdk11:latest - - oc start-build wildfly-build-from-source-code \ - --from-dir=/some-path/intersmash-tools/intersmash-tools-provisioners/src/test/resources/apps/openshift-jakarta-sample \ - --follow - - oc new-app wildfly-build-from-source-code - - 2. "target/server": The maven build is run on the local machine and then, server and application are uploaded to the builder image, - E.g.: - - cd /path/intersmash/intersmash-tools/intersmash-tools-provisioners/src/test/resources/apps/openshift-jakarta-sample/target/server - mvn install -P openshift \ - -Dwildfly.ee-feature-pack.location=org.wildfly:wildfly-galleon-pack:27.0.0.Alpha4 \ - -Dwildfly.cloud-feature-pack.location=org.wildfly.cloud:wildfly-cloud-galleon-pack:2.0.0.Alpha4 - - oc new-build --name=wildfly-build-from-server \ - --labels=intersmash.app=wildfly-test-app \ - --binary=true \ - --strategy=source \ - --env=ADMIN_USERNAME=admin \ - --env=ADMIN_PASSWORD=pass.1234 \ - --image=quay.io/wildfly/wildfly-s2i-jdk11:latest - - oc start-build wildfly-build-from-server \ - --from-dir=./target/server \ - --follow - - oc new-app wildfly-build-from-server - */ - BinaryBuild binaryBuild; - Path localSourceCode = application.prepareProjectSources(binarySource.getArchive()); - binaryBuild = new BinarySourceBuild( - IntersmashConfig.legacyWildflyImageURL(), - localSourceCode, - environmentVariables.stream().collect(Collectors.toMap(EnvVar::getName, EnvVar::getValue)), - application.getName()); - ManagedBuildReference reference = BuildManagers.get().deploy(binaryBuild); - BuildManagers.get().hasBuildCompleted(binaryBuild).waitFor(); - return ApplicationBuilder.fromManagedBuild( - application.getName(), - reference, - Collections.singletonMap(APP_LABEL_KEY, application.getName())); - } else if (archiveFile.isFile()) { - /* - Legacy S2I Binary build which takes as input an already built artifact e.g. WAR file; - - Note that WILDFLY images do not contain the server anymore; - - This scenario is probably to be pruned: now, if the build of th maven project happens outside - openshift, you start a binary build "--from-dir" using the "target/server" folder; - - This workflow is just preserved to support legacy builds where no server is provisioned because the - maven project isn't configured to use the new "wildfly-maven-plugin"; - E.g. - - oc new-build --name=wildfly-build-from-war \ - --labels=intersmash.app=wildfly-test-app \ - --binary=true \ - --strategy=source \ - --env=ADMIN_USERNAME=admin \ - --env=ADMIN_PASSWORD=pass.1234 \ - --env=GALLEON_PROVISION_FEATURE_PACKS="org.wildfly:wildfly-galleon-pack:27.0.0.Alpha4,org.wildfly.cloud:wildfly-cloud-galleon-pack:2.0.0.Alpha4" \ - --env=GALLEON_PROVISION_LAYERS=cloud-server \ - --image=quay.io/wildfly/wildfly-s2i-jdk11:latest - - oc start-build wildfly-build-from-war \ - --from-file=/some-path/intersmash/intersmash-tools/intersmash-tools-provisioners/src/test/resources/apps/openshift-jakarta-sample/target/ROOT.war \ - --follow - - oc new-app wildfly-build-from-war - */ - BinaryBuildFromFile legacyWildflyBuild = new BinaryBuildFromFile( - IntersmashConfig.legacyWildflyImageURL(), - binarySource.getArchive(), - environmentVariables.stream().collect(Collectors.toMap(EnvVar::getName, EnvVar::getValue)), - application.getName() + "-" - + IntersmashConfig.getProductCode(IntersmashConfig.legacyWildflyImageURL())); - ManagedBuildReference reference = BuildManagers.get().deploy(legacyWildflyBuild); - BuildManagers.get().hasBuildCompleted(legacyWildflyBuild).level(Level.DEBUG).waitFor(); - - return ApplicationBuilder.fromManagedBuild(application.getName(), reference, - Collections.singletonMap(APP_LABEL_KEY, application.getName())); - } else { - throw new RuntimeException( - String.format("'%s' archive path must be either a directory or a file", archiveFile.getAbsolutePath())); - } - } else if (GitSource.class.isAssignableFrom(buildInput.getClass())) { - /* - S2I Build which takes as input, source code located in a remote Git repository; - */ - GitSource gitSource = (GitSource) buildInput; - log.debug("Create application builder from git reference (repo: {}, ref: {}).", - gitSource.getUri(), gitSource.getRef()); - ApplicationBuilder appBuilder = ApplicationBuilder.fromS2IBuild(application.getName(), - IntersmashConfig.legacyWildflyImageURL(), - gitSource.getUri(), - Collections.singletonMap(APP_LABEL_KEY, application.getName())); - - appBuilder.buildConfig().onConfigurationChange().gitRef(gitSource.getRef()); - if (!Strings.isNullOrEmpty(gitSource.getContextDir())) - appBuilder.buildConfig().onConfigurationChange().gitContextDir(gitSource.getContextDir()); - - application.getEnvVars().stream() - .forEach(entry -> appBuilder.buildConfig().sti().addEnvVariable(entry.getName(), entry.getValue())); - return appBuilder; - } else { - throw new RuntimeException("Application artifact path, git reference or maven project root has to be specified"); - } - } - - private void deployImage() { - ffCheck = FailFastUtils.getFailFastCheck(EventHelper.timeOfLastEventBMOrTestNamespaceOrEpoch(), - application.getName()); - ApplicationBuilder appBuilder = getAppBuilder(); - appBuilder.service() - .port("8080-tcp", 8080, 8080, TransportProtocol.TCP); - - appBuilder.deploymentConfig().podTemplate().container() - .addLivenessProbe() - .setInitialDelay(60) - .setFailureThreshold(6) - .createHttpProbe("/health/live", "9990"); - - appBuilder.deploymentConfig().podTemplate().container() - .addReadinessProbe() - .setFailureThreshold(6) - .createHttpProbe("/health/ready", "9990"); - - // setup the ping service for clustering using DNS_PING - if (application.getPingServiceName() != null) { - String pingServiceName = application.getPingServiceName(); - int pingServicePort = 8888; - appBuilder.service(application.getPingServiceName()) - .addAnnotation("service.alpha.kubernetes.io/tolerate-unready-endpoints", "true") - .headless() - .port("ping", pingServicePort, pingServicePort, TransportProtocol.TCP); - Map pingServiceEnv = new HashMap<>(); - pingServiceEnv.put("JGROUPS_PING_PROTOCOL", "dns.DNS_PING"); - pingServiceEnv.put("OPENSHIFT_DNS_PING_SERVICE_NAME", pingServiceName); - pingServiceEnv.put("OPENSHIFT_DNS_PING_SERVICE_PORT", String.valueOf(pingServicePort)); - appBuilder.deploymentConfig().podTemplate().container().envVars(Collections.unmodifiableMap(pingServiceEnv)); - } - - // mount postconfigure CLI commands - if (!application.getCliScript().isEmpty()) { - final String extensionPath = "/opt/server/extensions"; - final String scriptName = "configure.cli"; - - appBuilder.configMap("jboss-cli") - .configEntry(scriptName, String.join("\n", application.getCliScript())); - - appBuilder.deploymentConfig() - .podTemplate() - .addConfigMapVolume("jboss-cli", "jboss-cli", "0755") - .container() - .addVolumeMount("jboss-cli", extensionPath, false); - - if (application.getEnvVars().stream().noneMatch((envVar -> envVar.getName().equals(CLI_LAUNCH_SCRIPT)))) { - // Application doesn't provide necessary env variable value to the extension script, so let's define it here. - addEnvVariable(appBuilder, CLI_LAUNCH_SCRIPT, extensionPath + "/" + scriptName, true, - !BinarySource.class.isAssignableFrom(application.getBuildInput().getClass())); - } - } - - // mount secrets to /etc/secrets - for (Secret secret : application.getSecrets()) { - appBuilder.deploymentConfig().podTemplate() - .addSecretVolume(secret.getMetadata().getName(), secret.getMetadata().getName()) - .container() - .addVolumeMount(secret.getMetadata().getName(), "/etc/secrets", false); - } - - appBuilder.route().targetPort(8080); - - // env vars - appBuilder.deploymentConfig().podTemplate().container() - .envVars(application.getEnvVars().stream().collect(Collectors.toMap(EnvVar::getName, EnvVar::getValue))); - - // enable script debugging - if (application.getEnvVars().stream().noneMatch((envVar -> envVar.getName().equals(SCRIPT_DEBUG)))) { - if (IntersmashConfig.scriptDebug() != null) - addEnvVariable(appBuilder, SCRIPT_DEBUG, IntersmashConfig.scriptDebug(), true, - !BinarySource.class.isAssignableFrom(application.getBuildInput().getClass())); - } - - // mount persistent volumes into pod - if (!application.getPersistentVolumeClaimMounts().isEmpty()) { - application.getPersistentVolumeClaimMounts().entrySet().stream() - .forEach(entry -> { - PersistentVolumeClaim pvc = entry.getKey(); - Set vms = entry.getValue(); - appBuilder.deploymentConfig().podTemplate().addPersistenVolumeClaim(pvc.getName(), - pvc.getClaimName()); - vms.forEach(vm -> appBuilder.deploymentConfig().podTemplate().container().addVolumeMount(pvc.getName(), - vm.getMountPath(), vm.isReadOnly(), vm.getSubPath())); - openShift.createPersistentVolumeClaim( - new PVCBuilder(pvc.getClaimName()).accessRWX().storageSize("100Mi").build()); - }); - } - - appBuilder.buildApplication(openShift).deploy(); - OpenShiftWaiters.get(openShift, ffCheck).isDcReady(application.getName()).level(Level.DEBUG).waitFor(); - // 1 by default - waitForReplicas(1); - } - - private void addEnvVariable(ApplicationBuilder appBuilder, final String key, final String value, final boolean addToDC, - final boolean addToBuild) { - if (addToDC) { - appBuilder.deploymentConfig().podTemplate().container().envVar(key, value); - } - if (addToBuild) { - appBuilder.buildConfig().sti().addEnvVariable(key, value); - } - } - - @Override - public List getPods() { - return openShift.getPods(getApplication().getName()); - } -} diff --git a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/LegacyWildflyImageOpenShiftProvisionerFactory.java b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/LegacyWildflyImageOpenShiftProvisionerFactory.java deleted file mode 100644 index 1ca563af1..000000000 --- a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/LegacyWildflyImageOpenShiftProvisionerFactory.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Copyright (C) 2023 Red Hat, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jboss.intersmash.tools.provision.openshift; - -import org.jboss.intersmash.tools.application.Application; -import org.jboss.intersmash.tools.application.openshift.LegacyWildflyImageOpenShiftApplication; -import org.jboss.intersmash.tools.provision.ProvisionerFactory; - -import lombok.extern.slf4j.Slf4j; - -@Slf4j -public class LegacyWildflyImageOpenShiftProvisionerFactory - implements ProvisionerFactory { - - @Override - public LegacyWildflyImageOpenShiftProvisioner getProvisioner(Application application) { - if (LegacyWildflyImageOpenShiftApplication.class.isAssignableFrom(application.getClass())) - return new LegacyWildflyImageOpenShiftProvisioner((LegacyWildflyImageOpenShiftApplication) application); - return null; - } -} diff --git a/tools/intersmash-tools-provisioners/src/main/resources/META-INF/services/org.jboss.intersmash.tools.provision.ProvisionerFactory b/tools/intersmash-tools-provisioners/src/main/resources/META-INF/services/org.jboss.intersmash.tools.provision.ProvisionerFactory index f87ce4962..cb039d970 100644 --- a/tools/intersmash-tools-provisioners/src/main/resources/META-INF/services/org.jboss.intersmash.tools.provision.ProvisionerFactory +++ b/tools/intersmash-tools-provisioners/src/main/resources/META-INF/services/org.jboss.intersmash.tools.provision.ProvisionerFactory @@ -8,4 +8,3 @@ org.jboss.intersmash.tools.provision.openshift.PostgreSQLImageOpenShiftProvision org.jboss.intersmash.tools.provision.openshift.InfinispanOperatorProvisionerFactory org.jboss.intersmash.tools.provision.openshift.KeycloakOperatorProvisionerFactory org.jboss.intersmash.tools.provision.helm.WildflyHelmChartOpenShiftProvisionerFactory -org.jboss.intersmash.tools.provision.openshift.LegacyWildflyImageOpenShiftProvisionerFactory