diff --git a/.github/settings.xml b/.github/settings.xml new file mode 100644 index 0000000000..59d889141e --- /dev/null +++ b/.github/settings.xml @@ -0,0 +1,13 @@ + + + + + gha + + true + + + + + diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d118728506..857ead849e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -14,23 +14,12 @@ jobs: build: strategy: matrix: - jdk_version: ['17'] + jdk_version: [ '17' ] fail-fast: false - runs-on: self-hosted + runs-on: ubuntu-latest steps: - - name: Clear /tmp - run: | - docker run --rm -v /tmp:/data alpine find /data -ctime +2 -exec rm -rf '{}' \; 2>&1 > /dev/null || true - - - name: Clear old Docker resources - run: | - docker rm -f $(docker ps -aq) || true - docker volume rm $(docker volume ps -q) || true - docker system prune -af || true - docker image prune -af || true - - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 with: @@ -42,21 +31,16 @@ jobs: username: ${{ secrets.OSS_DOCKERHUB_USERNAME }} password: ${{ secrets.OSS_DOCKERHUB_PASSWORD }} - - uses: actions/checkout@v3 - - name: Set up JDK uses: actions/setup-java@v3 with: java-version: '${{ matrix.jdk_version }}' distribution: 'temurin' - - name: Remove old Concord artifacts - run: | - rm -rf ~/.m2/repository/com/walmartlabs/concord - rm -rf ~/actions-runner/.m2/repository/com/walmartlabs/concord + - name: Checkout + uses: actions/checkout@v3 - name: Build and test with Maven - run: ./mvnw -B clean install -Pdocker -Pit -Pjdk${{ matrix.jdk_version }} - - - name: Build with debian docker images - run: ./mvnw -C -B -f docker-images install -DskipTests -Pdocker -Pdebian -Pjdk${{ matrix.jdk_version }} + env: + SKIP_DOCKER_TESTS: "true" + run: ./mvnw -s .github/settings.xml -B clean install -Pgha -Pdocker -Pit -Pjdk${{ matrix.jdk_version }} diff --git a/CHANGELOG.md b/CHANGELOG.md index 46e8c41cbb..8eb04f8723 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,89 @@ # Change log +## [2.5.0] - 2023-12-10 + +### Added + +- concord-server: support @Priority annotation when binding +Jetty components +([#841](https://github.com/walmartlabs/concord/pull/841)); + +### Changed + +- runtime-v2: allow "true|false" string in if expression +([#844](https://github.com/walmartlabs/concord/pull/844)); +- docker-images: Upgrade default Ansible installation to 2.14 +([#843](https://github.com/walmartlabs/concord/pull/843)); +- ansible-plugin: callback compatibility for Ansible 2.14 +([#842](https://github.com/walmartlabs/concord/pull/842)); +- concord-server: resume process now returns BAD_REQUEST +if no event found +([#838](https://github.com/walmartlabs/concord/pull/838)). + +### Breaking + +- docker-images: drop CentOS-based images, use Debian by default +([#843](https://github.com/walmartlabs/concord/pull/843). + + + +## [2.4.0] - 2023-11-26 + +### Added + +- concord-server: add `EXTRA_CLASSPATH` to start script +([#836](https://github.com/walmartlabs/concord/pull/836)); + +### Changed + +- concord-agent-operator: use JDK 17 base image +([#836](https://github.com/walmartlabs/concord/pull/836)); +- concord-common: shared ObjectMapperProvider +([#836](https://github.com/walmartlabs/concord/pull/836)). + + + +## [2.3.0] - 2023-11-21 + +### Added + +- testing-concord-server: add getter for the server instance +([#832](https://github.com/walmartlabs/concord/pull/832)); +- testing-concord-server: add agent wrapper, simple test +([835](https://github.com/walmartlabs/concord/pull/835)). + +### Changed + +- project: attach source jars only on release +([#832](https://github.com/walmartlabs/concord/pull/832)); +- concord-server: auto-wire modules in concord-server/dist +instead of impl +([#834](https://github.com/walmartlabs/concord/pull/834)). + + + +## [2.2.0] - 2023-11-13 + +### Added + +- pfed-sso: enable bearer token authentication +([#811](https://github.com/walmartlabs/concord/pull/811)). + +### Changed + +- runtime-v2: fix exit from parallel loop #830 +([#830](https://github.com/walmartlabs/concord/pull/830)); +- console2: calculate process duration from process last running timestamp +([#794](https://github.com/walmartlabs/concord/pull/794)); +- console2: do not drop secrets form values on error/password check fail +([#798](https://github.com/walmartlabs/concord/pull/798)); +- project: attach javadoc jars only on release +([#823](https://github.com/walmartlabs/concord/pull/823)); +- project: upgrade to source level 17 +([#824](https://github.com/walmartlabs/concord/pull/824)); +- project: remove more @Named usage +([#828](https://github.com/walmartlabs/concord/pull/828)). + ## [2.1.0] - 2023-10-10 ### Added @@ -31,9 +115,10 @@ - cli: active profiles fix ([#789](https://github.com/walmartlabs/concord/pull/789)). -## [2.0.0] - 2023-08-16 +## [2.0.0] - 2023-08-16 + # Breaking - project: drop support for JDK 8 and JDK 11. Make JDK 17 @@ -90,6 +175,8 @@ auth ([#764](https://github.com/walmartlabs/concord/pull/764)); - console2: do not remove project after rename; ([#770](https://github.com/walmartlabs/concord/pull/770)). + + ## [1.102.0] - 2023-05-22 ### Added @@ -124,6 +211,8 @@ improve error messages - runtime-v2: allow increment variables in expressions ([#740](https://github.com/walmartlabs/concord/pull/740)). + + ## [1.101.0] - 2023-03-29 ### Added @@ -170,6 +259,8 @@ forms - concord-server: remove more @Named usage ([#650](https://github.com/walmartlabs/concord/pull/650)). + + ## [1.99.0] - 2023-02-24 ### Added @@ -376,6 +467,7 @@ to support k8s 1.22+ ([#639](https://github.com/walmartlabs/concord/pull/639)). + ## [1.95.0] - 2022-04-16 ### Added @@ -417,6 +509,8 @@ files ([#593](https://github.com/walmartlabs/concord/pull/593)). - it: explicitly specify initialBranch for git tests ([#582](https://github.com/walmartlabs/concord/pull/582)). + + ## [1.93.3] - 2022-03-11 ### Changed diff --git a/README.md b/README.md index 60ff3d9000..0b77a4afad 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ different systems together using scenarios and plugins created by users. Dependencies: - [Git](https://git-scm.com/) 2.18+ -- [Java 8](https://adoptium.net/) +- [Java 17](https://adoptium.net/) - [Docker Community Edition](https://www.docker.com/community-edition) - [Docker Buildx](https://docs.docker.com/build/buildx/install/) - (Optional) [NodeJS and NPM](https://nodejs.org/en/download/) (Node 16 or greater) @@ -39,14 +39,13 @@ cd concord Available Maven profiles: - `docker` - build Docker images; -- `debian` - build Debian-based Docker images instead of the default CentOS base; - `it` - run integration tests; -- `jdk17`, `jdk17-aarch64` - use a different JDK version for building artifacts and Docker images. +- `jdk17-aarch64` - use a different JDK version for building artifacts and Docker images. Profiles can be combined, e.g. ``` -./mvnw clean install -Pdocker -Pdebian -Pit -Pjdk17-aarch64 +./mvnw clean install -Pdocker -Pit -Pjdk17-aarch64 ``` ## Console @@ -122,4 +121,4 @@ See the [examples](examples) directory. ## Development Notes -See [NOTES.md](NOTES.md). \ No newline at end of file +See [NOTES.md](NOTES.md). diff --git a/agent/pom.xml b/agent/pom.xml index 64c4001982..2b28147746 100644 --- a/agent/pom.xml +++ b/agent/pom.xml @@ -6,7 +6,7 @@ com.walmartlabs.concord parent - 2.1.1-SNAPSHOT + 2.5.1-SNAPSHOT ../pom.xml @@ -81,6 +81,14 @@ com.fasterxml.jackson.core jackson-databind + + com.fasterxml.jackson.datatype + jackson-datatype-jdk8 + + + com.fasterxml.jackson.datatype + jackson-datatype-jsr310 + com.fasterxml.jackson.core jackson-annotations @@ -125,10 +133,6 @@ com.fasterxml.jackson.datatype jackson-datatype-guava - - com.fasterxml.jackson.datatype - jackson-datatype-jdk8 - com.google.code.findbugs jsr305 diff --git a/agent/src/main/java/com/walmartlabs/concord/agent/Agent.java b/agent/src/main/java/com/walmartlabs/concord/agent/Agent.java index cbf69159d1..c2c1e5c04f 100644 --- a/agent/src/main/java/com/walmartlabs/concord/agent/Agent.java +++ b/agent/src/main/java/com/walmartlabs/concord/agent/Agent.java @@ -37,18 +37,13 @@ import org.slf4j.LoggerFactory; import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Singleton; import java.io.IOException; -import java.nio.file.Files; import java.nio.file.Path; import java.util.Map; import java.util.UUID; import java.util.concurrent.*; import java.util.concurrent.atomic.AtomicBoolean; -@Named -@Singleton public class Agent { private static final Logger log = LoggerFactory.getLogger(Agent.class); diff --git a/agent/src/main/java/com/walmartlabs/concord/agent/AgentModule.java b/agent/src/main/java/com/walmartlabs/concord/agent/AgentModule.java new file mode 100644 index 0000000000..8d33c466c1 --- /dev/null +++ b/agent/src/main/java/com/walmartlabs/concord/agent/AgentModule.java @@ -0,0 +1,82 @@ +package com.walmartlabs.concord.agent; + +/*- + * ***** + * Concord + * ----- + * Copyright (C) 2017 - 2023 Walmart 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. + * ===== + */ + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.google.inject.Binder; +import com.google.inject.Module; +import com.typesafe.config.Config; +import com.walmartlabs.concord.agent.cfg.*; +import com.walmartlabs.concord.agent.executors.runner.DefaultDependencies; +import com.walmartlabs.concord.agent.executors.runner.ProcessPool; +import com.walmartlabs.concord.agent.remote.ApiClientFactory; +import com.walmartlabs.concord.agent.remote.QueueClientProvider; +import com.walmartlabs.concord.common.ObjectMapperProvider; +import com.walmartlabs.concord.server.queueclient.QueueClient; +import com.walmartlabs.ollie.config.ConfigurationProcessor; +import com.walmartlabs.ollie.config.Environment; +import com.walmartlabs.ollie.config.EnvironmentSelector; + +import javax.inject.Named; + +import static com.google.inject.Scopes.SINGLETON; + +@Named +public class AgentModule implements Module { + + private final Config config; + + public AgentModule() { + this(loadDefaultConfig()); + } + + public AgentModule(Config config) { + this.config = config; + } + + @Override + public void configure(Binder binder) { + binder.bind(ObjectMapper.class).toProvider(ObjectMapperProvider.class); + binder.bind(Config.class).toInstance(config); + + binder.bind(AgentConfiguration.class).in(SINGLETON); + binder.bind(DockerConfiguration.class).in(SINGLETON); + binder.bind(GitConfiguration.class).in(SINGLETON); + binder.bind(ImportConfiguration.class).in(SINGLETON); + binder.bind(PreForkConfiguration.class).in(SINGLETON); + binder.bind(RepositoryCacheConfiguration.class).in(SINGLETON); + binder.bind(RunnerV1Configuration.class).in(SINGLETON); + binder.bind(RunnerV2Configuration.class).in(SINGLETON); + binder.bind(ServerConfiguration.class).in(SINGLETON); + + binder.bind(DefaultDependencies.class).in(SINGLETON); + binder.bind(ProcessPool.class).in(SINGLETON); + binder.bind(ApiClientFactory.class).in(SINGLETON); + binder.bind(QueueClient.class).toProvider(QueueClientProvider.class).in(SINGLETON); + + binder.bind(Agent.class).in(SINGLETON); + } + + private static Config loadDefaultConfig() { + Environment env = new EnvironmentSelector().select(); + return new ConfigurationProcessor("concord-agent", env, null, null).process(); + } +} diff --git a/agent/src/main/java/com/walmartlabs/concord/agent/cfg/AgentConfiguration.java b/agent/src/main/java/com/walmartlabs/concord/agent/cfg/AgentConfiguration.java index eadd5478fc..4c5c99a486 100644 --- a/agent/src/main/java/com/walmartlabs/concord/agent/cfg/AgentConfiguration.java +++ b/agent/src/main/java/com/walmartlabs/concord/agent/cfg/AgentConfiguration.java @@ -25,8 +25,6 @@ import org.slf4j.LoggerFactory; import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Singleton; import java.nio.file.Path; import java.time.Duration; import java.util.List; @@ -37,8 +35,6 @@ import static com.walmartlabs.concord.agent.cfg.Utils.getOrCreatePath; import static com.walmartlabs.concord.agent.cfg.Utils.getStringOrDefault; -@Named -@Singleton public class AgentConfiguration { private static final Logger log = LoggerFactory.getLogger(AgentConfiguration.class); diff --git a/agent/src/main/java/com/walmartlabs/concord/agent/cfg/DockerConfiguration.java b/agent/src/main/java/com/walmartlabs/concord/agent/cfg/DockerConfiguration.java index 90fde7f7f9..da7bc9cca4 100644 --- a/agent/src/main/java/com/walmartlabs/concord/agent/cfg/DockerConfiguration.java +++ b/agent/src/main/java/com/walmartlabs/concord/agent/cfg/DockerConfiguration.java @@ -23,13 +23,9 @@ import com.typesafe.config.Config; import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Singleton; import java.util.List; import java.util.concurrent.TimeUnit; -@Named -@Singleton public class DockerConfiguration { private final String dockerHost; diff --git a/agent/src/main/java/com/walmartlabs/concord/agent/cfg/GitConfiguration.java b/agent/src/main/java/com/walmartlabs/concord/agent/cfg/GitConfiguration.java index 6dcce8e6e4..85bdcab673 100644 --- a/agent/src/main/java/com/walmartlabs/concord/agent/cfg/GitConfiguration.java +++ b/agent/src/main/java/com/walmartlabs/concord/agent/cfg/GitConfiguration.java @@ -29,8 +29,6 @@ import static com.walmartlabs.concord.agent.cfg.Utils.getStringOrDefault; -@Named -@Singleton public class GitConfiguration { private final String token; diff --git a/agent/src/main/java/com/walmartlabs/concord/agent/cfg/ImportConfiguration.java b/agent/src/main/java/com/walmartlabs/concord/agent/cfg/ImportConfiguration.java index 7cde1f8ca7..f1f5756ba0 100644 --- a/agent/src/main/java/com/walmartlabs/concord/agent/cfg/ImportConfiguration.java +++ b/agent/src/main/java/com/walmartlabs/concord/agent/cfg/ImportConfiguration.java @@ -23,14 +23,10 @@ import com.typesafe.config.Config; import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Singleton; import java.util.Collections; import java.util.HashSet; import java.util.Set; -@Named -@Singleton public class ImportConfiguration { private final Set disabledProcessors; diff --git a/agent/src/main/java/com/walmartlabs/concord/agent/cfg/PreForkConfiguration.java b/agent/src/main/java/com/walmartlabs/concord/agent/cfg/PreForkConfiguration.java index 68758b065c..de38930cee 100644 --- a/agent/src/main/java/com/walmartlabs/concord/agent/cfg/PreForkConfiguration.java +++ b/agent/src/main/java/com/walmartlabs/concord/agent/cfg/PreForkConfiguration.java @@ -23,12 +23,8 @@ import com.typesafe.config.Config; import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Singleton; import java.util.concurrent.TimeUnit; -@Named -@Singleton public class PreForkConfiguration { private final boolean enabled; diff --git a/agent/src/main/java/com/walmartlabs/concord/agent/cfg/RepositoryCacheConfiguration.java b/agent/src/main/java/com/walmartlabs/concord/agent/cfg/RepositoryCacheConfiguration.java index 81ef969da0..c1454e31a1 100644 --- a/agent/src/main/java/com/walmartlabs/concord/agent/cfg/RepositoryCacheConfiguration.java +++ b/agent/src/main/java/com/walmartlabs/concord/agent/cfg/RepositoryCacheConfiguration.java @@ -23,15 +23,11 @@ import com.typesafe.config.Config; import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Singleton; import java.nio.file.Path; import java.time.Duration; import static com.walmartlabs.concord.agent.cfg.Utils.getOrCreatePath; -@Named -@Singleton public class RepositoryCacheConfiguration { private final Path cacheDir; diff --git a/agent/src/main/java/com/walmartlabs/concord/agent/cfg/RunnerV1Configuration.java b/agent/src/main/java/com/walmartlabs/concord/agent/cfg/RunnerV1Configuration.java index 90246a638f..dc57172c37 100644 --- a/agent/src/main/java/com/walmartlabs/concord/agent/cfg/RunnerV1Configuration.java +++ b/agent/src/main/java/com/walmartlabs/concord/agent/cfg/RunnerV1Configuration.java @@ -23,11 +23,7 @@ import com.typesafe.config.Config; import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Singleton; -@Named -@Singleton public class RunnerV1Configuration extends AbstractRunnerConfiguration { @Inject diff --git a/agent/src/main/java/com/walmartlabs/concord/agent/cfg/RunnerV2Configuration.java b/agent/src/main/java/com/walmartlabs/concord/agent/cfg/RunnerV2Configuration.java index 1f12aee1a6..8128b7dd67 100644 --- a/agent/src/main/java/com/walmartlabs/concord/agent/cfg/RunnerV2Configuration.java +++ b/agent/src/main/java/com/walmartlabs/concord/agent/cfg/RunnerV2Configuration.java @@ -23,11 +23,7 @@ import com.typesafe.config.Config; import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Singleton; -@Named -@Singleton public class RunnerV2Configuration extends AbstractRunnerConfiguration { @Inject diff --git a/agent/src/main/java/com/walmartlabs/concord/agent/cfg/ServerConfiguration.java b/agent/src/main/java/com/walmartlabs/concord/agent/cfg/ServerConfiguration.java index eabe02609c..5e6bfb4523 100644 --- a/agent/src/main/java/com/walmartlabs/concord/agent/cfg/ServerConfiguration.java +++ b/agent/src/main/java/com/walmartlabs/concord/agent/cfg/ServerConfiguration.java @@ -25,14 +25,10 @@ import org.slf4j.LoggerFactory; import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Singleton; import java.util.concurrent.TimeUnit; import static com.walmartlabs.concord.agent.cfg.Utils.getStringOrDefault; -@Named -@Singleton public class ServerConfiguration { private static final Logger log = LoggerFactory.getLogger(ServerConfiguration.class); diff --git a/agent/src/main/java/com/walmartlabs/concord/agent/executors/runner/DefaultDependencies.java b/agent/src/main/java/com/walmartlabs/concord/agent/executors/runner/DefaultDependencies.java index 70ad0e3387..4c5d88f5e2 100644 --- a/agent/src/main/java/com/walmartlabs/concord/agent/executors/runner/DefaultDependencies.java +++ b/agent/src/main/java/com/walmartlabs/concord/agent/executors/runner/DefaultDependencies.java @@ -23,8 +23,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.inject.Named; -import javax.inject.Singleton; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; @@ -37,8 +35,6 @@ import java.util.stream.Collectors; import java.util.stream.Stream; -@Named -@Singleton public class DefaultDependencies { private static final Logger log = LoggerFactory.getLogger(DefaultDependencies.class); diff --git a/agent/src/main/java/com/walmartlabs/concord/agent/executors/runner/ProcessPool.java b/agent/src/main/java/com/walmartlabs/concord/agent/executors/runner/ProcessPool.java index a389be7e8d..54dd575a65 100644 --- a/agent/src/main/java/com/walmartlabs/concord/agent/executors/runner/ProcessPool.java +++ b/agent/src/main/java/com/walmartlabs/concord/agent/executors/runner/ProcessPool.java @@ -29,16 +29,12 @@ import org.slf4j.LoggerFactory; import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Singleton; import java.io.IOException; import java.nio.file.Path; import java.util.*; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; -@Named -@Singleton public class ProcessPool { private static final Logger log = LoggerFactory.getLogger(ProcessPool.class); diff --git a/agent/src/main/java/com/walmartlabs/concord/agent/remote/ApiClientFactory.java b/agent/src/main/java/com/walmartlabs/concord/agent/remote/ApiClientFactory.java index 92e2fde99b..0b2403c212 100644 --- a/agent/src/main/java/com/walmartlabs/concord/agent/remote/ApiClientFactory.java +++ b/agent/src/main/java/com/walmartlabs/concord/agent/remote/ApiClientFactory.java @@ -30,8 +30,6 @@ import com.walmartlabs.concord.common.IOUtils; import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Singleton; import java.io.IOException; import java.nio.file.Path; import java.util.HashMap; @@ -39,8 +37,6 @@ import java.util.Map; import java.util.concurrent.TimeUnit; -@Named -@Singleton public class ApiClientFactory { private static final String SESSION_COOKIE_NAME = "JSESSIONID"; diff --git a/agent/src/main/java/com/walmartlabs/concord/agent/remote/QueueClientProvider.java b/agent/src/main/java/com/walmartlabs/concord/agent/remote/QueueClientProvider.java index 789a565b8a..63f6945bd2 100644 --- a/agent/src/main/java/com/walmartlabs/concord/agent/remote/QueueClientProvider.java +++ b/agent/src/main/java/com/walmartlabs/concord/agent/remote/QueueClientProvider.java @@ -26,13 +26,9 @@ import com.walmartlabs.concord.server.queueclient.QueueClientConfiguration; import javax.inject.Inject; -import javax.inject.Named; import javax.inject.Provider; -import javax.inject.Singleton; import java.net.URISyntaxException; -@Named -@Singleton public class QueueClientProvider implements Provider { private final AgentConfiguration agentCfg; diff --git a/cli/pom.xml b/cli/pom.xml index e4a5d95703..244c7e320b 100644 --- a/cli/pom.xml +++ b/cli/pom.xml @@ -6,7 +6,7 @@ com.walmartlabs.concord parent - 2.1.1-SNAPSHOT + 2.5.1-SNAPSHOT ../pom.xml diff --git a/client/pom.xml b/client/pom.xml index 4fc0aef8c0..a3c12448e2 100644 --- a/client/pom.xml +++ b/client/pom.xml @@ -6,7 +6,7 @@ com.walmartlabs.concord parent - 2.1.1-SNAPSHOT + 2.5.1-SNAPSHOT ../pom.xml diff --git a/client2/pom.xml b/client2/pom.xml index b4bd0b0986..983b440c44 100644 --- a/client2/pom.xml +++ b/client2/pom.xml @@ -6,7 +6,7 @@ com.walmartlabs.concord parent - 2.1.1-SNAPSHOT + 2.5.1-SNAPSHOT ../pom.xml diff --git a/client2/src/main/java/com/walmartlabs/concord/client2/impl/MultipartRequestBodyHandler.java b/client2/src/main/java/com/walmartlabs/concord/client2/impl/MultipartRequestBodyHandler.java index a6c705d22e..4575c072a8 100644 --- a/client2/src/main/java/com/walmartlabs/concord/client2/impl/MultipartRequestBodyHandler.java +++ b/client2/src/main/java/com/walmartlabs/concord/client2/impl/MultipartRequestBodyHandler.java @@ -27,6 +27,7 @@ import java.io.InputStream; import java.nio.file.Files; import java.nio.file.Path; +import java.util.Collection; import java.util.Map; import java.util.UUID; @@ -36,6 +37,7 @@ public static HttpEntity handle(ObjectMapper objectMapper, Map d return handle(new MultipartBuilder(), objectMapper, data); } + @SuppressWarnings("unchecked") public static HttpEntity handle(MultipartBuilder b, ObjectMapper objectMapper, Map data) { for (Map.Entry e : data.entrySet()) { String k = e.getKey(); @@ -60,6 +62,8 @@ public static HttpEntity handle(MultipartBuilder b, ObjectMapper objectMapper, M b.addFormDataPart(k, null, RequestBody.create(ContentType.TEXT_PLAIN, v.toString())); } else if (v instanceof String[]) { b.addFormDataPart(k, null, RequestBody.create(ContentType.TEXT_PLAIN, String.join(",", (String[]) v))); + } else if (v instanceof Collection) { + b.addFormDataPart(k, null, RequestBody.create(ContentType.TEXT_PLAIN, String.join(",", (Collection) v))); } else if (v instanceof UUID) { b.addFormDataPart(k, v.toString()); } else if (v instanceof Enum) { diff --git a/common/pom.xml b/common/pom.xml index d3800d275d..fa388b17ee 100644 --- a/common/pom.xml +++ b/common/pom.xml @@ -6,7 +6,7 @@ com.walmartlabs.concord parent - 2.1.1-SNAPSHOT + 2.5.1-SNAPSHOT ../pom.xml @@ -47,6 +47,31 @@ commons-validator provided + + com.fasterxml.jackson.core + jackson-databind + provided + + + com.fasterxml.jackson.datatype + jackson-datatype-jdk8 + provided + + + javax.inject + javax.inject + provided + + + com.fasterxml.jackson.datatype + jackson-datatype-guava + provided + + + com.fasterxml.jackson.datatype + jackson-datatype-jsr310 + provided + @@ -75,11 +100,6 @@ junit-jupiter-engine test - - com.fasterxml.jackson.core - jackson-databind - test - diff --git a/common/src/main/java/com/walmartlabs/concord/common/ObjectMapperProvider.java b/common/src/main/java/com/walmartlabs/concord/common/ObjectMapperProvider.java new file mode 100644 index 0000000000..7be85aca83 --- /dev/null +++ b/common/src/main/java/com/walmartlabs/concord/common/ObjectMapperProvider.java @@ -0,0 +1,59 @@ +package com.walmartlabs.concord.common; + +/*- + * ***** + * Concord + * ----- + * Copyright (C) 2017 - 2019 Walmart 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. + * ===== + */ + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; +import com.fasterxml.jackson.datatype.guava.GuavaModule; +import com.fasterxml.jackson.datatype.jdk8.Jdk8Module; +import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.inject.Provider; + +public class ObjectMapperProvider implements Provider { + + private static final Logger log = LoggerFactory.getLogger(ObjectMapperProvider.class); + + @Override + public ObjectMapper get() { + log.info("Using concord-common's ObjectMapper..."); + + ObjectMapper mapper = new ObjectMapper() + .registerModule(new Jdk8Module()) + .registerModule(new GuavaModule()) + .registerModule(new JavaTimeModule()); + + // Write dates as ISO-8601 + mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); + + // Ignore unknown properties + mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); + + // Ignore nulls + mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); + + return mapper; + } +} diff --git a/console2/pom.xml b/console2/pom.xml index 3df2f8be18..e6463b44de 100644 --- a/console2/pom.xml +++ b/console2/pom.xml @@ -5,7 +5,7 @@ com.walmartlabs.concord parent - 2.1.1-SNAPSHOT + 2.5.1-SNAPSHOT ../pom.xml diff --git a/console2/src/components/organisms/ProcessActivity/Toolbar.tsx b/console2/src/components/organisms/ProcessActivity/Toolbar.tsx index 1594193938..6bbd3393f1 100644 --- a/console2/src/components/organisms/ProcessActivity/Toolbar.tsx +++ b/console2/src/components/organisms/ProcessActivity/Toolbar.tsx @@ -146,7 +146,7 @@ const renderProcessStatus = (process?: ProcessEntry) => { let duration; if (process.status === ProcessStatus.RUNNING) { - duration = formatDuration(new Date().getTime() - parseDate(process.createdAt).getTime()); + duration = formatDuration(new Date().getTime() - parseDate(process.lastRunAt || process.createdAt).getTime()); } return ( <> diff --git a/dependency-manager/pom.xml b/dependency-manager/pom.xml index ca193853fa..32e3a3e83b 100644 --- a/dependency-manager/pom.xml +++ b/dependency-manager/pom.xml @@ -6,7 +6,7 @@ com.walmartlabs.concord parent - 2.1.1-SNAPSHOT + 2.5.1-SNAPSHOT ../pom.xml diff --git a/docker-images/agent/oss/centos/Dockerfile b/docker-images/agent/oss/centos/Dockerfile deleted file mode 100644 index 43974cf7c7..0000000000 --- a/docker-images/agent/oss/centos/Dockerfile +++ /dev/null @@ -1,20 +0,0 @@ -ARG docker_namespace=walmartlabs -ARG concord_version=latest - -FROM $docker_namespace/concord-ansible:$concord_version -LABEL maintainer="ibodrov@gmail.com" - -ENV DOCKER_HOST tcp://dind:2375 -ENV REQUESTS_CA_BUNDLE=/etc/ssl/certs/ca-bundle.crt - -USER root - -RUN dnf config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo && \ - dnf -y install docker-ce-cli uuid && \ - dnf clean all - -COPY --chown=concord:concord target/deps/ /home/concord/.m2/repository -ADD --chown=concord:concord target/dist/agent.tar.gz /opt/concord/agent/ - -USER concord -CMD ["bash", "/opt/concord/agent/start.sh"] diff --git a/docker-images/agent/pom.xml b/docker-images/agent/pom.xml index 175d05b0d1..b1e5a3521c 100644 --- a/docker-images/agent/pom.xml +++ b/docker-images/agent/pom.xml @@ -5,7 +5,7 @@ com.walmartlabs.concord.docker parent - 2.1.1-SNAPSHOT + 2.5.1-SNAPSHOT ../pom.xml @@ -15,7 +15,7 @@ ${docker.namespace}/concord-agent ${agent.image} - oss/centos/Dockerfile + oss/debian/Dockerfile false @@ -117,12 +117,4 @@ - - - debian - - oss/debian/Dockerfile - - - diff --git a/docker-images/ansible/galaxy_requirements.yml b/docker-images/ansible/galaxy_requirements.yml new file mode 100644 index 0000000000..eef53e024e --- /dev/null +++ b/docker-images/ansible/galaxy_requirements.yml @@ -0,0 +1,28 @@ +--- +collections: + - name: community.general + version: "7.0.1" + - name: ansible.windows + version: "1.14.0" + - name: ansible.posix + version: "1.5.4" + - name: community.windows + version: "1.13.0" + - name: kubernetes.core + version: "2.4.0" + - name: community.crypto + version: "2.13.1" + - name: community.mysql + version: "3.7.1" + - name: openstack.cloud + version: "2.1.0" + - name: community.postgresql + version: "2.4.1" + - name: community.docker + version: "3.4.6" + - name: "ansible.netcommon" + version: "5.1.1" + - name: "google.cloud" + version: "1.1.3" + - name: "chocolatey.chocolatey" + version: "1.4.0" diff --git a/docker-images/ansible/oss/centos/Dockerfile b/docker-images/ansible/oss/centos/Dockerfile deleted file mode 100644 index a2b4248696..0000000000 --- a/docker-images/ansible/oss/centos/Dockerfile +++ /dev/null @@ -1,45 +0,0 @@ -ARG docker_namespace=walmartlabs -ARG concord_version=latest - -FROM $docker_namespace/concord-base:$concord_version -LABEL maintainer="ybrigadirenko@walmartlabs.com" - -RUN mkdir -p /workspace -WORKDIR /workspace - -RUN dnf -y install \ - gcc \ - gcc-c++ \ - krb5-devel \ - krb5-libs \ - krb5-workstation \ - libffi-devel \ - openssh-clients \ - openssl-devel \ - rsync \ - util-linux && \ - dnf clean all - - -ENV PATH=/usr/local/bin/concord_venv/bin:${PATH} -ENV VIRTUAL_ENV=/usr/local/bin/concord_venv - -RUN umask 0022 && \ - pip3 install --no-cache-dir --upgrade --ignore-installed \ - "cryptography<=3.3.1" \ - "ansible>=2.8.0,<2.9.0" \ - "Appium-Python-Client<1.0" \ - boto3 \ - botocore \ - bzt \ - docker \ - kerberos \ - openshift \ - pbr \ - pyvmomi \ - pywinrm>=0.4.1 \ - requests_kerberos \ - urllib3 \ - ujson - -USER concord diff --git a/docker-images/ansible/oss/debian/Dockerfile b/docker-images/ansible/oss/debian/Dockerfile index 4cd4d93bba..94131696f6 100644 --- a/docker-images/ansible/oss/debian/Dockerfile +++ b/docker-images/ansible/oss/debian/Dockerfile @@ -10,6 +10,8 @@ ENV REQUESTS_CA_BUNDLE=/etc/ssl/certs/ca-certificates.crt RUN mkdir -p /workspace WORKDIR /workspace +COPY galaxy_requirements.yml galaxy_requirements.yml + RUN DEBIAN_FRONTEND=${DEBIAN_FRONTEND} apt-get -y install \ gcc \ g++ \ @@ -29,21 +31,27 @@ ENV VIRTUAL_ENV=/usr/local/bin/concord_venv RUN umask 0022 && \ pip3 install --no-cache-dir --upgrade --break-system-packages --ignore-installed \ - "cryptography<=3.3.1" \ - "ansible>=2.8.0,<2.9.0" \ - "Appium-Python-Client<1.0" \ - "openshift<=0.11.2" \ - "jinja2<=3.0.3" \ - boto3 \ - botocore \ - bzt \ - docker \ - kerberos \ - pbr \ - pyvmomi \ - "pywinrm>=0.4.1" \ - requests_kerberos \ - urllib3 \ - ujson + "cryptography<=3.4.8" \ + "ansible-core>=2.14,<2.15" \ + "Appium-Python-Client<1.0" \ + "openshift==0.13.2" \ + "jinja2<=3.1.0" \ + boto3 \ + botocore \ + bzt \ + docker \ + kerberos \ + kubernetes \ + pyyaml \ + pbr \ + pyvmomi \ + "pywinrm>=0.4.3" \ + requests_kerberos \ + urllib3 \ + ujson \ + virtualenv + +RUN umask 0022 && \ + ansible-galaxy collection install -p /usr/share/ansible/collections -r galaxy_requirements.yml USER concord diff --git a/docker-images/ansible/pom.xml b/docker-images/ansible/pom.xml index f1d448825c..5e24a89d7d 100644 --- a/docker-images/ansible/pom.xml +++ b/docker-images/ansible/pom.xml @@ -5,7 +5,7 @@ com.walmartlabs.concord.docker parent - 2.1.1-SNAPSHOT + 2.5.1-SNAPSHOT ../pom.xml @@ -15,7 +15,7 @@ ${docker.namespace}/concord-ansible ${ansible.image} - oss/centos/Dockerfile + oss/debian/Dockerfile false @@ -42,13 +42,4 @@ - - - - debian - - oss/debian/Dockerfile - - - diff --git a/docker-images/base/oss/centos/Dockerfile b/docker-images/base/oss/centos/Dockerfile deleted file mode 100644 index cfcae8d472..0000000000 --- a/docker-images/base/oss/centos/Dockerfile +++ /dev/null @@ -1,48 +0,0 @@ -FROM library/centos:8 -LABEL maintainer="mtkunke@walmartlabs.com" - -ENTRYPOINT ["/usr/local/bin/concord_venv/bin/dumb-init", "--"] - -RUN echo 'fastestmirror=true' >> /etc/dnf/dnf.conf && \ - echo 'max_parallel_downloads=10' >> /etc/dnf/dnf.conf - -# update mirrors to point to vault.centos.org(older versions) -RUN cd /etc/yum.repos.d/ && \ - sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-* && \ - sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-* - -# requires Git >= 2.3 -RUN rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial && \ - dnf -y upgrade && \ - dnf -y install \ - dnf-plugins-core \ - which \ - libtool-ltdl \ - strace \ - python3 \ - python3-virtualenv \ - git \ - coreutils-single \ - glibc-all-langpacks && \ - dnf clean all && \ - alternatives --set python /usr/bin/python3 && \ - alternatives --install /usr/bin/pip pip /usr/bin/pip2 0 - -ADD --chmod=755 ./get_jdk_url.sh /tmp/ -ARG jdk_version -ENV JDK_VERSION=${jdk_version} -ENV TARGETARCH=${TARGETARCH:-"amd64"} -RUN curl --location --output /tmp/jdk.tar.gz $(/tmp/get_jdk_url.sh) && \ - mkdir /opt/jdk && \ - tar xpf /tmp/jdk.tar.gz --strip 1 -C /opt/jdk && \ - rm /tmp/jdk.tar.gz - -ENV JAVA_HOME /opt/jdk -ENV PATH="${JAVA_HOME}/bin:${PATH}" -ENV LC_CTYPE en_US.UTF-8 -ENV LANG en_US.UTF-8 - -RUN virtualenv /usr/local/bin/concord_venv && \ - /usr/local/bin/concord_venv/bin/pip3 --no-cache-dir install dumb-init - -RUN groupadd -g 456 concord && useradd --no-log-init -u 456 -g concord -m -s /sbin/nologin concord diff --git a/docker-images/base/oss/debian/Dockerfile b/docker-images/base/oss/debian/Dockerfile index d21bfaec86..5374975127 100644 --- a/docker-images/base/oss/debian/Dockerfile +++ b/docker-images/base/oss/debian/Dockerfile @@ -7,10 +7,9 @@ ENTRYPOINT ["/usr/local/bin/concord_venv/bin/dumb-init", "--"] RUN apt-get update && \ apt-get -y upgrade && \ - apt-get -y install openssh-client libltdl-dev wget unzip diffutils strace git gdebi-core && \ - apt-get -y install python3 python3-pip coreutils locales locales-all curl && \ + apt-get -y install openssh-client libltdl-dev wget unzip diffutils strace git gdebi-core \ + python3 python3-pip python-is-python3 coreutils locales locales-all curl && \ apt-get clean && \ - ln -f -s /usr/bin/python3 /usr/bin/python && \ pip3 install --no-cache-dir --break-system-packages dumb-init virtualenv diff --git a/docker-images/base/pom.xml b/docker-images/base/pom.xml index 0b87dbeaa2..279070ea99 100644 --- a/docker-images/base/pom.xml +++ b/docker-images/base/pom.xml @@ -6,7 +6,7 @@ com.walmartlabs.concord.docker parent - 2.1.1-SNAPSHOT + 2.5.1-SNAPSHOT ../pom.xml @@ -16,7 +16,7 @@ ${docker.namespace}/concord-base ${base.image} - oss/centos/Dockerfile + oss/debian/Dockerfile false @@ -34,13 +34,4 @@ - - - - debian - - oss/debian/Dockerfile - - - diff --git a/docker-images/pom.xml b/docker-images/pom.xml index dbf4362db9..98ec2fe95a 100644 --- a/docker-images/pom.xml +++ b/docker-images/pom.xml @@ -5,7 +5,7 @@ com.walmartlabs.concord parent - 2.1.1-SNAPSHOT + 2.5.1-SNAPSHOT ../pom.xml diff --git a/docker-images/server/pom.xml b/docker-images/server/pom.xml index 2210ff32ed..7e02c7f4b1 100644 --- a/docker-images/server/pom.xml +++ b/docker-images/server/pom.xml @@ -5,7 +5,7 @@ com.walmartlabs.concord.docker parent - 2.1.1-SNAPSHOT + 2.5.1-SNAPSHOT ../pom.xml diff --git a/forms/pom.xml b/forms/pom.xml index 566ee416f3..4fd029283b 100644 --- a/forms/pom.xml +++ b/forms/pom.xml @@ -6,7 +6,7 @@ com.walmartlabs.concord parent - 2.1.1-SNAPSHOT + 2.5.1-SNAPSHOT ../pom.xml diff --git a/imports/pom.xml b/imports/pom.xml index c8a1628e0f..1c9941bab0 100644 --- a/imports/pom.xml +++ b/imports/pom.xml @@ -6,7 +6,7 @@ com.walmartlabs.concord parent - 2.1.1-SNAPSHOT + 2.5.1-SNAPSHOT ../pom.xml diff --git a/it/common/pom.xml b/it/common/pom.xml index a57fe249c2..b0f140cf92 100644 --- a/it/common/pom.xml +++ b/it/common/pom.xml @@ -6,7 +6,7 @@ com.walmartlabs.concord.it parent - 2.1.1-SNAPSHOT + 2.5.1-SNAPSHOT ../pom.xml diff --git a/it/compat/pom.xml b/it/compat/pom.xml index dcf30a4d01..ff9240fca5 100644 --- a/it/compat/pom.xml +++ b/it/compat/pom.xml @@ -6,7 +6,7 @@ com.walmartlabs.concord.it parent - 2.1.1-SNAPSHOT + 2.5.1-SNAPSHOT ../pom.xml diff --git a/it/console/pom.xml b/it/console/pom.xml index 343e8e99c5..d77bd4e437 100644 --- a/it/console/pom.xml +++ b/it/console/pom.xml @@ -6,7 +6,7 @@ com.walmartlabs.concord.it parent - 2.1.1-SNAPSHOT + 2.5.1-SNAPSHOT ../pom.xml diff --git a/it/pom.xml b/it/pom.xml index 23ad1112a6..5a28cb8911 100644 --- a/it/pom.xml +++ b/it/pom.xml @@ -5,7 +5,7 @@ com.walmartlabs.concord parent - 2.1.1-SNAPSHOT + 2.5.1-SNAPSHOT ../pom.xml @@ -18,6 +18,7 @@ tasks/dependency-manager-test tasks/serialization-test tasks/suspend-test + tasks/client1-test common server @@ -25,6 +26,8 @@ runtime-v1 runtime-v2 compat + + testing-server diff --git a/it/runtime-v1/pom.xml b/it/runtime-v1/pom.xml index 0de62eba74..82037fc6a3 100644 --- a/it/runtime-v1/pom.xml +++ b/it/runtime-v1/pom.xml @@ -6,7 +6,7 @@ com.walmartlabs.concord.it parent - 2.1.1-SNAPSHOT + 2.5.1-SNAPSHOT ../pom.xml diff --git a/it/runtime-v1/src/test/filtered-resources/version.properties b/it/runtime-v1/src/test/filtered-resources/version.properties new file mode 100644 index 0000000000..7e48b881dd --- /dev/null +++ b/it/runtime-v1/src/test/filtered-resources/version.properties @@ -0,0 +1 @@ +project.version = ${project.version} \ No newline at end of file diff --git a/it/runtime-v1/src/test/java/com/walmartlabs/concord/it/runtime/v1/ITConstants.java b/it/runtime-v1/src/test/java/com/walmartlabs/concord/it/runtime/v1/ITConstants.java index 192d6b0852..2d12545b88 100644 --- a/it/runtime-v1/src/test/java/com/walmartlabs/concord/it/runtime/v1/ITConstants.java +++ b/it/runtime-v1/src/test/java/com/walmartlabs/concord/it/runtime/v1/ITConstants.java @@ -20,10 +20,29 @@ * ===== */ +import java.io.IOException; +import java.io.InputStream; +import java.util.Properties; + public final class ITConstants { + public static final String PROJECT_VERSION; public static final long DEFAULT_TEST_TIMEOUT = 120000; + static { + PROJECT_VERSION = getProperties("version.properties").getProperty("project.version"); + } + + private static Properties getProperties(String path) { + try (InputStream in = ClassLoader.getSystemResourceAsStream(path)) { + Properties props = new Properties(); + props.load(in); + return props; + } catch (IOException e) { + throw new RuntimeException(e); + } + } + private ITConstants() { } } diff --git a/it/runtime-v1/src/test/java/com/walmartlabs/concord/it/runtime/v1/ProcessIT.java b/it/runtime-v1/src/test/java/com/walmartlabs/concord/it/runtime/v1/ProcessIT.java index b8e9f63405..5fbf46b5c9 100644 --- a/it/runtime-v1/src/test/java/com/walmartlabs/concord/it/runtime/v1/ProcessIT.java +++ b/it/runtime-v1/src/test/java/com/walmartlabs/concord/it/runtime/v1/ProcessIT.java @@ -24,8 +24,11 @@ import ca.ibodrov.concord.testcontainers.Payload; import ca.ibodrov.concord.testcontainers.ProcessListQuery; import ca.ibodrov.concord.testcontainers.junit5.ConcordRule; +import com.google.common.base.Charsets; +import com.google.common.io.Resources; import com.walmartlabs.concord.client.FormListEntry; import com.walmartlabs.concord.client.FormSubmitResponse; +import com.walmartlabs.concord.client.ProcessCheckpointEntry; import com.walmartlabs.concord.client.ProcessEntry; import com.walmartlabs.concord.client.ProcessEntry.StatusEnum; import com.walmartlabs.concord.it.common.JGitUtils; @@ -35,8 +38,10 @@ import org.junit.jupiter.api.Timeout; import org.junit.jupiter.api.extension.RegisterExtension; +import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; +import java.net.URL; import java.util.Collections; import java.util.List; import java.util.Map; @@ -517,6 +522,22 @@ public void testEmptyExclusiveGroup() throws Exception { proc.assertLog(".*Invalid exclusive mode.*"); } + @Test + public void testTaskWithClient1() throws Exception { + String concordYml = resourceToString(ProcessIT.class.getResource("client1Task/concord.yml")) + .replaceAll("PROJECT_VERSION", ITConstants.PROJECT_VERSION); + + Payload payload = new Payload().concordYml(concordYml); + + ConcordProcess proc = concord.processes().start(payload); + proc.expectStatus(StatusEnum.FINISHED); + + // --- + + proc.assertLog(".*process entry: RUNNING.*"); + proc.assertLog(".*Works!.*"); + } + @SuppressWarnings("unchecked") private static void assertProcessErrorMessage(ProcessEntry p, String expected) { assertNotNull(p); @@ -536,4 +557,8 @@ private static void assertProcessErrorMessage(ProcessEntry p, String expected) { private static URI resource(String name) throws URISyntaxException { return ProcessIT.class.getResource(name).toURI(); } + + private static String resourceToString(URL resource) throws IOException { + return Resources.toString(resource, Charsets.UTF_8); + } } diff --git a/it/runtime-v1/src/test/resources/com/walmartlabs/concord/it/runtime/v1/client1Task/concord.yml b/it/runtime-v1/src/test/resources/com/walmartlabs/concord/it/runtime/v1/client1Task/concord.yml new file mode 100644 index 0000000000..b66dff02df --- /dev/null +++ b/it/runtime-v1/src/test/resources/com/walmartlabs/concord/it/runtime/v1/client1Task/concord.yml @@ -0,0 +1,8 @@ +configuration: + dependencies: + - "mvn://com.walmartlabs.concord.it.tasks:client1-test:PROJECT_VERSION" + +flows: + default: + - task: client1Test + - log: "Works!" \ No newline at end of file diff --git a/it/runtime-v2/pom.xml b/it/runtime-v2/pom.xml index 45c8a8bfa9..00433176a2 100644 --- a/it/runtime-v2/pom.xml +++ b/it/runtime-v2/pom.xml @@ -6,7 +6,7 @@ com.walmartlabs.concord.it parent - 2.1.1-SNAPSHOT + 2.5.1-SNAPSHOT ../pom.xml diff --git a/it/runtime-v2/src/test/java/com/walmartlabs/concord/it/runtime/v2/ProcessIT.java b/it/runtime-v2/src/test/java/com/walmartlabs/concord/it/runtime/v2/ProcessIT.java index 9748625836..24fbb7798d 100644 --- a/it/runtime-v2/src/test/java/com/walmartlabs/concord/it/runtime/v2/ProcessIT.java +++ b/it/runtime-v2/src/test/java/com/walmartlabs/concord/it/runtime/v2/ProcessIT.java @@ -496,4 +496,20 @@ public void testForkVariablesAfterForm() throws Exception { fork.assertLog(".*parentInstanceId: " + proc.instanceId() + ".*"); fork.assertLog(".*txId: " + fork.instanceId() + ".*"); } + + @Test + public void testTaskWithClient1() throws Exception { + String concordYml = resourceToString(ProcessIT.class.getResource("client1Task/concord.yml")) + .replaceAll("PROJECT_VERSION", ITConstants.PROJECT_VERSION); + + Payload payload = new Payload().concordYml(concordYml); + + ConcordProcess proc = concord.processes().start(payload); + expectStatus(proc, ProcessEntry.StatusEnum.FINISHED); + + // --- + + proc.assertLog(".*process entry: RUNNING.*"); + proc.assertLog(".*Works!.*"); + } } diff --git a/it/runtime-v2/src/test/resources/com/walmartlabs/concord/it/runtime/v2/client1Task/concord.yml b/it/runtime-v2/src/test/resources/com/walmartlabs/concord/it/runtime/v2/client1Task/concord.yml new file mode 100644 index 0000000000..29d3e6f7d4 --- /dev/null +++ b/it/runtime-v2/src/test/resources/com/walmartlabs/concord/it/runtime/v2/client1Task/concord.yml @@ -0,0 +1,9 @@ +configuration: + runtime: concord-v2 + dependencies: + - "mvn://com.walmartlabs.concord.it.tasks:client1-test:PROJECT_VERSION" + +flows: + default: + - task: client1Test + - log: "Works!" \ No newline at end of file diff --git a/it/server/pom.xml b/it/server/pom.xml index 70c293ea02..74ca5c19e1 100644 --- a/it/server/pom.xml +++ b/it/server/pom.xml @@ -6,7 +6,7 @@ com.walmartlabs.concord.it parent - 2.1.1-SNAPSHOT + 2.5.1-SNAPSHOT ../pom.xml @@ -29,6 +29,7 @@ ldap-node:389 custom 8001 + false ${settings.localRepository} net-server-it osixia/openldap @@ -268,6 +269,7 @@ ldap://localhost:${it.ldap.port} ${project.version} ${it.server.port} + ${it.skipDocker} ${tmp.dir} diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/AbstractServerIT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/AbstractServerIT.java index c13c02546d..9d715ed5c0 100644 --- a/it/server/src/test/java/com/walmartlabs/concord/it/server/AbstractServerIT.java +++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/AbstractServerIT.java @@ -214,4 +214,8 @@ protected static String env(String k, String def) { } return v; } + + public static boolean shouldSkipDockerTests() { + return Boolean.parseBoolean(System.getenv("IT_SKIP_DOCKER_TESTS")); + } } diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/AnsibleIT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/AnsibleIT.java index fccd8dc785..b87cd4a44b 100644 --- a/it/server/src/test/java/com/walmartlabs/concord/it/server/AnsibleIT.java +++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/AnsibleIT.java @@ -98,7 +98,9 @@ public void testVault() throws Exception { // --- ProcessEntry pir = waitForCompletion(processApi, spr.getInstanceId()); - assertEquals(ProcessEntry.StatusEnum.FINISHED, pir.getStatus()); + + assertEquals(ProcessEntry.StatusEnum.FINISHED, pir.getStatus(), + new String(getLog(pir.getLogFileName()))); // --- diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/CryptoIT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/CryptoIT.java index 98389eb456..7f76bc688a 100644 --- a/it/server/src/test/java/com/walmartlabs/concord/it/server/CryptoIT.java +++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/CryptoIT.java @@ -325,7 +325,7 @@ public void testDecryptInvalidString() throws Exception { // --- pir = waitForCompletion(processApi, spr.getInstanceId()); - assertEquals(ProcessEntry.StatusEnum.FAILED, pir.getStatus()); + assertEquals(ProcessEntry.StatusEnum.FAILED, pir.getStatus(), "Process logs: " + new String(getLog(pir.getLogFileName()))); } @Test diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/DockerAnsibleIT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/DockerAnsibleIT.java index 2a2242a04c..5bf1535aa1 100644 --- a/it/server/src/test/java/com/walmartlabs/concord/it/server/DockerAnsibleIT.java +++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/DockerAnsibleIT.java @@ -24,6 +24,7 @@ import com.walmartlabs.concord.client.ProcessEntry; import com.walmartlabs.concord.client.StartProcessResponse; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.DisabledIfEnvironmentVariable; import java.io.File; import java.util.HashMap; @@ -35,6 +36,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; +@DisabledIfEnvironmentVariable(named = "SKIP_DOCKER_TESTS", matches = "true", disabledReason = "Requires dockerd listening on a tcp socket. Not available in a typical CI environment") public class DockerAnsibleIT extends AbstractServerIT { @Test diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/DockerIT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/DockerIT.java index 04b298115f..89647ab99c 100644 --- a/it/server/src/test/java/com/walmartlabs/concord/it/server/DockerIT.java +++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/DockerIT.java @@ -24,6 +24,8 @@ import com.walmartlabs.concord.client.ProcessEntry; import com.walmartlabs.concord.client.StartProcessResponse; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.DisabledIf; +import org.junit.jupiter.api.condition.DisabledIfEnvironmentVariable; import java.util.HashMap; import java.util.Map; @@ -32,6 +34,7 @@ import static com.walmartlabs.concord.it.common.ServerClient.*; import static org.junit.jupiter.api.Assertions.assertNotNull; +@DisabledIfEnvironmentVariable(named = "SKIP_DOCKER_TESTS", matches = "true", disabledReason = "Requires dockerd listening on a tcp socket. Not available in a typical CI environment") public class DockerIT extends AbstractServerIT { @Test diff --git a/it/server/src/test/resources/com/walmartlabs/concord/it/server/ansibleVault/get_password.py b/it/server/src/test/resources/com/walmartlabs/concord/it/server/ansibleVault/get_password.py index 24f2a7760d..7064cc3efb 100755 --- a/it/server/src/test/resources/com/walmartlabs/concord/it/server/ansibleVault/get_password.py +++ b/it/server/src/test/resources/com/walmartlabs/concord/it/server/ansibleVault/get_password.py @@ -1,2 +1,2 @@ -#!/usr/bin/python +#!/usr/bin/python3 print("q1") diff --git a/it/server/src/test/resources/com/walmartlabs/concord/it/server/ansibleVaultMultiplePasswordFiles/get_all_password.py b/it/server/src/test/resources/com/walmartlabs/concord/it/server/ansibleVaultMultiplePasswordFiles/get_all_password.py index c1ce83c804..d3bb3236ad 100755 --- a/it/server/src/test/resources/com/walmartlabs/concord/it/server/ansibleVaultMultiplePasswordFiles/get_all_password.py +++ b/it/server/src/test/resources/com/walmartlabs/concord/it/server/ansibleVaultMultiplePasswordFiles/get_all_password.py @@ -1,2 +1,2 @@ -#!/usr/bin/python +#!/usr/bin/python3 print("q2") diff --git a/it/server/src/test/resources/com/walmartlabs/concord/it/server/ansibleVaultMultiplePasswordFiles/get_local_password.py b/it/server/src/test/resources/com/walmartlabs/concord/it/server/ansibleVaultMultiplePasswordFiles/get_local_password.py index 24f2a7760d..7064cc3efb 100755 --- a/it/server/src/test/resources/com/walmartlabs/concord/it/server/ansibleVaultMultiplePasswordFiles/get_local_password.py +++ b/it/server/src/test/resources/com/walmartlabs/concord/it/server/ansibleVaultMultiplePasswordFiles/get_local_password.py @@ -1,2 +1,2 @@ -#!/usr/bin/python +#!/usr/bin/python3 print("q1") diff --git a/it/tasks/broken-deps/pom.xml b/it/tasks/broken-deps/pom.xml index ae95bac95f..f0bffdf254 100644 --- a/it/tasks/broken-deps/pom.xml +++ b/it/tasks/broken-deps/pom.xml @@ -5,7 +5,7 @@ com.walmartlabs.concord.it parent - 2.1.1-SNAPSHOT + 2.5.1-SNAPSHOT ../../pom.xml diff --git a/it/tasks/client1-test/pom.xml b/it/tasks/client1-test/pom.xml new file mode 100644 index 0000000000..361290c5c2 --- /dev/null +++ b/it/tasks/client1-test/pom.xml @@ -0,0 +1,52 @@ + + + 4.0.0 + + + com.walmartlabs.concord.it + parent + 2.5.1-SNAPSHOT + ../../pom.xml + + + com.walmartlabs.concord.it.tasks + client1-test + jar + + + + com.walmartlabs.concord + concord-sdk + provided + + + com.walmartlabs.concord.runtime.v2 + concord-runtime-sdk-v2 + provided + + + com.walmartlabs.concord + concord-client + provided + + + javax.inject + javax.inject + provided + + + org.slf4j + slf4j-api + provided + + + + + + + org.eclipse.sisu + sisu-maven-plugin + + + + diff --git a/it/tasks/client1-test/src/main/java/com/walmartlabs/concord/it/tasks/suspendtest/Client1TestTask.java b/it/tasks/client1-test/src/main/java/com/walmartlabs/concord/it/tasks/suspendtest/Client1TestTask.java new file mode 100644 index 0000000000..95fc7d15d1 --- /dev/null +++ b/it/tasks/client1-test/src/main/java/com/walmartlabs/concord/it/tasks/suspendtest/Client1TestTask.java @@ -0,0 +1,55 @@ +package com.walmartlabs.concord.it.tasks.suspendtest; + +/*- + * ***** + * Concord + * ----- + * Copyright (C) 2017 - 2023 Walmart 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. + * ===== + */ + +import com.walmartlabs.concord.ApiClient; +import com.walmartlabs.concord.client.ApiClientConfiguration; +import com.walmartlabs.concord.client.ApiClientFactory; +import com.walmartlabs.concord.client.ProcessApi; +import com.walmartlabs.concord.client.ProcessEntry; +import com.walmartlabs.concord.sdk.Context; +import com.walmartlabs.concord.sdk.ContextUtils; +import com.walmartlabs.concord.sdk.Task; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.inject.Inject; +import javax.inject.Named; + +@Named("client1Test") +public class Client1TestTask implements Task { + + private static final Logger log = LoggerFactory.getLogger(Client1TestTask.class); + + private final ApiClientFactory factory; + + @Inject + public Client1TestTask(ApiClientFactory factory) { + this.factory = factory; + } + + @Override + public void execute(Context ctx) throws Exception { + ProcessApi api = new ProcessApi(factory.create(ApiClientConfiguration.builder().context(ctx).build())); + ProcessEntry p = api.get(ContextUtils.getTxId(ctx)); + log.info("process entry: {}", p.getStatus()); + } +} diff --git a/it/tasks/client1-test/src/main/java/com/walmartlabs/concord/it/tasks/suspendtest/Client1TestTaskV2.java b/it/tasks/client1-test/src/main/java/com/walmartlabs/concord/it/tasks/suspendtest/Client1TestTaskV2.java new file mode 100644 index 0000000000..8545d8b881 --- /dev/null +++ b/it/tasks/client1-test/src/main/java/com/walmartlabs/concord/it/tasks/suspendtest/Client1TestTaskV2.java @@ -0,0 +1,62 @@ +package com.walmartlabs.concord.it.tasks.suspendtest; + +/*- + * ***** + * Concord + * ----- + * Copyright (C) 2017 - 2023 Walmart 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. + * ===== + */ + +import com.walmartlabs.concord.ApiClient; +import com.walmartlabs.concord.client.ApiClientFactory; +import com.walmartlabs.concord.client.ProcessApi; +import com.walmartlabs.concord.client.ProcessEntry; +import com.walmartlabs.concord.runtime.v2.sdk.Context; +import com.walmartlabs.concord.runtime.v2.sdk.Task; +import com.walmartlabs.concord.runtime.v2.sdk.TaskResult; +import com.walmartlabs.concord.runtime.v2.sdk.Variables; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.inject.Inject; +import javax.inject.Named; + +@Named("client1Test") +public class Client1TestTaskV2 implements Task { + + private static final Logger log = LoggerFactory.getLogger(Client1TestTaskV2.class); + + private final Context ctx; + private final ApiClient apiClient; + private final ApiClientFactory factory; + + @Inject + public Client1TestTaskV2(Context ctx, ApiClient apiClient, ApiClientFactory factory) { + this.ctx = ctx; + this.apiClient = apiClient; + this.factory = factory; + } + + @Override + public TaskResult execute(Variables input) throws Exception { + ProcessApi api = new ProcessApi(apiClient); + + ProcessEntry p = api.get(ctx.processInstanceId()); + log.info("process entry: {}", p.getStatus()); + + return TaskResult.success(); + } +} diff --git a/it/tasks/dependency-manager-test/pom.xml b/it/tasks/dependency-manager-test/pom.xml index 2549ad444a..f276db38fb 100644 --- a/it/tasks/dependency-manager-test/pom.xml +++ b/it/tasks/dependency-manager-test/pom.xml @@ -5,7 +5,7 @@ com.walmartlabs.concord.it parent - 2.1.1-SNAPSHOT + 2.5.1-SNAPSHOT ../../pom.xml diff --git a/it/tasks/serialization-test/pom.xml b/it/tasks/serialization-test/pom.xml index 857a52ef46..f111fb57d2 100644 --- a/it/tasks/serialization-test/pom.xml +++ b/it/tasks/serialization-test/pom.xml @@ -5,7 +5,7 @@ com.walmartlabs.concord.it parent - 2.1.1-SNAPSHOT + 2.5.1-SNAPSHOT ../../pom.xml diff --git a/it/tasks/suspend-test/pom.xml b/it/tasks/suspend-test/pom.xml index 9ec57b0391..2987b916a8 100644 --- a/it/tasks/suspend-test/pom.xml +++ b/it/tasks/suspend-test/pom.xml @@ -5,7 +5,7 @@ com.walmartlabs.concord.it parent - 2.1.1-SNAPSHOT + 2.5.1-SNAPSHOT ../../pom.xml diff --git a/it/testing-server/pom.xml b/it/testing-server/pom.xml new file mode 100644 index 0000000000..a5b6909cb6 --- /dev/null +++ b/it/testing-server/pom.xml @@ -0,0 +1,62 @@ + + + 4.0.0 + + + com.walmartlabs.concord.it + parent + 2.5.1-SNAPSHOT + ../pom.xml + + + testing-concord-server + jar + + + + com.walmartlabs.concord.server + concord-server + + + com.walmartlabs.concord.server.plugins.ansible + concord-ansible-plugin + + + com.walmartlabs.concord.server.plugins + concord-oneops-plugin + + + com.walmartlabs.concord.server.plugins.noderoster + concord-noderoster-plugin + + + com.walmartlabs.concord.server.plugins + pfed-sso + + + + + com.walmartlabs.concord + concord-agent + + + org.testcontainers + postgresql + + + com.typesafe + config + + + + com.walmartlabs.concord + concord-client2 + test + + + org.junit.jupiter + junit-jupiter-api + test + + + diff --git a/it/testing-server/src/main/java/com/walmartlabs/concord/it/testingserver/TestingConcordAgent.java b/it/testing-server/src/main/java/com/walmartlabs/concord/it/testingserver/TestingConcordAgent.java new file mode 100644 index 0000000000..531378e33b --- /dev/null +++ b/it/testing-server/src/main/java/com/walmartlabs/concord/it/testingserver/TestingConcordAgent.java @@ -0,0 +1,97 @@ +package com.walmartlabs.concord.it.testingserver; + +/*- + * ***** + * Concord + * ----- + * Copyright (C) 2017 - 2023 Walmart 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. + * ===== + */ + +import com.google.inject.Guice; +import com.google.inject.Module; +import com.typesafe.config.Config; +import com.typesafe.config.ConfigFactory; +import com.typesafe.config.ConfigParseOptions; +import com.typesafe.config.ConfigResolveOptions; +import com.walmartlabs.concord.agent.Agent; +import com.walmartlabs.concord.agent.AgentModule; + +import java.util.List; +import java.util.Map; +import java.util.function.Function; +import java.util.stream.Stream; + +/** + * A helper class for running concord-agent. + * The agent runs in the same JVM as TestingConcordAgent. + */ +public class TestingConcordAgent implements AutoCloseable { + + private final Map extraConfiguration; + private final List> extraModules; + private final int apiPort; + private final String agentApiKey; + + private Agent agent; + + public TestingConcordAgent(TestingConcordServer testingConcordServer) { + this(testingConcordServer, Map.of(), List.of()); + } + + public TestingConcordAgent(TestingConcordServer testingConcordServer, Map extraConfiguration, List> extraModules) { + this.apiPort = testingConcordServer.getApiPort(); + this.agentApiKey = testingConcordServer.getAgentApiKey(); + this.extraConfiguration = extraConfiguration; + this.extraModules = extraModules; + } + + public synchronized void start() { + var config = prepareConfig(); + var system = new AgentModule(config); + var allModules = Stream.concat(extraModules.stream().map(f -> f.apply(config)), Stream.of(system)).toList(); + var injector = Guice.createInjector(allModules); + agent = injector.getInstance(Agent.class); + agent.start(); + } + + public synchronized void stop() { + if (agent != null) { + agent.stop(); + agent = null; + } + } + + @Override + public void close() { + this.stop(); + } + + private Config prepareConfig() { + var extraConfig = ConfigFactory.parseMap(this.extraConfiguration); + + var testConfig = ConfigFactory.parseMap(Map.of( + "maintenanceModeListenerPort", 0, + "server.apiBaseUrl", "http://localhost:" + apiPort, + "server.websocketUrl", "ws://localhost:" + apiPort + "/websocket", + "server.apiKey", agentApiKey + )); + + var defaultConfig = ConfigFactory.load("concord-agent.conf", ConfigParseOptions.defaults(), ConfigResolveOptions.defaults().setAllowUnresolved(true)) + .getConfig("concord-agent"); + + return extraConfig.withFallback(testConfig.withFallback(defaultConfig)).resolve(); + } +} diff --git a/it/testing-server/src/main/java/com/walmartlabs/concord/it/testingserver/TestingConcordServer.java b/it/testing-server/src/main/java/com/walmartlabs/concord/it/testingserver/TestingConcordServer.java new file mode 100644 index 0000000000..4f1260828e --- /dev/null +++ b/it/testing-server/src/main/java/com/walmartlabs/concord/it/testingserver/TestingConcordServer.java @@ -0,0 +1,177 @@ +package com.walmartlabs.concord.it.testingserver; + +/*- + * ***** + * Concord + * ----- + * Copyright (C) 2017 - 2023 Walmart 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. + * ===== + */ + +import com.google.common.collect.ImmutableMap; +import com.google.inject.Module; +import com.typesafe.config.Config; +import com.typesafe.config.ConfigFactory; +import com.typesafe.config.ConfigParseOptions; +import com.typesafe.config.ConfigResolveOptions; +import com.walmartlabs.concord.server.ConcordServer; +import com.walmartlabs.concord.server.ConcordServerModule; +import org.testcontainers.containers.PostgreSQLContainer; + +import java.security.SecureRandom; +import java.util.Base64; +import java.util.List; +import java.util.Map; +import java.util.function.Function; +import java.util.stream.Stream; + +import static com.google.common.base.Preconditions.checkArgument; +import static java.util.Objects.requireNonNull; + +/** + * A helper class for running concord-server. It runs PostgreSQL in Docker + * and the server runs in the same JVM as TestingConcordServer. + */ +public class TestingConcordServer implements AutoCloseable { + + private final PostgreSQLContainer db; + private final Map extraConfiguration; + private final List> extraModules; + private final int apiPort; + private final String adminApiKey; + private final String agentApiKey; + + private ConcordServer server; + + public TestingConcordServer(PostgreSQLContainer db) { + this(db, 8001, Map.of(), List.of()); + } + + public TestingConcordServer(PostgreSQLContainer db, int apiPort, Map extraConfiguration, List> extraModules) { + this.db = requireNonNull(db); + this.extraConfiguration = requireNonNull(extraConfiguration); + this.apiPort = apiPort; + this.extraModules = requireNonNull(extraModules); + this.adminApiKey = randomString(8); + this.agentApiKey = randomString(16); + } + + public synchronized TestingConcordServer start() throws Exception { + checkArgument(db.isRunning(), "The database container is not running"); + + var config = prepareConfig(db); + var system = new ConcordServerModule(config); + var allModules = Stream.concat(extraModules.stream().map(f -> f.apply(config)), Stream.of(system)).toList(); + server = ConcordServer.withModules(allModules) + .start(); + + return this; + } + + public synchronized void stop() throws Exception { + if (server != null) { + server.stop(); + server = null; + } + } + + @Override + public void close() throws Exception { + this.stop(); + } + + public int getApiPort() { + return apiPort; + } + + public String getApiBaseUrl() { + return "http://localhost:" + apiPort; + } + + public ConcordServer getServer() { + return server; + } + + public PostgreSQLContainer getDb() { + return db; + } + + public String getAdminApiKey() { + return adminApiKey; + } + + public String getAgentApiKey() { + return agentApiKey; + } + + private Config prepareConfig(PostgreSQLContainer db) { + var extraConfig = ConfigFactory.parseMap(this.extraConfiguration); + + var testConfig = ConfigFactory.parseMap(ImmutableMap.builder() + .put("server.port", String.valueOf(apiPort)) + .put("db.url", db.getJdbcUrl()) + .put("db.appUsername", db.getUsername()) + .put("db.appPassword", db.getPassword()) + .put("db.inventoryUsername", db.getUsername()) + .put("db.inventoryPassword", db.getPassword()) + .put("db.changeLogParameters.defaultAdminToken", adminApiKey) + .put("db.changeLogParameters.defaultAgentToken", agentApiKey) + .put("secretStore.serverPassword", randomString(64)) + .put("secretStore.secretStoreSalt", randomString(64)) + .put("secretStore.projectSecretSalt", randomString(64)) + .build()); + + var defaultConfig = ConfigFactory.load("concord-server.conf", ConfigParseOptions.defaults(), ConfigResolveOptions.defaults().setAllowUnresolved(true)) + .getConfig("concord-server"); + + return extraConfig.withFallback(testConfig.withFallback(defaultConfig)).resolve(); + } + + private static String randomString(int minLength) { + byte[] ab = new byte[minLength]; + new SecureRandom().nextBytes(ab); + return Base64.getEncoder().encodeToString(ab); + } + + /** + * Just an example. + */ + public static void main(String[] args) throws Exception { + try (var db = new PostgreSQLContainer<>("postgres:15-alpine"); + var server = new TestingConcordServer(db, 8001, Map.of("process.watchdogPeriod", "10 seconds"), List.of())) { + db.start(); + server.start(); + System.out.printf(""" + ============================================================== + + UI: http://localhost:8001/ + DB: + JDBC URL: %s + username: %s + password: %s + + admin API key: %s + agent API key: %s + %n""", db.getJdbcUrl(), + db.getUsername(), + db.getPassword(), + server.getAdminApiKey(), + server.getAgentApiKey()); + + Thread.currentThread().join(); + } + } +} + diff --git a/it/testing-server/src/test/java/com/walmartlabs/concord/it/testingserver/TestingConcordIT.java b/it/testing-server/src/test/java/com/walmartlabs/concord/it/testingserver/TestingConcordIT.java new file mode 100644 index 0000000000..0e93548756 --- /dev/null +++ b/it/testing-server/src/test/java/com/walmartlabs/concord/it/testingserver/TestingConcordIT.java @@ -0,0 +1,109 @@ +package com.walmartlabs.concord.it.testingserver; + +/*- + * ***** + * Concord + * ----- + * Copyright (C) 2017 - 2023 Walmart 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. + * ===== + */ + +import com.walmartlabs.concord.client2.ApiClientConfiguration; +import com.walmartlabs.concord.client2.DefaultApiClientFactory; +import com.walmartlabs.concord.client2.ProcessApi; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.testcontainers.containers.PostgreSQLContainer; + +import java.io.IOException; +import java.net.ServerSocket; +import java.time.Duration; +import java.util.List; +import java.util.Map; + +import static com.walmartlabs.concord.client2.ProcessEntry.StatusEnum.FINISHED; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + +/** + * A test that tests TestingConcordServer and TestingConcordAgent can run together in the same JVM. + */ +public class TestingConcordIT { + + private PostgreSQLContainer db; + private TestingConcordServer concordServer; + private TestingConcordAgent concordAgent; + + @Before + public void setUp() throws Exception { + db = new PostgreSQLContainer<>("postgres:15-alpine"); + db.start(); + + int apiPort = getFreePort(); + concordServer = new TestingConcordServer(db, apiPort, Map.of(), List.of()); + concordServer.start(); + + concordAgent = new TestingConcordAgent(concordServer); + concordAgent.start(); + } + + @After + public void tearDown() throws Exception { + if (concordAgent != null) { + concordAgent.close(); + concordAgent = null; + } + + if (concordServer != null) { + concordServer.close(); + concordServer = null; + } + + if (db != null) { + db.close(); + db = null; + } + } + + @Test(timeout = 120_000) + public void testRunningSimpleProcess() throws Exception { + var client = new DefaultApiClientFactory(concordServer.getApiBaseUrl()) + .create(ApiClientConfiguration.builder() + .apiKey(concordServer.getAdminApiKey()) + .build()); + + var processApi = new ProcessApi(client); + var response = processApi.startProcess(Map.of("concord.yml", """ + configuration: + runtime: "concord-v2" + flows: + default: + - log: "Hello!" + """.getBytes())); + assertNotNull(response.getInstanceId()); + + var process = processApi.waitForCompletion(response.getInstanceId(), Duration.ofSeconds(60).toMillis()); + assertEquals(FINISHED, process.getStatus()); + } + + private static int getFreePort() { + try (var socket = new ServerSocket(0)) { + return socket.getLocalPort(); + } catch (IOException e) { + throw new RuntimeException(e); + } + } +} diff --git a/k8s/agent-operator/Dockerfile b/k8s/agent-operator/Dockerfile index 74095896ea..9eb567520b 100644 --- a/k8s/agent-operator/Dockerfile +++ b/k8s/agent-operator/Dockerfile @@ -1,4 +1,4 @@ -ARG from_image=gcr.io/distroless/java:8 +ARG from_image=gcr.io/distroless/java17 FROM $from_image COPY target/operator.jar /operator.jar diff --git a/k8s/agent-operator/pom.xml b/k8s/agent-operator/pom.xml index e03fd15f5e..a6a02dff01 100644 --- a/k8s/agent-operator/pom.xml +++ b/k8s/agent-operator/pom.xml @@ -6,7 +6,7 @@ com.walmartlabs.concord parent - 2.1.1-SNAPSHOT + 2.5.1-SNAPSHOT ../../pom.xml diff --git a/plugins/pom.xml b/plugins/pom.xml index 9babe8bef3..470e3f87e1 100644 --- a/plugins/pom.xml +++ b/plugins/pom.xml @@ -5,7 +5,7 @@ com.walmartlabs.concord parent - 2.1.1-SNAPSHOT + 2.5.1-SNAPSHOT ../pom.xml diff --git a/plugins/tasks/ansible/pom.xml b/plugins/tasks/ansible/pom.xml index 23c59fa270..f44699cdf4 100644 --- a/plugins/tasks/ansible/pom.xml +++ b/plugins/tasks/ansible/pom.xml @@ -5,7 +5,7 @@ com.walmartlabs.concord.plugins.basic parent - 2.1.1-SNAPSHOT + 2.5.1-SNAPSHOT ../../pom.xml diff --git a/plugins/tasks/ansible/src/main/resources/com/walmartlabs/concord/plugins/ansible/callback/concord_protectdata.py b/plugins/tasks/ansible/src/main/resources/com/walmartlabs/concord/plugins/ansible/callback/concord_protectdata.py index f68131acf9..1cf3787c60 100644 --- a/plugins/tasks/ansible/src/main/resources/com/walmartlabs/concord/plugins/ansible/callback/concord_protectdata.py +++ b/plugins/tasks/ansible/src/main/resources/com/walmartlabs/concord/plugins/ansible/callback/concord_protectdata.py @@ -2,7 +2,7 @@ __metaclass__ = type from ansible.plugins.callback.default import CallbackModule as CallbackModule_default -import collections +from collections.abc import Mapping def enc(s): # we shouldn't use `str` as the input string can contain non-ascii characters @@ -23,27 +23,35 @@ class CallbackModule(CallbackModule_default): def __init__(self): super(CallbackModule, self).__init__() + self.secret_list = ['password', 'credentials', 'secret', 'ansible_password', 'vaultpassword'] print("Log filter is enabled...") - + + def set_options(self, task_keys=None, var_options=None, direct=None): + super(CallbackModule, self).set_options(task_keys=task_keys, var_options=var_options, direct=direct) + + self.set_option('display_ok_hosts', True) + self.set_option('show_per_host_start', False) + def hide_password(self, result): ret = {} for key, value in result.items(): - if isinstance(value, collections.Mapping): + if isinstance(value, Mapping): ret[key] = self.hide_password(value) elif any (x in enc(value).lower() for x in self.secret_list) or any (y in enc(key).lower() for y in self.secret_list): ret[key] = "******" - else: + else: ret[key] = value return ret def v2_playbook_on_task_start(self, task, is_conditional): print("TASK", "[",task.get_name(),"]" , "*************************************************************************") - task_args = task._attributes.get('args') - for k, v in task_args.items(): - if any(s in enc(v).lower() for s in self.secret_list): - print("*********** THIS TASK CONTAINS SENSITIVE INFORMATION. ENABLING NO_LOG ******************") - task.no_log = True - + if hasattr(task, 'args'): + task_args = getattr(task, 'args', None) + for k, v in task_args.items(): + if any(s in enc(v).lower() for s in self.secret_list): + print("*********** THIS TASK CONTAINS SENSITIVE INFORMATION. ENABLING NO_LOG ******************") + task.no_log = True + def _dump_results(self, result, indent=None, sort_keys=True, keep_invocation=False): return super(CallbackModule, self)._dump_results(self.hide_password(result), indent, sort_keys, keep_invocation) diff --git a/plugins/tasks/ansible/src/main/resources/com/walmartlabs/concord/plugins/ansible/lib/task_policy.py b/plugins/tasks/ansible/src/main/resources/com/walmartlabs/concord/plugins/ansible/lib/task_policy.py index 863ae7f254..3bd957898e 100644 --- a/plugins/tasks/ansible/src/main/resources/com/walmartlabs/concord/plugins/ansible/lib/task_policy.py +++ b/plugins/tasks/ansible/src/main/resources/com/walmartlabs/concord/plugins/ansible/lib/task_policy.py @@ -36,7 +36,13 @@ def is_deny(self, task): ansible_rules = self.policy_rules['ansible'] action = task.action - args = self._enrich_args(action, task._attributes.get('args')) + + if not hasattr(task, 'args'): + return False + + task_args = getattr(task, 'args', None) + + args = self._enrich_args(action, task_args) if 'allow' in ansible_rules: for r in ansible_rules['allow']: diff --git a/plugins/tasks/concord/pom.xml b/plugins/tasks/concord/pom.xml index b45109c03a..550db22cbf 100644 --- a/plugins/tasks/concord/pom.xml +++ b/plugins/tasks/concord/pom.xml @@ -6,7 +6,7 @@ com.walmartlabs.concord.plugins.basic parent - 2.1.1-SNAPSHOT + 2.5.1-SNAPSHOT ../../pom.xml diff --git a/plugins/tasks/crypto/pom.xml b/plugins/tasks/crypto/pom.xml index d2632dfc03..b044413f22 100644 --- a/plugins/tasks/crypto/pom.xml +++ b/plugins/tasks/crypto/pom.xml @@ -5,7 +5,7 @@ com.walmartlabs.concord.plugins.basic parent - 2.1.1-SNAPSHOT + 2.5.1-SNAPSHOT ../../pom.xml diff --git a/plugins/tasks/docker/pom.xml b/plugins/tasks/docker/pom.xml index a93215cb48..7435f2d02e 100644 --- a/plugins/tasks/docker/pom.xml +++ b/plugins/tasks/docker/pom.xml @@ -5,7 +5,7 @@ com.walmartlabs.concord.plugins.basic parent - 2.1.1-SNAPSHOT + 2.5.1-SNAPSHOT ../../pom.xml diff --git a/plugins/tasks/dynamic-tasks/pom.xml b/plugins/tasks/dynamic-tasks/pom.xml index 81b99350b6..994d456989 100644 --- a/plugins/tasks/dynamic-tasks/pom.xml +++ b/plugins/tasks/dynamic-tasks/pom.xml @@ -5,7 +5,7 @@ com.walmartlabs.concord.plugins.basic parent - 2.1.1-SNAPSHOT + 2.5.1-SNAPSHOT ../../pom.xml diff --git a/plugins/tasks/example/pom.xml b/plugins/tasks/example/pom.xml index 0b14ddaaf2..7bcd2b5a8c 100644 --- a/plugins/tasks/example/pom.xml +++ b/plugins/tasks/example/pom.xml @@ -5,7 +5,7 @@ com.walmartlabs.concord.plugins.basic parent - 2.1.1-SNAPSHOT + 2.5.1-SNAPSHOT ../../pom.xml diff --git a/plugins/tasks/files/pom.xml b/plugins/tasks/files/pom.xml index 2c22a6b6d3..3c67d094d3 100644 --- a/plugins/tasks/files/pom.xml +++ b/plugins/tasks/files/pom.xml @@ -5,7 +5,7 @@ com.walmartlabs.concord.plugins.basic parent - 2.1.1-SNAPSHOT + 2.5.1-SNAPSHOT ../../pom.xml diff --git a/plugins/tasks/http/pom.xml b/plugins/tasks/http/pom.xml index 675ccad56e..e7bbd95a5f 100644 --- a/plugins/tasks/http/pom.xml +++ b/plugins/tasks/http/pom.xml @@ -5,7 +5,7 @@ com.walmartlabs.concord.plugins.basic parent - 2.1.1-SNAPSHOT + 2.5.1-SNAPSHOT ../../pom.xml diff --git a/plugins/tasks/kv/pom.xml b/plugins/tasks/kv/pom.xml index 39005eced9..1d42d040c9 100644 --- a/plugins/tasks/kv/pom.xml +++ b/plugins/tasks/kv/pom.xml @@ -5,7 +5,7 @@ com.walmartlabs.concord.plugins.basic parent - 2.1.1-SNAPSHOT + 2.5.1-SNAPSHOT ../../pom.xml diff --git a/plugins/tasks/locale/pom.xml b/plugins/tasks/locale/pom.xml index aff649a2f6..1300860e10 100644 --- a/plugins/tasks/locale/pom.xml +++ b/plugins/tasks/locale/pom.xml @@ -5,7 +5,7 @@ com.walmartlabs.concord.plugins.basic parent - 2.1.1-SNAPSHOT + 2.5.1-SNAPSHOT ../../pom.xml diff --git a/plugins/tasks/lock/pom.xml b/plugins/tasks/lock/pom.xml index 1901af9140..3384ab3850 100644 --- a/plugins/tasks/lock/pom.xml +++ b/plugins/tasks/lock/pom.xml @@ -5,7 +5,7 @@ com.walmartlabs.concord.plugins.basic parent - 2.1.1-SNAPSHOT + 2.5.1-SNAPSHOT ../../pom.xml diff --git a/plugins/tasks/log/pom.xml b/plugins/tasks/log/pom.xml index 89ab126290..38f87bce0d 100644 --- a/plugins/tasks/log/pom.xml +++ b/plugins/tasks/log/pom.xml @@ -5,7 +5,7 @@ com.walmartlabs.concord.plugins.basic parent - 2.1.1-SNAPSHOT + 2.5.1-SNAPSHOT ../../pom.xml diff --git a/plugins/tasks/misc/pom.xml b/plugins/tasks/misc/pom.xml index 4ab16563d2..94d102f021 100644 --- a/plugins/tasks/misc/pom.xml +++ b/plugins/tasks/misc/pom.xml @@ -5,7 +5,7 @@ com.walmartlabs.concord.plugins.basic parent - 2.1.1-SNAPSHOT + 2.5.1-SNAPSHOT ../../pom.xml diff --git a/plugins/tasks/noderoster/pom.xml b/plugins/tasks/noderoster/pom.xml index 33107a3a71..d2d04cdc31 100644 --- a/plugins/tasks/noderoster/pom.xml +++ b/plugins/tasks/noderoster/pom.xml @@ -6,7 +6,7 @@ com.walmartlabs.concord.plugins.basic parent - 2.1.1-SNAPSHOT + 2.5.1-SNAPSHOT ../../pom.xml diff --git a/plugins/tasks/resource/pom.xml b/plugins/tasks/resource/pom.xml index 442e02b5b2..935389b2ba 100644 --- a/plugins/tasks/resource/pom.xml +++ b/plugins/tasks/resource/pom.xml @@ -5,7 +5,7 @@ com.walmartlabs.concord.plugins.basic parent - 2.1.1-SNAPSHOT + 2.5.1-SNAPSHOT ../../pom.xml diff --git a/plugins/tasks/slack/pom.xml b/plugins/tasks/slack/pom.xml index 071c27a3b5..aa7abc7a80 100644 --- a/plugins/tasks/slack/pom.xml +++ b/plugins/tasks/slack/pom.xml @@ -5,7 +5,7 @@ com.walmartlabs.concord.plugins.basic parent - 2.1.1-SNAPSHOT + 2.5.1-SNAPSHOT ../../pom.xml diff --git a/plugins/tasks/sleep/pom.xml b/plugins/tasks/sleep/pom.xml index e1bf2fd684..0cfa9b7652 100644 --- a/plugins/tasks/sleep/pom.xml +++ b/plugins/tasks/sleep/pom.xml @@ -5,7 +5,7 @@ com.walmartlabs.concord.plugins.basic parent - 2.1.1-SNAPSHOT + 2.5.1-SNAPSHOT ../../pom.xml diff --git a/plugins/tasks/smtp/pom.xml b/plugins/tasks/smtp/pom.xml index ca5bd1131d..827e74e4fb 100644 --- a/plugins/tasks/smtp/pom.xml +++ b/plugins/tasks/smtp/pom.xml @@ -5,7 +5,7 @@ com.walmartlabs.concord.plugins.basic parent - 2.1.1-SNAPSHOT + 2.5.1-SNAPSHOT ../../pom.xml diff --git a/plugins/tasks/throw/pom.xml b/plugins/tasks/throw/pom.xml index 907db95b47..bcca2f35ec 100644 --- a/plugins/tasks/throw/pom.xml +++ b/plugins/tasks/throw/pom.xml @@ -5,7 +5,7 @@ com.walmartlabs.concord.plugins.basic parent - 2.1.1-SNAPSHOT + 2.5.1-SNAPSHOT ../../pom.xml diff --git a/plugins/tasks/variables/pom.xml b/plugins/tasks/variables/pom.xml index a585ca4673..9e0495d862 100644 --- a/plugins/tasks/variables/pom.xml +++ b/plugins/tasks/variables/pom.xml @@ -5,7 +5,7 @@ com.walmartlabs.concord.plugins.basic parent - 2.1.1-SNAPSHOT + 2.5.1-SNAPSHOT ../../pom.xml diff --git a/plugins/templates/ansible/pom.xml b/plugins/templates/ansible/pom.xml index 2205dc28fb..84c9257285 100644 --- a/plugins/templates/ansible/pom.xml +++ b/plugins/templates/ansible/pom.xml @@ -5,7 +5,7 @@ com.walmartlabs.concord.plugins.basic parent - 2.1.1-SNAPSHOT + 2.5.1-SNAPSHOT ../../pom.xml diff --git a/policy-engine/pom.xml b/policy-engine/pom.xml index acfae4c163..c03b3eec84 100644 --- a/policy-engine/pom.xml +++ b/policy-engine/pom.xml @@ -6,7 +6,7 @@ com.walmartlabs.concord parent - 2.1.1-SNAPSHOT + 2.5.1-SNAPSHOT ../pom.xml diff --git a/pom.xml b/pom.xml index e37a78b86d..f4e0b21669 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ com.walmartlabs.concord parent - 2.1.1-SNAPSHOT + 2.5.1-SNAPSHOT pom ${project.groupId}:${project.artifactId} @@ -60,8 +60,9 @@ - 1.8 - 1.8 + 17 + ${maven.compiler.release + ${maven.compiler.release} UTF-8 UTF-8 @@ -73,7 +74,6 @@ 5.8.2 3.5.1 - 3.1.2 16.13.1 1.12.0 @@ -107,10 +107,6 @@ maven-compiler-plugin 3.11.0 - - ${maven.compiler.source} - ${maven.compiler.target} - @@ -147,10 +143,9 @@ org.apache.maven.plugins maven-checkstyle-plugin - 3.1.1 + 3.2.1 checkstyle.xml - UTF-8 true true false @@ -296,6 +291,9 @@ + + true + org.apache.maven.plugins @@ -414,24 +412,12 @@ org.apache.maven.plugins maven-dependency-plugin - ${maven.dependency.plugin.version} + 3.1.2 org.apache.maven.plugins maven-javadoc-plugin 3.2.0 - - - attach-javadocs - - jar - - - - - true - none - @@ -467,6 +453,37 @@ false + + org.apache.maven.plugins + maven-javadoc-plugin + + + attach-javadocs + + jar + + + + + true + none + + + + org.apache.maven.plugins + maven-source-plugin + + + attach-sources + + jar-no-fork + + + + + false + + diff --git a/repository/pom.xml b/repository/pom.xml index 70939ee58a..e4d0b7c4de 100644 --- a/repository/pom.xml +++ b/repository/pom.xml @@ -6,7 +6,7 @@ com.walmartlabs.concord parent - 2.1.1-SNAPSHOT + 2.5.1-SNAPSHOT ../pom.xml diff --git a/runtime/common/pom.xml b/runtime/common/pom.xml index ea7f3e8754..1b17daceb2 100644 --- a/runtime/common/pom.xml +++ b/runtime/common/pom.xml @@ -6,7 +6,7 @@ com.walmartlabs.concord parent - 2.1.1-SNAPSHOT + 2.5.1-SNAPSHOT ../../pom.xml diff --git a/runtime/loader/pom.xml b/runtime/loader/pom.xml index b96696874c..724c7a5b02 100644 --- a/runtime/loader/pom.xml +++ b/runtime/loader/pom.xml @@ -6,7 +6,7 @@ com.walmartlabs.concord parent - 2.1.1-SNAPSHOT + 2.5.1-SNAPSHOT ../../pom.xml diff --git a/runtime/v1/impl/pom.xml b/runtime/v1/impl/pom.xml index 0384f0ed4f..8e2fb71505 100644 --- a/runtime/v1/impl/pom.xml +++ b/runtime/v1/impl/pom.xml @@ -6,7 +6,7 @@ com.walmartlabs.concord.runtime.v1 parent - 2.1.1-SNAPSHOT + 2.5.1-SNAPSHOT ../pom.xml diff --git a/runtime/v1/pom.xml b/runtime/v1/pom.xml index 29fe557fc9..f232638480 100644 --- a/runtime/v1/pom.xml +++ b/runtime/v1/pom.xml @@ -6,7 +6,7 @@ com.walmartlabs.concord parent - 2.1.1-SNAPSHOT + 2.5.1-SNAPSHOT ../../pom.xml diff --git a/runtime/v1/project-model/pom.xml b/runtime/v1/project-model/pom.xml index f066f72d90..bc6cd147e4 100644 --- a/runtime/v1/project-model/pom.xml +++ b/runtime/v1/project-model/pom.xml @@ -6,7 +6,7 @@ com.walmartlabs.concord.runtime.v1 parent - 2.1.1-SNAPSHOT + 2.5.1-SNAPSHOT ../pom.xml diff --git a/runtime/v2/model/pom.xml b/runtime/v2/model/pom.xml index 038153c8d0..0363203796 100644 --- a/runtime/v2/model/pom.xml +++ b/runtime/v2/model/pom.xml @@ -6,7 +6,7 @@ com.walmartlabs.concord.runtime.v2 parent - 2.1.1-SNAPSHOT + 2.5.1-SNAPSHOT ../pom.xml diff --git a/runtime/v2/pom.xml b/runtime/v2/pom.xml index ebb7fbcb82..1f6a5816c9 100644 --- a/runtime/v2/pom.xml +++ b/runtime/v2/pom.xml @@ -6,7 +6,7 @@ com.walmartlabs.concord parent - 2.1.1-SNAPSHOT + 2.5.1-SNAPSHOT ../../pom.xml diff --git a/runtime/v2/runner/pom.xml b/runtime/v2/runner/pom.xml index b7c2586c18..ede9d4b001 100644 --- a/runtime/v2/runner/pom.xml +++ b/runtime/v2/runner/pom.xml @@ -6,7 +6,7 @@ com.walmartlabs.concord.runtime.v2 parent - 2.1.1-SNAPSHOT + 2.5.1-SNAPSHOT ../pom.xml diff --git a/runtime/v2/runner/src/main/java/com/walmartlabs/concord/runtime/v2/runner/DefaultSynchronizationService.java b/runtime/v2/runner/src/main/java/com/walmartlabs/concord/runtime/v2/runner/DefaultSynchronizationService.java index e327d93c11..2c1d8950fd 100644 --- a/runtime/v2/runner/src/main/java/com/walmartlabs/concord/runtime/v2/runner/DefaultSynchronizationService.java +++ b/runtime/v2/runner/src/main/java/com/walmartlabs/concord/runtime/v2/runner/DefaultSynchronizationService.java @@ -29,6 +29,8 @@ public class DefaultSynchronizationService implements SynchronizationService { private final List callbacks = new ArrayList<>(); + private boolean stop; + @Override public boolean hasPoint() { synchronized (this) { @@ -43,6 +45,7 @@ public void maintain() { } callbacks.clear(); + stop = false; } @Override @@ -51,4 +54,14 @@ public void point(Runnable callback) { callbacks.add(callback); } } + + @Override + public void stop() { + this.stop = true; + } + + @Override + public boolean hasStop() { + return stop; + } } diff --git a/runtime/v2/runner/src/main/java/com/walmartlabs/concord/runtime/v2/runner/SynchronizationService.java b/runtime/v2/runner/src/main/java/com/walmartlabs/concord/runtime/v2/runner/SynchronizationService.java index 5975964abf..fea6b9149e 100644 --- a/runtime/v2/runner/src/main/java/com/walmartlabs/concord/runtime/v2/runner/SynchronizationService.java +++ b/runtime/v2/runner/src/main/java/com/walmartlabs/concord/runtime/v2/runner/SynchronizationService.java @@ -27,4 +27,8 @@ public interface SynchronizationService { void maintain(); void point(Runnable callback); + + void stop(); + + boolean hasStop(); } diff --git a/runtime/v2/runner/src/main/java/com/walmartlabs/concord/runtime/v2/runner/SynchronizationServiceListener.java b/runtime/v2/runner/src/main/java/com/walmartlabs/concord/runtime/v2/runner/SynchronizationServiceListener.java index 87559c366d..c8f551abaf 100644 --- a/runtime/v2/runner/src/main/java/com/walmartlabs/concord/runtime/v2/runner/SynchronizationServiceListener.java +++ b/runtime/v2/runner/src/main/java/com/walmartlabs/concord/runtime/v2/runner/SynchronizationServiceListener.java @@ -23,6 +23,8 @@ import com.walmartlabs.concord.svm.Runtime; import com.walmartlabs.concord.svm.*; +import java.util.Map; + public class SynchronizationServiceListener implements ExecutionListener { private final SynchronizationService delegate; @@ -33,7 +35,7 @@ public SynchronizationServiceListener(SynchronizationService delegate) { @Override public Result afterCommand(Runtime runtime, VM vm, State state, ThreadId threadId, Command cmd) { - if (delegate.hasPoint()) { + if (delegate.hasPoint() || delegate.hasStop()) { state.setStatus(threadId, ThreadStatus.SUSPENDED); return Result.BREAK; } @@ -43,6 +45,13 @@ public Result afterCommand(Runtime runtime, VM vm, State state, ThreadId threadI @Override public Result afterEval(Runtime runtime, VM vm, State state) { + if (delegate.hasStop()) { + for (Map.Entry e : state.threadStatus().entrySet()) { + state.setStatus(e.getKey(), ThreadStatus.DONE); + } + return Result.BREAK; + } + if (!delegate.hasPoint()) { return Result.BREAK; } diff --git a/runtime/v2/runner/src/main/java/com/walmartlabs/concord/runtime/v2/runner/tasks/TaskCallInterceptor.java b/runtime/v2/runner/src/main/java/com/walmartlabs/concord/runtime/v2/runner/tasks/TaskCallInterceptor.java index 774dc4948a..1bedb43928 100644 --- a/runtime/v2/runner/src/main/java/com/walmartlabs/concord/runtime/v2/runner/tasks/TaskCallInterceptor.java +++ b/runtime/v2/runner/src/main/java/com/walmartlabs/concord/runtime/v2/runner/tasks/TaskCallInterceptor.java @@ -124,7 +124,7 @@ default List> annotations() { static Method of(Object base, String methodName, List params) { List> annotations = Collections.emptyList(); java.lang.reflect.Method m = ReflectionUtil.findMethod(base.getClass(), methodName, null, params.toArray()); - if (m != null) { + if (m != null && !m.isVarArgs()) { annotations = Arrays.stream(m.getParameterAnnotations()) .map(Arrays::asList) .collect(Collectors.toList()); diff --git a/runtime/v2/runner/src/main/java/com/walmartlabs/concord/runtime/v2/runner/vm/ExitCommand.java b/runtime/v2/runner/src/main/java/com/walmartlabs/concord/runtime/v2/runner/vm/ExitCommand.java index ee5722cb40..2739224fde 100644 --- a/runtime/v2/runner/src/main/java/com/walmartlabs/concord/runtime/v2/runner/vm/ExitCommand.java +++ b/runtime/v2/runner/src/main/java/com/walmartlabs/concord/runtime/v2/runner/vm/ExitCommand.java @@ -21,6 +21,7 @@ */ import com.walmartlabs.concord.runtime.v2.model.ExitStep; +import com.walmartlabs.concord.runtime.v2.runner.SynchronizationService; import com.walmartlabs.concord.svm.Runtime; import com.walmartlabs.concord.svm.State; import com.walmartlabs.concord.svm.ThreadId; @@ -35,6 +36,6 @@ public ExitCommand(ExitStep step) { @Override protected void execute(Runtime runtime, State state, ThreadId threadId) { - state.dropAllFrames(); + runtime.getService(SynchronizationService.class).stop(); } } diff --git a/runtime/v2/runner/src/main/java/com/walmartlabs/concord/runtime/v2/runner/vm/IfCommand.java b/runtime/v2/runner/src/main/java/com/walmartlabs/concord/runtime/v2/runner/vm/IfCommand.java index f1bf016034..ab24f826bc 100644 --- a/runtime/v2/runner/src/main/java/com/walmartlabs/concord/runtime/v2/runner/vm/IfCommand.java +++ b/runtime/v2/runner/src/main/java/com/walmartlabs/concord/runtime/v2/runner/vm/IfCommand.java @@ -54,11 +54,29 @@ protected void execute(Runtime runtime, State state, ThreadId threadId) { EvalContext evalContext = ecf.global(ctx); ExpressionEvaluator ee = runtime.getService(ExpressionEvaluator.class); - Boolean ifResult = ee.eval(evalContext, expr, Boolean.class); - if (ifResult != null && ifResult) { + Object ifResult = ee.eval(evalContext, expr, Object.class); + if (isTrue(ifResult)) { frame.push(thenCommand); } else if (elseCommand != null) { frame.push(elseCommand); } } + + private static boolean isTrue(Object value) { + if (value == null) { + return false; + } + + if (value instanceof Boolean b) { + return b; + } else if (value instanceof String s) { + if ("true".equalsIgnoreCase(s)) { + return true; + } else if ("false".equalsIgnoreCase(s)) { + return false; + } + } + + throw new RuntimeException(String.format("Expected boolean value or string 'true'/'false', got: '%s', type: %s", value, value.getClass())); + } } diff --git a/runtime/v2/runner/src/test/java/com/walmartlabs/concord/runtime/v2/runner/MainTest.java b/runtime/v2/runner/src/test/java/com/walmartlabs/concord/runtime/v2/runner/MainTest.java index 1880b9b580..40d758066c 100644 --- a/runtime/v2/runner/src/test/java/com/walmartlabs/concord/runtime/v2/runner/MainTest.java +++ b/runtime/v2/runner/src/test/java/com/walmartlabs/concord/runtime/v2/runner/MainTest.java @@ -1577,6 +1577,50 @@ public void testUuidFunc() throws Exception { assertLog(log, ".*uuid: [0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}.*"); } + @Test + public void testExitFromParallelLoop() throws Exception { + deploy("parallelLoopExit"); + + save(ProcessConfiguration.builder() + .build()); + + byte[] log = run(); + + assertNoLog(log, ".*should not reach here.*"); + } + + @Test + public void testExitFromSerialLoop() throws Exception { + deploy("serialLoopExit"); + + save(ProcessConfiguration.builder() + .build()); + + byte[] log = run(); + + assertNoLog(log, ".*should not reach here.*"); + + assertLog(log, ".*inner start: one.*"); + assertLog(log, ".*inner end: one.*"); + assertLog(log, ".*inner start: two.*"); + + assertNoLog(log, ".*inner end: two.*"); + assertNoLog(log, ".*inner start: three.*"); + assertNoLog(log, ".*inner start: four.*"); + } + + @Test + public void testStringIfExpression() throws Exception { + deploy("ifExpressionAsString"); + + save(ProcessConfiguration.builder() + .putArguments("myVar", Collections.singletonMap("str", "true")) + .build()); + + byte[] log = run(); + assertLog(log, ".*it's true.*"); + } + private void deploy(String resource) throws URISyntaxException, IOException { Path src = Paths.get(MainTest.class.getResource(resource).toURI()); IOUtils.copy(src, workDir); diff --git a/runtime/v2/runner/src/test/java/com/walmartlabs/concord/runtime/v2/runner/tasks/TaskCallInterceptorTest.java b/runtime/v2/runner/src/test/java/com/walmartlabs/concord/runtime/v2/runner/tasks/TaskCallInterceptorTest.java new file mode 100644 index 0000000000..4772fac1b5 --- /dev/null +++ b/runtime/v2/runner/src/test/java/com/walmartlabs/concord/runtime/v2/runner/tasks/TaskCallInterceptorTest.java @@ -0,0 +1,29 @@ +package com.walmartlabs.concord.runtime.v2.runner.tasks; + +import org.junit.Test; + +import java.util.Arrays; +import java.util.List; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +public class TaskCallInterceptorTest { + + @Test + public void methodAnnotationsTest() { + Base base = new Base(); + String method = "varargs"; + List params = Arrays.asList("one", "two"); + + TaskCallInterceptor.Method m = TaskCallInterceptor.Method.of(base, method, params); + + assertEquals(0, m.annotations().size()); + } + + public static class Base { + + public void varargs(Object ... args) { + + } + } +} diff --git a/runtime/v2/runner/src/test/resources/com/walmartlabs/concord/runtime/v2/runner/ifExpressionAsString/concord.yml b/runtime/v2/runner/src/test/resources/com/walmartlabs/concord/runtime/v2/runner/ifExpressionAsString/concord.yml new file mode 100644 index 0000000000..d238803d9c --- /dev/null +++ b/runtime/v2/runner/src/test/resources/com/walmartlabs/concord/runtime/v2/runner/ifExpressionAsString/concord.yml @@ -0,0 +1,7 @@ +flows: + default: + - if: "${myVar.str}" + then: + - log: "it's true" + else: + - log: "it's not true" diff --git a/runtime/v2/runner/src/test/resources/com/walmartlabs/concord/runtime/v2/runner/parallelLoopExit/concord.yml b/runtime/v2/runner/src/test/resources/com/walmartlabs/concord/runtime/v2/runner/parallelLoopExit/concord.yml new file mode 100644 index 0000000000..51ca7005f8 --- /dev/null +++ b/runtime/v2/runner/src/test/resources/com/walmartlabs/concord/runtime/v2/runner/parallelLoopExit/concord.yml @@ -0,0 +1,33 @@ +configuration: + debug: true + runtime: concord-v2 + +flows: + default: + - call: "inner" + loop: + items: + - "one" + - "two" + - "three" + - "four" + mode: parallel + + - log: "should not reach here" + + inner: + - log: "inner start: ${item}" + + - if: ${item == "four"} + then: + - checkpoint: "${item}" + + - if: ${item == "two"} + then: + - exit + + - if: ${item == "three"} + then: + - expr: ${sleep.ms(1000)} + + - log: "inner end: ${item}" diff --git a/runtime/v2/runner/src/test/resources/com/walmartlabs/concord/runtime/v2/runner/serialLoopExit/concord.yml b/runtime/v2/runner/src/test/resources/com/walmartlabs/concord/runtime/v2/runner/serialLoopExit/concord.yml new file mode 100644 index 0000000000..06d97138e5 --- /dev/null +++ b/runtime/v2/runner/src/test/resources/com/walmartlabs/concord/runtime/v2/runner/serialLoopExit/concord.yml @@ -0,0 +1,32 @@ +configuration: + debug: true + runtime: concord-v2 + +flows: + default: + - call: "inner" + loop: + items: + - "one" + - "two" + - "three" + - "four" + + - log: "should not reach here" + + inner: + - log: "inner start: ${item}" + + - if: ${item == "four"} + then: + - checkpoint: "${item}" + + - if: ${item == "two"} + then: + - exit + + - if: ${item == "three"} + then: + - expr: ${sleep.ms(1000)} + + - log: "inner end: ${item}" diff --git a/runtime/v2/sdk/pom.xml b/runtime/v2/sdk/pom.xml index e92f73ceee..a8b91480c9 100644 --- a/runtime/v2/sdk/pom.xml +++ b/runtime/v2/sdk/pom.xml @@ -6,7 +6,7 @@ com.walmartlabs.concord.runtime.v2 parent - 2.1.1-SNAPSHOT + 2.5.1-SNAPSHOT ../pom.xml diff --git a/runtime/v2/vm/pom.xml b/runtime/v2/vm/pom.xml index 9bd12d2e5d..01267249db 100644 --- a/runtime/v2/vm/pom.xml +++ b/runtime/v2/vm/pom.xml @@ -6,7 +6,7 @@ com.walmartlabs.concord.runtime.v2 parent - 2.1.1-SNAPSHOT + 2.5.1-SNAPSHOT ../pom.xml diff --git a/sdk/pom.xml b/sdk/pom.xml index 54fcfe3f68..1c7b348845 100644 --- a/sdk/pom.xml +++ b/sdk/pom.xml @@ -6,7 +6,7 @@ com.walmartlabs.concord parent - 2.1.1-SNAPSHOT + 2.5.1-SNAPSHOT ../pom.xml diff --git a/server/db/pom.xml b/server/db/pom.xml index 73218f9f0c..225c83c579 100644 --- a/server/db/pom.xml +++ b/server/db/pom.xml @@ -6,7 +6,7 @@ com.walmartlabs.concord.server parent - 2.1.1-SNAPSHOT + 2.5.1-SNAPSHOT ../pom.xml diff --git a/server/dist/pom.xml b/server/dist/pom.xml index d7819e134d..7fa30974ff 100644 --- a/server/dist/pom.xml +++ b/server/dist/pom.xml @@ -6,7 +6,7 @@ com.walmartlabs.concord.server parent - 2.1.1-SNAPSHOT + 2.5.1-SNAPSHOT ../pom.xml diff --git a/server/dist/src/assembly/start.sh b/server/dist/src/assembly/start.sh index 46ce235dcd..f62e44951d 100755 --- a/server/dist/src/assembly/start.sh +++ b/server/dist/src/assembly/start.sh @@ -40,6 +40,12 @@ if (( $JAVA_VERSION > 8 )); then JDK_SPECIFIC_OPTS="--add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED" fi +if [[ -z "${EXTRA_CLASSPATH}" ]]; then + EXTRA_CLASSPATH="" +fi + +echo "EXTRA_CLASSPATH: ${EXTRA_CLASSPATH}" + exec java \ ${CONCORD_JAVA_OPTS} \ ${JDK_SPECIFIC_OPTS} \ @@ -47,5 +53,5 @@ ${JDK_SPECIFIC_OPTS} \ -Djava.net.preferIPv4Stack=true \ -Djava.security.egd=file:/dev/./urandom \ -Dollie.conf=${CONCORD_CFG_FILE} \ --cp "${BASE_DIR}/lib/*:${BASE_DIR}/ext/*:${BASE_DIR}/classes" \ +-cp "${BASE_DIR}/lib/*:${BASE_DIR}/ext/*:${BASE_DIR}/classes:${EXTRA_CLASSPATH}" \ "${MAIN_CLASS}" diff --git a/server/dist/src/main/java/com/walmartlabs/concord/server/dist/Main.java b/server/dist/src/main/java/com/walmartlabs/concord/server/dist/Main.java index 38627a69e4..d3cdd93996 100644 --- a/server/dist/src/main/java/com/walmartlabs/concord/server/dist/Main.java +++ b/server/dist/src/main/java/com/walmartlabs/concord/server/dist/Main.java @@ -22,6 +22,10 @@ import com.walmartlabs.concord.server.ConcordServer; import com.walmartlabs.concord.server.Version; +import org.eclipse.sisu.space.BeanScanning; +import org.eclipse.sisu.space.SpaceModule; +import org.eclipse.sisu.space.URLClassSpace; +import org.eclipse.sisu.wire.WireModule; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.slf4j.bridge.SLF4JBridgeHandler; @@ -38,10 +42,15 @@ public static void main(String[] args) throws Exception { long t1 = System.currentTimeMillis(); - ConcordServer.withAutoWiring() - .start(); + autoWire().start(); long t2 = System.currentTimeMillis(); log.info("main -> started in {}ms", (t2 - t1)); } + + public static ConcordServer autoWire() throws Exception { + // works as a plugin system by automatically wiring all @Named modules and beans in the classpath + ClassLoader cl = ConcordServer.class.getClassLoader(); + return ConcordServer.withModules(new WireModule(new SpaceModule(new URLClassSpace(cl), BeanScanning.GLOBAL_INDEX))); + } } diff --git a/server/impl/pom.xml b/server/impl/pom.xml index 2b82c384ac..71ee58d537 100644 --- a/server/impl/pom.xml +++ b/server/impl/pom.xml @@ -6,7 +6,7 @@ com.walmartlabs.concord.server parent - 2.1.1-SNAPSHOT + 2.5.1-SNAPSHOT ../pom.xml diff --git a/server/impl/src/main/java/com/walmartlabs/concord/server/ApiServerModule.java b/server/impl/src/main/java/com/walmartlabs/concord/server/ApiServerModule.java index d0f13ab6ae..27566614eb 100644 --- a/server/impl/src/main/java/com/walmartlabs/concord/server/ApiServerModule.java +++ b/server/impl/src/main/java/com/walmartlabs/concord/server/ApiServerModule.java @@ -20,8 +20,11 @@ * ===== */ +import com.fasterxml.jackson.databind.ObjectMapper; import com.google.inject.Binder; import com.google.inject.Module; +import com.google.inject.name.Names; +import com.walmartlabs.concord.common.ObjectMapperProvider; import com.walmartlabs.concord.server.boot.*; import com.walmartlabs.concord.server.boot.filters.*; import com.walmartlabs.concord.server.boot.servlets.FormServletHolder; @@ -31,6 +34,8 @@ import org.apache.shiro.mgt.SecurityManager; import org.apache.shiro.web.mgt.WebSecurityManager; import org.eclipse.jetty.servlet.FilterHolder; +import org.sonatype.siesta.Component; +import org.sonatype.siesta.jackson2.ObjectMapperResolver; import javax.servlet.ServletContextListener; import javax.servlet.http.HttpServlet; @@ -44,7 +49,14 @@ public class ApiServerModule implements Module { @Override public void configure(Binder binder) { + // Jackson + + binder.bind(ObjectMapper.class).toProvider(ObjectMapperProvider.class).in(SINGLETON); + binder.bind(ObjectMapper.class).annotatedWith(Names.named("siesta")).toProvider(ObjectMapperProvider.class).in(SINGLETON); + newSetBinder(binder, Component.class).addBinding().to(ObjectMapperResolver.class); + // Jetty + binder.bind(HttpServer.class).in(SINGLETON); // Filter diff --git a/server/impl/src/main/java/com/walmartlabs/concord/server/ConcordServer.java b/server/impl/src/main/java/com/walmartlabs/concord/server/ConcordServer.java index d4f06884a6..bbf0f63547 100644 --- a/server/impl/src/main/java/com/walmartlabs/concord/server/ConcordServer.java +++ b/server/impl/src/main/java/com/walmartlabs/concord/server/ConcordServer.java @@ -25,14 +25,12 @@ import com.google.inject.Module; import com.walmartlabs.concord.server.boot.BackgroundTasks; import com.walmartlabs.concord.server.boot.HttpServer; -import org.eclipse.sisu.space.BeanScanning; -import org.eclipse.sisu.space.SpaceModule; -import org.eclipse.sisu.space.URLClassSpace; -import org.eclipse.sisu.wire.WireModule; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.inject.Inject; +import java.util.Collection; +import java.util.List; public final class ConcordServer { @@ -49,19 +47,14 @@ public final class ConcordServer { private final Object controlMutex = new Object(); - /** - * Start ConcordServer by scanning the local class path for the implementations of - * {@link HttpServer} or {@link BackgroundTasks}. - */ - public static ConcordServer withAutoWiring() throws Exception { - ClassLoader cl = ConcordServer.class.getClassLoader(); - return withModules(new WireModule(new SpaceModule(new URLClassSpace(cl), BeanScanning.GLOBAL_INDEX))); + public static ConcordServer withModules(Module... modules) throws Exception { + return withModules(List.of(modules)); } /** * Start ConcordServer using the provided modules. */ - public static ConcordServer withModules(Module... modules) throws Exception { + public static ConcordServer withModules(Collection modules) throws Exception { Injector injector = Guice.createInjector(modules); ConcordServer instance = new ConcordServer(); diff --git a/server/impl/src/main/java/com/walmartlabs/concord/server/ConcordServerModule.java b/server/impl/src/main/java/com/walmartlabs/concord/server/ConcordServerModule.java index 6bbeeb0cda..14314e1d0a 100644 --- a/server/impl/src/main/java/com/walmartlabs/concord/server/ConcordServerModule.java +++ b/server/impl/src/main/java/com/walmartlabs/concord/server/ConcordServerModule.java @@ -11,7 +11,7 @@ * 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. @@ -22,22 +22,30 @@ import com.google.inject.Binder; import com.google.inject.Module; +import com.typesafe.config.Config; import com.walmartlabs.concord.db.DatabaseModule; +import com.walmartlabs.concord.dependencymanager.DependencyManagerConfiguration; import com.walmartlabs.concord.server.agent.AgentModule; import com.walmartlabs.concord.server.audit.AuditLogModule; import com.walmartlabs.concord.server.boot.BackgroundTasks; import com.walmartlabs.concord.server.cfg.ConfigurationModule; import com.walmartlabs.concord.server.cfg.DatabaseConfigurationModule; import com.walmartlabs.concord.server.console.ConsoleModule; +import com.walmartlabs.concord.server.events.EventModule; import com.walmartlabs.concord.server.metrics.MetricModule; +import com.walmartlabs.concord.server.org.secret.SecretModule; import com.walmartlabs.concord.server.org.triggers.TriggersModule; import com.walmartlabs.concord.server.policy.PolicyModule; import com.walmartlabs.concord.server.process.ProcessModule; import com.walmartlabs.concord.server.repository.RepositoryModule; import com.walmartlabs.concord.server.role.RoleModule; +import com.walmartlabs.concord.server.security.SecurityModule; import com.walmartlabs.concord.server.security.apikey.ApiKeyModule; import com.walmartlabs.concord.server.task.TaskSchedulerModule; import com.walmartlabs.concord.server.template.TemplateModule; +import com.walmartlabs.ollie.config.ConfigurationProcessor; +import com.walmartlabs.ollie.config.Environment; +import com.walmartlabs.ollie.config.EnvironmentSelector; import javax.inject.Named; @@ -50,9 +58,19 @@ @Named public class ConcordServerModule implements Module { + private final Config config; + + public ConcordServerModule() { + this(loadDefaultConfig()); + } + + public ConcordServerModule(Config config) { + this.config = config; + } + @Override public void configure(Binder binder) { - binder.install(new ConfigurationModule()); + binder.install(new ConfigurationModule(config)); binder.install(new MetricModule()); binder.install(new DatabaseConfigurationModule()); @@ -61,18 +79,28 @@ public void configure(Binder binder) { binder.install(new TaskSchedulerModule()); binder.bind(BackgroundTasks.class).in(SINGLETON); + binder.bind(DependencyManagerConfiguration.class).toProvider(DependencyManagerConfigurationProvider.class); + binder.install(new AgentModule()); binder.install(new ApiKeyModule()); - binder.install(new ConsoleModule()); binder.install(new ApiServerModule()); binder.install(new AuditLogModule()); + binder.install(new ConsoleModule()); + binder.install(new EventModule()); binder.install(new PolicyModule()); binder.install(new ProcessModule()); binder.install(new RepositoryModule()); binder.install(new RoleModule()); + binder.install(new SecretModule()); + binder.install(new SecurityModule()); binder.install(new TemplateModule()); binder.install(new TriggersModule()); bindJaxRsResource(binder, ServerResource.class); } + + private static Config loadDefaultConfig() { + Environment env = new EnvironmentSelector().select(); + return new ConfigurationProcessor("concord-server", env, null, null).process(); + } } diff --git a/server/impl/src/main/java/com/walmartlabs/concord/server/DependencyManagerConfigurationProvider.java b/server/impl/src/main/java/com/walmartlabs/concord/server/DependencyManagerConfigurationProvider.java index fff50d3a6d..f9b1ddaef0 100644 --- a/server/impl/src/main/java/com/walmartlabs/concord/server/DependencyManagerConfigurationProvider.java +++ b/server/impl/src/main/java/com/walmartlabs/concord/server/DependencyManagerConfigurationProvider.java @@ -24,11 +24,9 @@ import com.walmartlabs.concord.server.cfg.DependenciesConfiguration; import javax.inject.Inject; -import javax.inject.Named; import javax.inject.Provider; import javax.inject.Singleton; -@Named @Singleton public class DependencyManagerConfigurationProvider implements Provider { diff --git a/server/impl/src/main/java/com/walmartlabs/concord/server/ObjectMapperInitializer.java b/server/impl/src/main/java/com/walmartlabs/concord/server/ObjectMapperInitializer.java index 4184391c0e..f10ae1341f 100644 --- a/server/impl/src/main/java/com/walmartlabs/concord/server/ObjectMapperInitializer.java +++ b/server/impl/src/main/java/com/walmartlabs/concord/server/ObjectMapperInitializer.java @@ -29,6 +29,9 @@ import javax.inject.Inject; import javax.inject.Named; +/** + * Until Siesta is removed, we need to make sure its ObjectMapper is configured correctly. + */ @Named @EagerSingleton public class ObjectMapperInitializer { diff --git a/server/impl/src/main/java/com/walmartlabs/concord/server/audit/AuditLogModule.java b/server/impl/src/main/java/com/walmartlabs/concord/server/audit/AuditLogModule.java index 67acf151cc..ee54ad8c78 100644 --- a/server/impl/src/main/java/com/walmartlabs/concord/server/audit/AuditLogModule.java +++ b/server/impl/src/main/java/com/walmartlabs/concord/server/audit/AuditLogModule.java @@ -22,7 +22,9 @@ import com.google.inject.Binder; import com.google.inject.Module; +import com.walmartlabs.concord.server.sdk.audit.AuditLogListener; +import static com.google.inject.multibindings.Multibinder.newSetBinder; import static com.walmartlabs.concord.server.Utils.bindJaxRsResource; import static com.walmartlabs.concord.server.Utils.bindSingletonScheduledTask; @@ -30,6 +32,7 @@ public class AuditLogModule implements Module { @Override public void configure(Binder binder) { + newSetBinder(binder, AuditLogListener.class); bindSingletonScheduledTask(binder, AuditLogCleaner.class); bindJaxRsResource(binder, AuditLogResource.class); } diff --git a/server/impl/src/main/java/com/walmartlabs/concord/server/boot/HttpServer.java b/server/impl/src/main/java/com/walmartlabs/concord/server/boot/HttpServer.java index 7d024bada5..e958ba99a6 100644 --- a/server/impl/src/main/java/com/walmartlabs/concord/server/boot/HttpServer.java +++ b/server/impl/src/main/java/com/walmartlabs/concord/server/boot/HttpServer.java @@ -32,6 +32,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import javax.annotation.Priority; import javax.inject.Inject; import javax.servlet.*; import javax.servlet.annotation.WebFilter; @@ -39,6 +40,7 @@ import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import java.lang.management.ManagementFactory; +import java.util.Comparator; import java.util.EnumSet; import java.util.Set; @@ -101,21 +103,21 @@ public HttpServer(ServerConfiguration cfg, } // init all @WebListeners - for (ServletContextListener listener : contextListeners) { + contextListeners.stream().sorted(byPriority()).forEachOrdered(listener -> { WebListener annotation = listener.getClass().getAnnotation(WebListener.class); if (annotation == null) { - continue; + return; } log.info("Event listener -> {}", listener.getClass()); contextHandler.addEventListener(listener); - } + }); // init all @WebServlets - for (HttpServlet servlet : servlets) { + servlets.stream().sorted(byPriority()).forEachOrdered(servlet -> { WebServlet annotation = servlet.getClass().getAnnotation(WebServlet.class); if (annotation == null) { - continue; + return; } ServletHolder holder = new ServletHolder(servlet); @@ -123,54 +125,54 @@ public HttpServer(ServerConfiguration cfg, log.info("Servlet -> {} @ {}", servlet.getClass(), pathSpec); contextHandler.addServlet(holder, pathSpec); } - } + }); - for (ServletHolder holder : servletHolders) { + servletHolders.stream().sorted(byPriority()).forEachOrdered(holder -> { WebServlet annotation = holder.getClass().getAnnotation(WebServlet.class); if (annotation == null) { - continue; + return; } for (String pathSpec : annotation.value()) { log.info("Servlet -> {} @ {}", holder.getClass(), pathSpec); contextHandler.addServlet(holder, pathSpec); } - } + }); // init all @WebFilters - for (Filter filter : filters) { + filters.stream().sorted(byPriority()).forEachOrdered(filter -> { WebFilter annotation = filter.getClass().getAnnotation(WebFilter.class); if (annotation == null) { - continue; + return; } FilterHolder holder = new FilterHolder(filter); for (String pathSpec : annotation.value()) { - log.info("Servlet -> {} @ {}", filter.getClass(), pathSpec); + log.info("Filter -> {} @ {}", filter.getClass(), pathSpec); contextHandler.addFilter(holder, pathSpec, EnumSet.allOf(DispatcherType.class)); } - } + }); - for (FilterHolder holder : filterHolders) { + filterHolders.stream().sorted(byPriority()).forEachOrdered(holder -> { WebFilter annotation = holder.getClass().getAnnotation(WebFilter.class); if (annotation == null) { - continue; + return; } for (String pathSpec : annotation.value()) { log.info("Filter -> {} @ {}", holder.getClass(), pathSpec); - contextHandler.addFilter(holder, pathSpec, EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD, DispatcherType.INCLUDE, DispatcherType.ERROR)); + contextHandler.addFilter(holder, pathSpec, EnumSet.allOf(DispatcherType.class)); } - } + }); ContextHandlerCollection contextHandlerCollection = new ContextHandlerCollection(); contextHandlerCollection.addHandler(contextHandler); // additional handlers - for (ContextHandlerConfigurator configurator : contextHandlerConfigurators) { + contextHandlerConfigurators.stream().sorted(byPriority()).forEachOrdered(configurator -> { log.info("Configuring additional context handlers {}...", configurator.getClass()); configurator.configure(contextHandlerCollection); - } + }); StatisticsHandler statisticsHandler = new StatisticsHandler(); statisticsHandler.setHandler(contextHandlerCollection); @@ -202,4 +204,11 @@ private static RequestLog createRequestLog(ServerConfiguration cfg) { return new CustomRequestLog(writer, ServerConfiguration.ACCESS_LOG_FORMAT); } + + private static Comparator byPriority() { + return Comparator.comparingInt(o -> { + var a = o.getClass().getAnnotation(Priority.class); + return a != null ? a.value() : 0; + }); + } } diff --git a/server/impl/src/main/java/com/walmartlabs/concord/server/cfg/ConfigurationModule.java b/server/impl/src/main/java/com/walmartlabs/concord/server/cfg/ConfigurationModule.java index 21b3482b34..196624fe01 100644 --- a/server/impl/src/main/java/com/walmartlabs/concord/server/cfg/ConfigurationModule.java +++ b/server/impl/src/main/java/com/walmartlabs/concord/server/cfg/ConfigurationModule.java @@ -22,20 +22,23 @@ import com.google.inject.Binder; import com.google.inject.Module; -import com.walmartlabs.ollie.config.ConfigurationProcessor; -import com.walmartlabs.ollie.config.Environment; -import com.walmartlabs.ollie.config.EnvironmentSelector; -import com.walmartlabs.ollie.config.OllieConfigurationModule; +import com.typesafe.config.Config; import static com.google.inject.Scopes.SINGLETON; public class ConfigurationModule implements Module { + private final Config config; + + public ConfigurationModule(Config config) { + this.config = config; + } + @Override public void configure(Binder binder) { - Environment env = new EnvironmentSelector().select(); - com.typesafe.config.Config config = new ConfigurationProcessor("concord-server", env, null, null).process(); - binder.install(new OllieConfigurationModule("com.walmartlabs.concord.server", config)); + binder.bind(Config.class).toInstance(config); + + binder.install(new com.walmartlabs.ollie.config.OllieConfigurationModule("com.walmartlabs.concord.server", config)); binder.bind(AgentConfiguration.class).in(SINGLETON); binder.bind(ApiKeyConfiguration.class).in(SINGLETON); diff --git a/agent/src/main/java/com/walmartlabs/concord/agent/ObjectMapperProvider.java b/server/impl/src/main/java/com/walmartlabs/concord/server/events/EventModule.java similarity index 59% rename from agent/src/main/java/com/walmartlabs/concord/agent/ObjectMapperProvider.java rename to server/impl/src/main/java/com/walmartlabs/concord/server/events/EventModule.java index 857544fc15..4a994d2928 100644 --- a/agent/src/main/java/com/walmartlabs/concord/agent/ObjectMapperProvider.java +++ b/server/impl/src/main/java/com/walmartlabs/concord/server/events/EventModule.java @@ -1,10 +1,10 @@ -package com.walmartlabs.concord.agent; +package com.walmartlabs.concord.server.events; /*- * ***** * Concord * ----- - * Copyright (C) 2017 - 2019 Walmart Inc. + * Copyright (C) 2017 - 2023 Walmart Inc. * ----- * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,18 +20,16 @@ * ===== */ -import com.fasterxml.jackson.databind.ObjectMapper; +import com.google.inject.Binder; +import com.google.inject.Module; +import com.walmartlabs.concord.server.sdk.events.ProcessEventListener; -import javax.inject.Named; -import javax.inject.Provider; -import javax.inject.Singleton; +import static com.google.inject.multibindings.Multibinder.newSetBinder; -@Named -@Singleton -public class ObjectMapperProvider implements Provider { +public class EventModule implements Module { @Override - public ObjectMapper get() { - return new ObjectMapper(); + public void configure(Binder binder) { + newSetBinder(binder, ProcessEventListener.class); } } diff --git a/server/impl/src/main/java/com/walmartlabs/concord/server/metrics/MetricModule.java b/server/impl/src/main/java/com/walmartlabs/concord/server/metrics/MetricModule.java index dfaf9a6634..7aaec78d29 100644 --- a/server/impl/src/main/java/com/walmartlabs/concord/server/metrics/MetricModule.java +++ b/server/impl/src/main/java/com/walmartlabs/concord/server/metrics/MetricModule.java @@ -24,9 +24,11 @@ import com.google.inject.Binder; import com.google.inject.Module; import com.google.inject.matcher.Matchers; +import com.walmartlabs.concord.server.sdk.metrics.GaugeProvider; import com.walmartlabs.concord.server.sdk.metrics.WithTimer; import static com.google.inject.Scopes.SINGLETON; +import static com.google.inject.multibindings.Multibinder.newSetBinder; import static com.walmartlabs.concord.server.Utils.bindServletHolder; import static com.walmartlabs.concord.server.Utils.bindSingletonBackgroundTask; import static com.walmartlabs.concord.server.metrics.NoSyntheticMethodMatcher.INSTANCE; @@ -35,6 +37,10 @@ public class MetricModule implements Module { @Override public void configure(Binder binder) { + // common + + newSetBinder(binder, GaugeProvider.class); + // registry binder.bind(MetricRegistry.class).toProvider(MetricRegistryProvider.class).in(SINGLETON); @@ -50,9 +56,9 @@ public void configure(Binder binder) { // tasks - bindSingletonBackgroundTask(binder, MetricsRegistrator.class); bindSingletonBackgroundTask(binder, FailedTaskMetrics.class); bindSingletonBackgroundTask(binder, WorkerMetrics.class); + bindSingletonBackgroundTask(binder, MetricsRegistrator.class); // the /metrics endpoint diff --git a/server/impl/src/main/java/com/walmartlabs/concord/server/metrics/MetricsRegistrator.java b/server/impl/src/main/java/com/walmartlabs/concord/server/metrics/MetricsRegistrator.java index 6cf20fb500..bb7cd49222 100644 --- a/server/impl/src/main/java/com/walmartlabs/concord/server/metrics/MetricsRegistrator.java +++ b/server/impl/src/main/java/com/walmartlabs/concord/server/metrics/MetricsRegistrator.java @@ -9,9 +9,9 @@ * 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. @@ -33,10 +33,10 @@ public class MetricsRegistrator implements BackgroundTask { private final MetricRegistry registry; - private final Set> gauges; + private final Set gauges; @Inject - public MetricsRegistrator(MetricRegistry registry, Set> gauges) { + public MetricsRegistrator(MetricRegistry registry, Set gauges) { this.registry = registry; this.gauges = gauges; } diff --git a/agent/src/main/java/com/walmartlabs/concord/agent/cfg/ConfigProvider.java b/server/impl/src/main/java/com/walmartlabs/concord/server/org/secret/SecretModule.java similarity index 50% rename from agent/src/main/java/com/walmartlabs/concord/agent/cfg/ConfigProvider.java rename to server/impl/src/main/java/com/walmartlabs/concord/server/org/secret/SecretModule.java index efa3b9947e..87cc8b63f7 100644 --- a/agent/src/main/java/com/walmartlabs/concord/agent/cfg/ConfigProvider.java +++ b/server/impl/src/main/java/com/walmartlabs/concord/server/org/secret/SecretModule.java @@ -1,17 +1,17 @@ -package com.walmartlabs.concord.agent.cfg; +package com.walmartlabs.concord.server.org.secret; /*- * ***** * Concord * ----- - * Copyright (C) 2017 - 2019 Walmart Inc. + * Copyright (C) 2017 - 2023 Walmart 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. @@ -20,22 +20,17 @@ * ===== */ -import com.typesafe.config.Config; -import com.walmartlabs.ollie.config.ConfigurationProcessor; -import com.walmartlabs.ollie.config.Environment; -import com.walmartlabs.ollie.config.EnvironmentSelector; +import com.google.inject.Binder; +import com.google.inject.Module; +import com.walmartlabs.concord.server.org.secret.store.SecretStore; +import com.walmartlabs.concord.server.org.secret.store.concord.ConcordSecretStore; -import javax.inject.Named; -import javax.inject.Provider; -import javax.inject.Singleton; +import static com.google.inject.multibindings.Multibinder.newSetBinder; -@Named -@Singleton -public class ConfigProvider implements Provider { +public class SecretModule implements Module { @Override - public Config get() { - Environment env = new EnvironmentSelector().select(); - return new ConfigurationProcessor("concord-agent", env).process(); + public void configure(Binder binder) { + newSetBinder(binder, SecretStore.class).addBinding().to(ConcordSecretStore.class); } } diff --git a/server/impl/src/main/java/com/walmartlabs/concord/server/org/secret/provider/SecretStoreProvider.java b/server/impl/src/main/java/com/walmartlabs/concord/server/org/secret/provider/SecretStoreProvider.java index 6e02a80dfa..aabc08e68c 100644 --- a/server/impl/src/main/java/com/walmartlabs/concord/server/org/secret/provider/SecretStoreProvider.java +++ b/server/impl/src/main/java/com/walmartlabs/concord/server/org/secret/provider/SecretStoreProvider.java @@ -27,16 +27,17 @@ import javax.inject.Named; import java.util.ArrayList; import java.util.Collection; +import java.util.Set; @Named public class SecretStoreProvider { - private final Collection stores; + private final Set stores; private final int maxSecretDataSize; private final String defaultSecretStoreType; @Inject - public SecretStoreProvider(Collection stores, + public SecretStoreProvider(Set stores, @Config("secretStore.maxSecretDataSize") int maxSecretDataSize, @Config("secretStore.default") String defaultStore) { this.stores = stores; diff --git a/server/impl/src/main/java/com/walmartlabs/concord/server/org/secret/store/concord/ConcordSecretStore.java b/server/impl/src/main/java/com/walmartlabs/concord/server/org/secret/store/concord/ConcordSecretStore.java index 5410c1aac3..7ca1313cc1 100644 --- a/server/impl/src/main/java/com/walmartlabs/concord/server/org/secret/store/concord/ConcordSecretStore.java +++ b/server/impl/src/main/java/com/walmartlabs/concord/server/org/secret/store/concord/ConcordSecretStore.java @@ -30,8 +30,6 @@ import javax.inject.Singleton; import java.util.UUID; -@Named("concordSecretStore") -@Singleton public class ConcordSecretStore implements SecretStore { private static final String TYPE = "concord"; diff --git a/server/impl/src/main/java/com/walmartlabs/concord/server/ImportManagerProvider.java b/server/impl/src/main/java/com/walmartlabs/concord/server/process/ImportManagerProvider.java similarity index 98% rename from server/impl/src/main/java/com/walmartlabs/concord/server/ImportManagerProvider.java rename to server/impl/src/main/java/com/walmartlabs/concord/server/process/ImportManagerProvider.java index 5a42cb9bdf..2fbd7878f7 100644 --- a/server/impl/src/main/java/com/walmartlabs/concord/server/ImportManagerProvider.java +++ b/server/impl/src/main/java/com/walmartlabs/concord/server/process/ImportManagerProvider.java @@ -1,4 +1,4 @@ -package com.walmartlabs.concord.server; +package com.walmartlabs.concord.server.process; /*- * ***** @@ -35,13 +35,11 @@ import com.walmartlabs.concord.server.repository.RepositoryManager; import javax.inject.Inject; -import javax.inject.Named; import javax.inject.Provider; import java.nio.file.Path; import java.util.Objects; import java.util.UUID; -@Named public class ImportManagerProvider implements Provider { private final ImportManagerFactory factory; diff --git a/server/impl/src/main/java/com/walmartlabs/concord/server/process/ProcessHeartbeatResource.java b/server/impl/src/main/java/com/walmartlabs/concord/server/process/ProcessHeartbeatResource.java index 7d2ce1a8e6..4d0be8c847 100644 --- a/server/impl/src/main/java/com/walmartlabs/concord/server/process/ProcessHeartbeatResource.java +++ b/server/impl/src/main/java/com/walmartlabs/concord/server/process/ProcessHeartbeatResource.java @@ -26,15 +26,11 @@ import org.sonatype.siesta.Resource; import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Singleton; import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import java.util.UUID; -@Named -@Singleton @Path("/api/v1/process") @Tag(name = "ProcessHeartbeat") public class ProcessHeartbeatResource implements Resource { @@ -46,7 +42,6 @@ public ProcessHeartbeatResource(ProcessQueueDao queueDao) { this.queueDao = queueDao; } - @POST @Path("{id}/ping") @Operation(description = "Process heartbeat", operationId = "pingProcess") diff --git a/server/impl/src/main/java/com/walmartlabs/concord/server/process/ProcessKvResource.java b/server/impl/src/main/java/com/walmartlabs/concord/server/process/ProcessKvResource.java index 8ea1abca40..75a2bc7f31 100644 --- a/server/impl/src/main/java/com/walmartlabs/concord/server/process/ProcessKvResource.java +++ b/server/impl/src/main/java/com/walmartlabs/concord/server/process/ProcessKvResource.java @@ -31,14 +31,10 @@ import org.sonatype.siesta.Resource; import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Singleton; import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import java.util.UUID; -@Named -@Singleton @Path("/api/v1/process") @Tag(name = "Process KV store") public class ProcessKvResource implements Resource { diff --git a/server/impl/src/main/java/com/walmartlabs/concord/server/process/ProcessLogResourceV2.java b/server/impl/src/main/java/com/walmartlabs/concord/server/process/ProcessLogResourceV2.java index 17160e76c4..f11b8a3237 100644 --- a/server/impl/src/main/java/com/walmartlabs/concord/server/process/ProcessLogResourceV2.java +++ b/server/impl/src/main/java/com/walmartlabs/concord/server/process/ProcessLogResourceV2.java @@ -39,8 +39,6 @@ import org.sonatype.siesta.ValidationErrorsException; import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Singleton; import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; @@ -56,8 +54,6 @@ /** * API to work with segmented process logs. */ -@Named -@Singleton @Path("/api/v2/process") @Tag(name = "ProcessLogV2") public class ProcessLogResourceV2 implements Resource { diff --git a/server/impl/src/main/java/com/walmartlabs/concord/server/process/ProcessManager.java b/server/impl/src/main/java/com/walmartlabs/concord/server/process/ProcessManager.java index 5eb7b3ba26..84ca473ece 100644 --- a/server/impl/src/main/java/com/walmartlabs/concord/server/process/ProcessManager.java +++ b/server/impl/src/main/java/com/walmartlabs/concord/server/process/ProcessManager.java @@ -53,10 +53,8 @@ import javax.inject.Inject; import javax.inject.Named; -import javax.ws.rs.core.Response; import javax.ws.rs.core.Response.Status; -import java.io.IOException; -import java.io.Serializable; +import java.io.*; import java.util.*; import java.util.stream.Collectors; @@ -312,6 +310,22 @@ public ProcessEntry assertProcess(UUID instanceId) { return p; } + public void assertResumeEvents(ProcessKey processKey, Set events) { + if (events.isEmpty()) { + throw new ConcordApplicationException("Empty resume events", Status.BAD_REQUEST); + } + + Set expectedEvents = getResumeEvents(processKey); + + Set unexpectedEvents = new HashSet<>(events); + unexpectedEvents.removeAll(expectedEvents); + + if (!unexpectedEvents.isEmpty()) { + logManager.warn(processKey, "Unexpected 'resume' events: {}, expected: {}", unexpectedEvents, expectedEvents); + throw new ConcordApplicationException("Unexpected 'resume' events: " + unexpectedEvents, Status.BAD_REQUEST); + } + } + public void updateExclusive(DSLContext tx, ProcessKey processKey, ExclusiveMode exclusive) { queueDao.updateExclusive(tx, processKey, exclusive); } @@ -419,6 +433,28 @@ public void auditLogOnCancelled(ProcessEntry p) { .log(); } + private Set getResumeEvents(ProcessKey processKey) { + String path = ProcessStateManager.path(Constants.Files.JOB_ATTACHMENTS_DIR_NAME, + Constants.Files.JOB_STATE_DIR_NAME, + Constants.Files.SUSPEND_MARKER_FILE_NAME); + + return stateManager.get(processKey, path, ProcessManager::deserialize) + .orElse(Set.of()); + } + + private static Optional> deserialize(InputStream in) { + Set result = new HashSet<>(); + try (BufferedReader reader = new BufferedReader(new InputStreamReader(in))) { + String line; + while ((line = reader.readLine()) != null) { + result.add(line); + } + return Optional.of(result); + } catch (IOException e) { + throw new RuntimeException("Error while deserializing a resume events: " + e.getMessage(), e); + } + } + private static List filterProcesses(List l, List expected) { return l.stream() .filter(r -> expected.contains(r.status())) diff --git a/server/impl/src/main/java/com/walmartlabs/concord/server/process/ProcessModule.java b/server/impl/src/main/java/com/walmartlabs/concord/server/process/ProcessModule.java index 7e76673f0d..484bff5efe 100644 --- a/server/impl/src/main/java/com/walmartlabs/concord/server/process/ProcessModule.java +++ b/server/impl/src/main/java/com/walmartlabs/concord/server/process/ProcessModule.java @@ -9,9 +9,9 @@ * 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. @@ -22,21 +22,38 @@ import com.google.inject.Binder; import com.google.inject.Module; +import com.walmartlabs.concord.imports.ImportManager; +import com.walmartlabs.concord.server.process.checkpoint.ProcessCheckpointResource; +import com.walmartlabs.concord.server.process.checkpoint.ProcessCheckpointV2Resource; +import com.walmartlabs.concord.server.process.event.ProcessEventResource; +import com.walmartlabs.concord.server.process.form.FormResource; +import com.walmartlabs.concord.server.process.locks.ProcessLocksResource; import com.walmartlabs.concord.server.process.locks.ProcessLocksWatchdog; +import com.walmartlabs.concord.server.process.pipelines.processors.ExclusiveGroupProcessor; +import com.walmartlabs.concord.server.process.pipelines.processors.policy.*; import com.walmartlabs.concord.server.process.queue.EnqueuedTaskProvider; +import com.walmartlabs.concord.server.process.queue.ExternalProcessListenerHandler; import com.walmartlabs.concord.server.process.queue.ProcessQueueWatchdog; +import com.walmartlabs.concord.server.process.queue.ProcessStatusListener; +import com.walmartlabs.concord.server.process.queue.dispatcher.ConcurrentProcessFilter; import com.walmartlabs.concord.server.process.queue.dispatcher.Dispatcher; -import com.walmartlabs.concord.server.process.waits.ProcessWaitWatchdog; +import com.walmartlabs.concord.server.process.queue.dispatcher.ExclusiveProcessFilter; +import com.walmartlabs.concord.server.process.queue.dispatcher.Filter; +import com.walmartlabs.concord.server.process.waits.*; import com.walmartlabs.concord.server.sdk.BackgroundTask; +import com.walmartlabs.concord.server.sdk.log.ProcessLogListener; import static com.google.inject.Scopes.SINGLETON; import static com.google.inject.multibindings.Multibinder.newSetBinder; +import static com.walmartlabs.concord.server.Utils.bindJaxRsResource; import static com.walmartlabs.concord.server.Utils.bindSingletonScheduledTask; public class ProcessModule implements Module { @Override public void configure(Binder binder) { + binder.bind(ImportManager.class).toProvider(ImportManagerProvider.class); + bindSingletonScheduledTask(binder, ProcessCleaner.class); bindSingletonScheduledTask(binder, ProcessLocksWatchdog.class); bindSingletonScheduledTask(binder, ProcessQueueWatchdog.class); @@ -46,5 +63,36 @@ public void configure(Binder binder) { newSetBinder(binder, BackgroundTask.class).addBinding().to(Dispatcher.class); newSetBinder(binder, BackgroundTask.class).addBinding().toProvider(EnqueuedTaskProvider.class).in(SINGLETON); + + newSetBinder(binder, ProcessStatusListener.class).addBinding().to(WaitProcessStatusListener.class); + newSetBinder(binder, ProcessStatusListener.class).addBinding().to(ExternalProcessListenerHandler.class); + + newSetBinder(binder, Filter.class).addBinding().to(ConcurrentProcessFilter.class); + newSetBinder(binder, Filter.class).addBinding().to(ExclusiveProcessFilter.class); + + newSetBinder(binder, ProcessWaitHandler.class).addBinding().to(WaitProcessFinishHandler.class); + newSetBinder(binder, ProcessWaitHandler.class).addBinding().to(WaitProcessLockHandler.class); + newSetBinder(binder, ProcessWaitHandler.class).addBinding().to(WaitProcessSleepHandler.class); + + newSetBinder(binder, ProcessLogListener.class); + + binder.install(new ExclusiveGroupProcessor.ModeProcessorModule()); + + newSetBinder(binder, PolicyApplier.class).addBinding().to(ContainerPolicyApplier.class); + newSetBinder(binder, PolicyApplier.class).addBinding().to(FilePolicyApplier.class); + newSetBinder(binder, PolicyApplier.class).addBinding().to(ProcessRuntimePolicyApplier.class); + newSetBinder(binder, PolicyApplier.class).addBinding().to(ProcessTimeoutPolicyApplier.class); + newSetBinder(binder, PolicyApplier.class).addBinding().to(WorkspacePolicyApplier.class); + + bindJaxRsResource(binder, FormResource.class); + bindJaxRsResource(binder, ProcessCheckpointResource.class); + bindJaxRsResource(binder, ProcessCheckpointV2Resource.class); + bindJaxRsResource(binder, ProcessEventResource.class); + bindJaxRsResource(binder, ProcessHeartbeatResource.class); + bindJaxRsResource(binder, ProcessKvResource.class); + bindJaxRsResource(binder, ProcessLocksResource.class); + bindJaxRsResource(binder, ProcessLogResourceV2.class); + bindJaxRsResource(binder, ProcessResource.class); + bindJaxRsResource(binder, ProcessResourceV2.class); } } diff --git a/server/impl/src/main/java/com/walmartlabs/concord/server/process/ProcessResource.java b/server/impl/src/main/java/com/walmartlabs/concord/server/process/ProcessResource.java index 9f830ee941..25da421db2 100644 --- a/server/impl/src/main/java/com/walmartlabs/concord/server/process/ProcessResource.java +++ b/server/impl/src/main/java/com/walmartlabs/concord/server/process/ProcessResource.java @@ -79,15 +79,16 @@ import org.sonatype.siesta.ValidationErrorsException; import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Singleton; import javax.servlet.http.HttpServletRequest; import javax.validation.constraints.NotNull; import javax.validation.constraints.Size; import javax.ws.rs.*; import javax.ws.rs.core.*; import javax.ws.rs.core.Response.Status; -import java.io.*; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.StandardCopyOption; @@ -98,8 +99,6 @@ import static com.walmartlabs.concord.server.process.state.ProcessStateManager.path; import static com.walmartlabs.concord.server.process.state.ProcessStateManager.zipTo; -@Named -@Singleton @javax.ws.rs.Path("/api/v1/process") @Tag(name = "Process") public class ProcessResource implements Resource { @@ -260,7 +259,6 @@ public StartProcessResponse start(@PathParam("entryPoint") String entryPoint, /** * Starts a new process instance. - * */ @POST @Consumes(MediaType.MULTIPART_FORM_DATA) @@ -395,7 +393,9 @@ public ResumeProcessResponse resume(@PathParam("id") UUID instanceId, @QueryParam("saveAs") String saveAs, Map req) { - PartialProcessKey processKey = PartialProcessKey.from(instanceId); + ProcessKey processKey = assertProcessKey(instanceId); + + processManager.assertResumeEvents(processKey, Set.of(eventName)); if (saveAs != null && !saveAs.isEmpty() && req != null) { req = ConfigurationUtils.toNested(saveAs, req); @@ -478,9 +478,9 @@ public ProcessEntry waitForCompletion(@PathParam("id") UUID instanceId, ProcessStatus s = r.status(); if (s == ProcessStatus.FINISHED || - s == ProcessStatus.FAILED || - s == ProcessStatus.CANCELLED || - s == ProcessStatus.TIMED_OUT) { + s == ProcessStatus.FAILED || + s == ProcessStatus.CANCELLED || + s == ProcessStatus.TIMED_OUT) { return r; } @@ -758,6 +758,7 @@ public Response getLog(@PathParam("id") UUID instanceId, /** * Appends a process' log. + * * @deprecated in favor of the /api/v2/process/{id}/log* endpoints */ @POST @@ -1033,7 +1034,7 @@ private void assertProcessAccess(ProcessEntry pe, String downloadEntity) { } throw new UnauthorizedException("The current user (" + principal.getUsername() + ") doesn't have " + - "the necessary permissions to the download " + downloadEntity + " : " + pe.instanceId()); + "the necessary permissions to the download " + downloadEntity + " : " + pe.instanceId()); } private void assertResourceAccess(ProcessEntry pe, String resource) { @@ -1109,7 +1110,7 @@ private static Optional copyToTmp(InputStream in) { private static RuntimeException syncIsForbidden() { return new ConcordApplicationException("The 'sync' mode is no longer available. " + - "Please use sync=false and poll for the status updates.", Status.BAD_REQUEST); + "Please use sync=false and poll for the status updates.", Status.BAD_REQUEST); } private void assertAttachmentsPolicy(Path tmpDir, ProcessEntry entry) throws IOException { diff --git a/server/impl/src/main/java/com/walmartlabs/concord/server/process/ProcessResourceV2.java b/server/impl/src/main/java/com/walmartlabs/concord/server/process/ProcessResourceV2.java index 4134bbc28f..6bb436327e 100644 --- a/server/impl/src/main/java/com/walmartlabs/concord/server/process/ProcessResourceV2.java +++ b/server/impl/src/main/java/com/walmartlabs/concord/server/process/ProcessResourceV2.java @@ -43,31 +43,23 @@ import io.swagger.v3.oas.annotations.enums.ParameterIn; import io.swagger.v3.oas.annotations.extensions.Extension; import io.swagger.v3.oas.annotations.extensions.ExtensionProperty; -import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; -import io.swagger.v3.oas.annotations.parameters.RequestBody; import io.swagger.v3.oas.annotations.tags.Tag; -import org.jboss.resteasy.plugins.providers.multipart.MultipartInput; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.sonatype.siesta.Resource; import org.sonatype.siesta.ValidationErrorsException; import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Singleton; import javax.ws.rs.*; import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; import javax.ws.rs.core.Response.Status; import javax.ws.rs.core.UriInfo; import java.util.*; import static com.walmartlabs.concord.server.Utils.unwrap; -@Named -@Singleton @Path("/api/v2/process") @Tag(name = "ProcessV2") public class ProcessResourceV2 implements Resource { diff --git a/server/impl/src/main/java/com/walmartlabs/concord/server/process/checkpoint/ProcessCheckpointResource.java b/server/impl/src/main/java/com/walmartlabs/concord/server/process/checkpoint/ProcessCheckpointResource.java index 2d45878fb1..f1ed6ff698 100644 --- a/server/impl/src/main/java/com/walmartlabs/concord/server/process/checkpoint/ProcessCheckpointResource.java +++ b/server/impl/src/main/java/com/walmartlabs/concord/server/process/checkpoint/ProcessCheckpointResource.java @@ -23,7 +23,6 @@ import com.walmartlabs.concord.common.IOUtils; import com.walmartlabs.concord.common.TemporaryPath; import com.walmartlabs.concord.server.MultipartUtils; -import com.walmartlabs.concord.server.org.secret.SecretResource; import com.walmartlabs.concord.server.process.ProcessEntry; import com.walmartlabs.concord.server.process.ProcessEntry.ProcessCheckpointEntry; import com.walmartlabs.concord.server.process.ProcessManager; @@ -45,8 +44,6 @@ import org.sonatype.siesta.ValidationErrorsException; import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Singleton; import javax.validation.Valid; import javax.ws.rs.*; import javax.ws.rs.core.MediaType; @@ -58,8 +55,6 @@ import java.util.List; import java.util.UUID; -@Named -@Singleton @Path("/api/v1/process") @Tag(name = "Checkpoint") public class ProcessCheckpointResource implements Resource { diff --git a/server/impl/src/main/java/com/walmartlabs/concord/server/process/checkpoint/ProcessCheckpointV2Resource.java b/server/impl/src/main/java/com/walmartlabs/concord/server/process/checkpoint/ProcessCheckpointV2Resource.java index 7289656e3e..ab2005f0a4 100644 --- a/server/impl/src/main/java/com/walmartlabs/concord/server/process/checkpoint/ProcessCheckpointV2Resource.java +++ b/server/impl/src/main/java/com/walmartlabs/concord/server/process/checkpoint/ProcessCheckpointV2Resource.java @@ -39,8 +39,6 @@ import javax.ws.rs.core.MediaType; import java.util.UUID; -@Named -@Singleton @Path("/api/v2/process") @Tag(name = "CheckpointV2") public class ProcessCheckpointV2Resource implements Resource { diff --git a/server/impl/src/main/java/com/walmartlabs/concord/server/process/event/ProcessEventResource.java b/server/impl/src/main/java/com/walmartlabs/concord/server/process/event/ProcessEventResource.java index 2e49c69c0f..a788a455b1 100644 --- a/server/impl/src/main/java/com/walmartlabs/concord/server/process/event/ProcessEventResource.java +++ b/server/impl/src/main/java/com/walmartlabs/concord/server/process/event/ProcessEventResource.java @@ -49,8 +49,6 @@ import static com.walmartlabs.concord.server.Utils.unwrap; -@Named -@Singleton @Path("/api/v1/process") @Tag(name = "Process Events") public class ProcessEventResource implements Resource { diff --git a/server/impl/src/main/java/com/walmartlabs/concord/server/process/form/FormResource.java b/server/impl/src/main/java/com/walmartlabs/concord/server/process/form/FormResource.java index f885e810b6..124eac37ef 100644 --- a/server/impl/src/main/java/com/walmartlabs/concord/server/process/form/FormResource.java +++ b/server/impl/src/main/java/com/walmartlabs/concord/server/process/form/FormResource.java @@ -42,8 +42,6 @@ import static com.walmartlabs.concord.server.process.state.ProcessStateManager.path; -@Named -@Singleton @Path("/api/v1/process") @Tag(name = "Process Forms") public class FormResource implements Resource { diff --git a/server/impl/src/main/java/com/walmartlabs/concord/server/process/locks/ProcessLocksResource.java b/server/impl/src/main/java/com/walmartlabs/concord/server/process/locks/ProcessLocksResource.java index d25ea20733..f08b22eaaa 100644 --- a/server/impl/src/main/java/com/walmartlabs/concord/server/process/locks/ProcessLocksResource.java +++ b/server/impl/src/main/java/com/walmartlabs/concord/server/process/locks/ProcessLocksResource.java @@ -39,8 +39,6 @@ import javax.ws.rs.core.Response; import java.util.UUID; -@Named -@Singleton @Path("/api/v1/process") @Tag(name = "Process Locks") public class ProcessLocksResource implements Resource { diff --git a/server/impl/src/main/java/com/walmartlabs/concord/server/process/pipelines/processors/ExclusiveGroupProcessor.java b/server/impl/src/main/java/com/walmartlabs/concord/server/process/pipelines/processors/ExclusiveGroupProcessor.java index f9777ce963..6f9eadf2a5 100644 --- a/server/impl/src/main/java/com/walmartlabs/concord/server/process/pipelines/processors/ExclusiveGroupProcessor.java +++ b/server/impl/src/main/java/com/walmartlabs/concord/server/process/pipelines/processors/ExclusiveGroupProcessor.java @@ -9,9 +9,9 @@ * 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. @@ -20,6 +20,8 @@ * ===== */ +import com.google.inject.Binder; +import com.google.inject.Module; import com.walmartlabs.concord.db.AbstractDao; import com.walmartlabs.concord.db.MainDB; import com.walmartlabs.concord.runtime.v2.model.ExclusiveMode; @@ -37,12 +39,10 @@ import javax.inject.Inject; import javax.inject.Named; import java.time.OffsetDateTime; -import java.util.Arrays; -import java.util.List; -import java.util.Map; -import java.util.UUID; +import java.util.*; import java.util.stream.Collectors; +import static com.google.inject.multibindings.Multibinder.newSetBinder; import static com.walmartlabs.concord.db.PgUtils.jsonbText; import static com.walmartlabs.concord.server.jooq.Tables.PROCESS_QUEUE; import static org.jooq.impl.DSL.*; @@ -60,7 +60,7 @@ public class ExclusiveGroupProcessor implements PayloadProcessor { @Inject public ExclusiveGroupProcessor(ProcessLogManager logManager, - List processors) { + Set processors) { this.logManager = logManager; this.processors = processors.stream().collect(Collectors.toMap(ModeProcessor::mode, v -> v)); @@ -94,6 +94,15 @@ public Payload process(Chain chain, Payload payload) { return payload; } + public static class ModeProcessorModule implements Module { + + @Override + public void configure(Binder binder) { + newSetBinder(binder, ModeProcessor.class).addBinding().to(CancelModeProcessor.class); + newSetBinder(binder, ModeProcessor.class).addBinding().to(CancelOldModeProcessor.class); + } + } + interface ModeProcessor { boolean process(Payload payload, ExclusiveMode exclusive); @@ -101,7 +110,6 @@ interface ModeProcessor { ExclusiveMode.Mode mode(); } - @Named static class CancelModeProcessor implements ModeProcessor { private static final long LOCK_KEY = 1562319227723L; @@ -152,7 +160,6 @@ public ExclusiveMode.Mode mode() { } } - @Named static class CancelOldModeProcessor implements ModeProcessor { private static final long LOCK_KEY = 1562319227723L; @@ -231,7 +238,7 @@ public ProcessKey newProcess() { } @Named - static class CancelModeDao extends AbstractDao { + static class CancelModeDao extends AbstractDao { private static final List RUNNING_STATUSES = Arrays.asList( ProcessStatus.NEW, @@ -271,7 +278,7 @@ public boolean exists(DSLContext tx, UUID currentInstanceId, UUID parentInstance } @Named - static class CancelOldModeDao extends AbstractDao { + static class CancelOldModeDao extends AbstractDao { private static final List CANCELLABLE_STATUSES = Arrays.asList( ProcessStatus.NEW, diff --git a/server/impl/src/main/java/com/walmartlabs/concord/server/process/pipelines/processors/FailProcessor.java b/server/impl/src/main/java/com/walmartlabs/concord/server/process/pipelines/processors/FailProcessor.java index 5fb414265e..f97e7676d2 100644 --- a/server/impl/src/main/java/com/walmartlabs/concord/server/process/pipelines/processors/FailProcessor.java +++ b/server/impl/src/main/java/com/walmartlabs/concord/server/process/pipelines/processors/FailProcessor.java @@ -54,10 +54,11 @@ public void process(Payload payload, Exception e) { return; } - logManager.error(processKey, "Process failed: {}", e.getMessage()); - if (!(e instanceof InvalidProcessStateException)) { + logManager.error(processKey, "Process failed: {}", e.getMessage()); queueManager.updateStatus(processKey, ProcessStatus.FAILED); + } else { + logManager.warn(processKey, "Invalid process state: {}", e.getMessage()); } } } diff --git a/server/impl/src/main/java/com/walmartlabs/concord/server/process/pipelines/processors/ForkPolicyProcessor.java b/server/impl/src/main/java/com/walmartlabs/concord/server/process/pipelines/processors/ForkPolicyProcessor.java index 6ccfcb2b61..5f08ff1c4b 100644 --- a/server/impl/src/main/java/com/walmartlabs/concord/server/process/pipelines/processors/ForkPolicyProcessor.java +++ b/server/impl/src/main/java/com/walmartlabs/concord/server/process/pipelines/processors/ForkPolicyProcessor.java @@ -21,6 +21,7 @@ */ import com.walmartlabs.concord.db.AbstractDao; +import com.walmartlabs.concord.db.MainDB; import com.walmartlabs.concord.policyengine.CheckResult; import com.walmartlabs.concord.policyengine.ForkDepthRule; import com.walmartlabs.concord.policyengine.PolicyEngine; @@ -106,7 +107,7 @@ private String buildErrorMessage(List> private static class ForkDepthDao extends AbstractDao { @Inject - public ForkDepthDao(Configuration cfg) { + public ForkDepthDao(@MainDB Configuration cfg) { super(cfg); } diff --git a/server/impl/src/main/java/com/walmartlabs/concord/server/process/pipelines/processors/policy/ContainerPolicyApplier.java b/server/impl/src/main/java/com/walmartlabs/concord/server/process/pipelines/processors/policy/ContainerPolicyApplier.java index 777019044f..73b8c9466c 100644 --- a/server/impl/src/main/java/com/walmartlabs/concord/server/process/pipelines/processors/policy/ContainerPolicyApplier.java +++ b/server/impl/src/main/java/com/walmartlabs/concord/server/process/pipelines/processors/policy/ContainerPolicyApplier.java @@ -33,7 +33,6 @@ import com.walmartlabs.concord.server.sdk.metrics.InjectCounter; import javax.inject.Inject; -import javax.inject.Named; import java.io.IOException; import java.io.InputStream; import java.nio.file.Files; @@ -42,7 +41,6 @@ import static com.walmartlabs.concord.server.process.pipelines.processors.policy.PolicyApplier.appendMsg; -@Named public class ContainerPolicyApplier implements PolicyApplier { private final ProcessLogManager logManager; diff --git a/server/impl/src/main/java/com/walmartlabs/concord/server/process/pipelines/processors/policy/FilePolicyApplier.java b/server/impl/src/main/java/com/walmartlabs/concord/server/process/pipelines/processors/policy/FilePolicyApplier.java index 2e7ebd9082..1378b5ba10 100644 --- a/server/impl/src/main/java/com/walmartlabs/concord/server/process/pipelines/processors/policy/FilePolicyApplier.java +++ b/server/impl/src/main/java/com/walmartlabs/concord/server/process/pipelines/processors/policy/FilePolicyApplier.java @@ -31,10 +31,8 @@ import com.walmartlabs.concord.server.sdk.metrics.InjectCounter; import javax.inject.Inject; -import javax.inject.Named; import java.nio.file.Path; -@Named public class FilePolicyApplier implements PolicyApplier { private final ProcessLogManager logManager; diff --git a/server/impl/src/main/java/com/walmartlabs/concord/server/process/pipelines/processors/policy/ProcessRuntimePolicyApplier.java b/server/impl/src/main/java/com/walmartlabs/concord/server/process/pipelines/processors/policy/ProcessRuntimePolicyApplier.java index ce88740386..deda93a6ce 100644 --- a/server/impl/src/main/java/com/walmartlabs/concord/server/process/pipelines/processors/policy/ProcessRuntimePolicyApplier.java +++ b/server/impl/src/main/java/com/walmartlabs/concord/server/process/pipelines/processors/policy/ProcessRuntimePolicyApplier.java @@ -32,7 +32,6 @@ import com.walmartlabs.concord.server.sdk.metrics.InjectCounter; import javax.inject.Inject; -import javax.inject.Named; import java.text.MessageFormat; import java.time.OffsetDateTime; import java.util.Objects; @@ -40,7 +39,6 @@ import java.util.UUID; import java.util.function.Supplier; -@Named public class ProcessRuntimePolicyApplier implements PolicyApplier { private static final String DEFAULT_PROCESS_TIMEOUT_MSG = "{0} runtime version is not allowed"; diff --git a/server/impl/src/main/java/com/walmartlabs/concord/server/process/pipelines/processors/policy/ProcessTimeoutPolicyApplier.java b/server/impl/src/main/java/com/walmartlabs/concord/server/process/pipelines/processors/policy/ProcessTimeoutPolicyApplier.java index cedc37b767..3731e20538 100644 --- a/server/impl/src/main/java/com/walmartlabs/concord/server/process/pipelines/processors/policy/ProcessTimeoutPolicyApplier.java +++ b/server/impl/src/main/java/com/walmartlabs/concord/server/process/pipelines/processors/policy/ProcessTimeoutPolicyApplier.java @@ -32,11 +32,9 @@ import com.walmartlabs.concord.server.sdk.metrics.InjectCounter; import javax.inject.Inject; -import javax.inject.Named; import java.text.MessageFormat; import java.util.Map; -@Named public class ProcessTimeoutPolicyApplier implements PolicyApplier { private static final String DEFAULT_PROCESS_TIMEOUT_MSG = "Maximum 'processTimeout' value exceeded: current {0}, limit {1}"; diff --git a/server/impl/src/main/java/com/walmartlabs/concord/server/process/pipelines/processors/policy/WorkspacePolicyApplier.java b/server/impl/src/main/java/com/walmartlabs/concord/server/process/pipelines/processors/policy/WorkspacePolicyApplier.java index e786c51b53..27f236fe7e 100644 --- a/server/impl/src/main/java/com/walmartlabs/concord/server/process/pipelines/processors/policy/WorkspacePolicyApplier.java +++ b/server/impl/src/main/java/com/walmartlabs/concord/server/process/pipelines/processors/policy/WorkspacePolicyApplier.java @@ -31,12 +31,10 @@ import com.walmartlabs.concord.server.sdk.metrics.InjectCounter; import javax.inject.Inject; -import javax.inject.Named; import java.nio.file.Path; import static com.walmartlabs.concord.server.process.pipelines.processors.policy.PolicyApplier.appendMsg; -@Named public class WorkspacePolicyApplier implements PolicyApplier { private final ProcessLogManager logManager; diff --git a/server/impl/src/main/java/com/walmartlabs/concord/server/process/queue/ExternalProcessListenerHandler.java b/server/impl/src/main/java/com/walmartlabs/concord/server/process/queue/ExternalProcessListenerHandler.java index 5b834f8937..b061bb4c6e 100644 --- a/server/impl/src/main/java/com/walmartlabs/concord/server/process/queue/ExternalProcessListenerHandler.java +++ b/server/impl/src/main/java/com/walmartlabs/concord/server/process/queue/ExternalProcessListenerHandler.java @@ -28,14 +28,12 @@ import org.jooq.DSLContext; import javax.inject.Inject; -import javax.inject.Named; import java.util.Collections; /** * Sends {@link EventType#PROCESS_STATUS} events to registered {@link com.walmartlabs.concord.server.sdk.events.ProcessEventListener} * instances. */ -@Named public class ExternalProcessListenerHandler implements ProcessStatusListener { private final ProcessEventManager eventManager; diff --git a/server/impl/src/main/java/com/walmartlabs/concord/server/process/queue/ProcessQueueManager.java b/server/impl/src/main/java/com/walmartlabs/concord/server/process/queue/ProcessQueueManager.java index 491fc7992d..bfd45d44f2 100644 --- a/server/impl/src/main/java/com/walmartlabs/concord/server/process/queue/ProcessQueueManager.java +++ b/server/impl/src/main/java/com/walmartlabs/concord/server/process/queue/ProcessQueueManager.java @@ -49,7 +49,7 @@ public class ProcessQueueManager { private final ProcessKeyCache keyCache; private final ProcessEventManager eventManager; private final ProcessLogManager processLogManager; - private final Collection statusListeners; + private final Set statusListeners; private static final Set TO_ENQUEUED_STATUSES = new HashSet<>(Arrays.asList( ProcessStatus.PREPARING, ProcessStatus.RESUMING, ProcessStatus.SUSPENDED @@ -60,7 +60,7 @@ public ProcessQueueManager(ProcessQueueDao queueDao, ProcessKeyCache keyCache, ProcessEventManager eventManager, ProcessLogManager processLogManager, - Collection statusListeners) { + Set statusListeners) { this.queueDao = queueDao; this.eventManager = eventManager; diff --git a/server/impl/src/main/java/com/walmartlabs/concord/server/process/queue/dispatcher/ConcurrentProcessFilter.java b/server/impl/src/main/java/com/walmartlabs/concord/server/process/queue/dispatcher/ConcurrentProcessFilter.java index 98c34878f4..538cb542b8 100644 --- a/server/impl/src/main/java/com/walmartlabs/concord/server/process/queue/dispatcher/ConcurrentProcessFilter.java +++ b/server/impl/src/main/java/com/walmartlabs/concord/server/process/queue/dispatcher/ConcurrentProcessFilter.java @@ -33,7 +33,6 @@ import org.jooq.DSLContext; import javax.inject.Inject; -import javax.inject.Named; import java.util.*; /** @@ -41,7 +40,6 @@ * The process won't be scheduled for execution until the number of currently running * processes in the same project exceeds the configured value. */ -@Named public class ConcurrentProcessFilter extends WaitProcessFinishFilter { private static final Set FINAL_STATUSES = ImmutableSet.of( diff --git a/server/impl/src/main/java/com/walmartlabs/concord/server/process/queue/dispatcher/ExclusiveProcessFilter.java b/server/impl/src/main/java/com/walmartlabs/concord/server/process/queue/dispatcher/ExclusiveProcessFilter.java index 80c3d534a3..9bef850d78 100644 --- a/server/impl/src/main/java/com/walmartlabs/concord/server/process/queue/dispatcher/ExclusiveProcessFilter.java +++ b/server/impl/src/main/java/com/walmartlabs/concord/server/process/queue/dispatcher/ExclusiveProcessFilter.java @@ -27,7 +27,6 @@ import org.jooq.DSLContext; import javax.inject.Inject; -import javax.inject.Named; import java.util.*; /** @@ -35,7 +34,6 @@ * Exclusive processes can't be executed when there is another process * running in the same project and group. */ -@Named public class ExclusiveProcessFilter extends WaitProcessFinishFilter { private final ExclusiveProcessFilterDao dao; diff --git a/server/impl/src/main/java/com/walmartlabs/concord/server/process/waits/WaitProcessFinishHandler.java b/server/impl/src/main/java/com/walmartlabs/concord/server/process/waits/WaitProcessFinishHandler.java index cce4f38cdf..fac6670c68 100644 --- a/server/impl/src/main/java/com/walmartlabs/concord/server/process/waits/WaitProcessFinishHandler.java +++ b/server/impl/src/main/java/com/walmartlabs/concord/server/process/waits/WaitProcessFinishHandler.java @@ -43,7 +43,6 @@ /** * Handles the processes that are waiting for other processes to finish. */ -@Named @Singleton public class WaitProcessFinishHandler implements ProcessWaitHandler { diff --git a/server/impl/src/main/java/com/walmartlabs/concord/server/process/waits/WaitProcessLockHandler.java b/server/impl/src/main/java/com/walmartlabs/concord/server/process/waits/WaitProcessLockHandler.java index e7a1358fd0..fd10fc7022 100644 --- a/server/impl/src/main/java/com/walmartlabs/concord/server/process/waits/WaitProcessLockHandler.java +++ b/server/impl/src/main/java/com/walmartlabs/concord/server/process/waits/WaitProcessLockHandler.java @@ -26,14 +26,12 @@ import com.walmartlabs.concord.server.sdk.metrics.WithTimer; import javax.inject.Inject; -import javax.inject.Named; import javax.inject.Singleton; /** * Handles the processes that are waiting for locks. Resumes a suspended process * if the lock was acquired successfully. */ -@Named @Singleton public class WaitProcessLockHandler implements ProcessWaitHandler { diff --git a/server/impl/src/main/java/com/walmartlabs/concord/server/process/waits/WaitProcessSleepHandler.java b/server/impl/src/main/java/com/walmartlabs/concord/server/process/waits/WaitProcessSleepHandler.java index 7d408fd5ba..1c3ae6e882 100644 --- a/server/impl/src/main/java/com/walmartlabs/concord/server/process/waits/WaitProcessSleepHandler.java +++ b/server/impl/src/main/java/com/walmartlabs/concord/server/process/waits/WaitProcessSleepHandler.java @@ -23,7 +23,6 @@ import com.walmartlabs.concord.server.sdk.ProcessKey; import com.walmartlabs.concord.server.sdk.metrics.WithTimer; -import javax.inject.Named; import javax.inject.Singleton; import java.util.Date; @@ -31,7 +30,6 @@ * Handles the processes that are waiting for some timeout. Resumes a suspended process * if the timeout exceeded. */ -@Named @Singleton public class WaitProcessSleepHandler implements ProcessWaitHandler { diff --git a/server/impl/src/main/java/com/walmartlabs/concord/server/process/waits/WaitProcessStatusListener.java b/server/impl/src/main/java/com/walmartlabs/concord/server/process/waits/WaitProcessStatusListener.java index 484986e934..a14d736869 100644 --- a/server/impl/src/main/java/com/walmartlabs/concord/server/process/waits/WaitProcessStatusListener.java +++ b/server/impl/src/main/java/com/walmartlabs/concord/server/process/waits/WaitProcessStatusListener.java @@ -29,7 +29,6 @@ import static com.walmartlabs.concord.server.jooq.Tables.PROCESS_WAIT_CONDITIONS; -@Named public class WaitProcessStatusListener implements ProcessStatusListener { @Override diff --git a/server/impl/src/main/java/com/walmartlabs/concord/server/security/SecurityModule.java b/server/impl/src/main/java/com/walmartlabs/concord/server/security/SecurityModule.java index 238b45f1f0..a988b17de3 100644 --- a/server/impl/src/main/java/com/walmartlabs/concord/server/security/SecurityModule.java +++ b/server/impl/src/main/java/com/walmartlabs/concord/server/security/SecurityModule.java @@ -26,20 +26,16 @@ import com.walmartlabs.concord.server.security.github.GithubRealm; import com.walmartlabs.concord.server.security.internal.InternalRealm; import com.walmartlabs.concord.server.security.internal.LocalUserInfoProvider; -import com.walmartlabs.concord.server.security.ldap.LdapRealm; -import com.walmartlabs.concord.server.security.ldap.LdapUserInfoProvider; -import com.walmartlabs.concord.server.security.ldap.UserLdapGroupSynchronizer; +import com.walmartlabs.concord.server.security.ldap.*; import com.walmartlabs.concord.server.security.sessionkey.SessionKeyRealm; import com.walmartlabs.concord.server.user.UserInfoProvider; import org.apache.shiro.realm.Realm; - -import javax.inject.Named; +import org.apache.shiro.realm.ldap.LdapContextFactory; import static com.google.inject.Scopes.SINGLETON; import static com.google.inject.multibindings.Multibinder.newSetBinder; import static com.walmartlabs.concord.server.Utils.bindSingletonScheduledTask; -@Named public class SecurityModule implements Module { @Override @@ -50,6 +46,9 @@ public void configure(Binder binder) { newSetBinder(binder, Realm.class).addBinding().to(LdapRealm.class); newSetBinder(binder, Realm.class).addBinding().to(SessionKeyRealm.class); + binder.bind(LdapManager.class).toProvider(LdapManagerProvider.class); + binder.bind(LdapContextFactory.class).toProvider(LdapContextFactoryProvider.class); + bindSingletonScheduledTask(binder, UserLdapGroupSynchronizer.class); binder.bind(LocalUserInfoProvider.class).in(SINGLETON); diff --git a/server/impl/src/main/java/com/walmartlabs/concord/server/security/ldap/LdapContextFactoryProvider.java b/server/impl/src/main/java/com/walmartlabs/concord/server/security/ldap/LdapContextFactoryProvider.java index 5886d5b355..290cb89cbe 100644 --- a/server/impl/src/main/java/com/walmartlabs/concord/server/security/ldap/LdapContextFactoryProvider.java +++ b/server/impl/src/main/java/com/walmartlabs/concord/server/security/ldap/LdapContextFactoryProvider.java @@ -28,7 +28,6 @@ import javax.inject.Provider; import javax.naming.NamingException; -@Named public class LdapContextFactoryProvider implements Provider { private final LdapConfiguration cfg; diff --git a/server/impl/src/main/java/com/walmartlabs/concord/server/security/ldap/LdapManagerProvider.java b/server/impl/src/main/java/com/walmartlabs/concord/server/security/ldap/LdapManagerProvider.java index 63f8ded900..3105aba201 100644 --- a/server/impl/src/main/java/com/walmartlabs/concord/server/security/ldap/LdapManagerProvider.java +++ b/server/impl/src/main/java/com/walmartlabs/concord/server/security/ldap/LdapManagerProvider.java @@ -24,18 +24,16 @@ import org.apache.shiro.realm.ldap.LdapContextFactory; import javax.inject.Inject; -import javax.inject.Named; import javax.inject.Provider; import java.time.Duration; -@Named public class LdapManagerProvider implements Provider { private final LdapManager ldapManager; @Inject public LdapManagerProvider(LdapConfiguration cfg, - LdapContextFactory ctxFactory) { + LdapContextFactory ctxFactory) { LdapManager manager = new LdapManagerImpl(cfg, ctxFactory); diff --git a/server/impl/src/test/java/com/walmartlabs/concord/server/TestObjectMapper.java b/server/impl/src/test/java/com/walmartlabs/concord/server/TestObjectMapper.java index c42e4a53b7..83306020f8 100644 --- a/server/impl/src/test/java/com/walmartlabs/concord/server/TestObjectMapper.java +++ b/server/impl/src/test/java/com/walmartlabs/concord/server/TestObjectMapper.java @@ -28,9 +28,7 @@ public final class TestObjectMapper { public static final ObjectMapper INSTANCE = createObjectMapper(); private static ObjectMapper createObjectMapper() { - ObjectMapper om = new ObjectMapperProvider().get(); - new ObjectMapperInitializer(() -> om); - return om; + return new ObjectMapperProvider().get(); } private TestObjectMapper() { diff --git a/server/liquibase-ext/pom.xml b/server/liquibase-ext/pom.xml index bf1b1b9096..3e6f3a6f37 100644 --- a/server/liquibase-ext/pom.xml +++ b/server/liquibase-ext/pom.xml @@ -6,7 +6,7 @@ com.walmartlabs.concord.server parent - 2.1.1-SNAPSHOT + 2.5.1-SNAPSHOT ../pom.xml diff --git a/server/plugins/ansible/client/pom.xml b/server/plugins/ansible/client/pom.xml index 9815b46cc0..24dbd9fc1c 100644 --- a/server/plugins/ansible/client/pom.xml +++ b/server/plugins/ansible/client/pom.xml @@ -6,7 +6,7 @@ com.walmartlabs.concord.server.plugins.ansible parent - 2.1.1-SNAPSHOT + 2.5.1-SNAPSHOT ../pom.xml diff --git a/server/plugins/ansible/client2/pom.xml b/server/plugins/ansible/client2/pom.xml index e58d724ab5..71cd55809a 100644 --- a/server/plugins/ansible/client2/pom.xml +++ b/server/plugins/ansible/client2/pom.xml @@ -6,7 +6,7 @@ com.walmartlabs.concord.server.plugins.ansible parent - 2.1.1-SNAPSHOT + 2.5.1-SNAPSHOT ../pom.xml diff --git a/server/plugins/ansible/db/pom.xml b/server/plugins/ansible/db/pom.xml index 90eba31aea..2844fa4a7e 100644 --- a/server/plugins/ansible/db/pom.xml +++ b/server/plugins/ansible/db/pom.xml @@ -6,7 +6,7 @@ com.walmartlabs.concord.server.plugins.ansible parent - 2.1.1-SNAPSHOT + 2.5.1-SNAPSHOT ../pom.xml diff --git a/server/plugins/ansible/impl/pom.xml b/server/plugins/ansible/impl/pom.xml index 15067be0d9..72a3c07b24 100644 --- a/server/plugins/ansible/impl/pom.xml +++ b/server/plugins/ansible/impl/pom.xml @@ -6,7 +6,7 @@ com.walmartlabs.concord.server.plugins.ansible parent - 2.1.1-SNAPSHOT + 2.5.1-SNAPSHOT ../pom.xml diff --git a/server/plugins/ansible/pom.xml b/server/plugins/ansible/pom.xml index 2861633bc3..93cf4b4b72 100644 --- a/server/plugins/ansible/pom.xml +++ b/server/plugins/ansible/pom.xml @@ -6,7 +6,7 @@ com.walmartlabs.concord.server.plugins parent - 2.1.1-SNAPSHOT + 2.5.1-SNAPSHOT ../pom.xml diff --git a/server/plugins/kafka-event-sink/pom.xml b/server/plugins/kafka-event-sink/pom.xml index 6783a1fc51..c1cfa3d9d8 100644 --- a/server/plugins/kafka-event-sink/pom.xml +++ b/server/plugins/kafka-event-sink/pom.xml @@ -6,7 +6,7 @@ com.walmartlabs.concord.server.plugins parent - 2.1.1-SNAPSHOT + 2.5.1-SNAPSHOT ../pom.xml diff --git a/server/plugins/kafka-event-sink/src/main/java/com/walmartlabs/concord/server/plugins/eventsink/kafka/KafkaConnector.java b/server/plugins/kafka-event-sink/src/main/java/com/walmartlabs/concord/server/plugins/eventsink/kafka/KafkaConnector.java index 5155b392a3..8f95271106 100644 --- a/server/plugins/kafka-event-sink/src/main/java/com/walmartlabs/concord/server/plugins/eventsink/kafka/KafkaConnector.java +++ b/server/plugins/kafka-event-sink/src/main/java/com/walmartlabs/concord/server/plugins/eventsink/kafka/KafkaConnector.java @@ -28,14 +28,10 @@ import org.slf4j.LoggerFactory; import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Singleton; import java.net.InetAddress; import java.net.UnknownHostException; import java.util.Properties; -@Named -@Singleton public class KafkaConnector implements BackgroundTask { private static final Logger log = LoggerFactory.getLogger(KafkaConnector.class); diff --git a/server/plugins/kafka-event-sink/src/main/java/com/walmartlabs/concord/server/plugins/eventsink/kafka/KafkaEventSink.java b/server/plugins/kafka-event-sink/src/main/java/com/walmartlabs/concord/server/plugins/eventsink/kafka/KafkaEventSink.java index 301d7c521a..5dfd8af0a9 100644 --- a/server/plugins/kafka-event-sink/src/main/java/com/walmartlabs/concord/server/plugins/eventsink/kafka/KafkaEventSink.java +++ b/server/plugins/kafka-event-sink/src/main/java/com/walmartlabs/concord/server/plugins/eventsink/kafka/KafkaEventSink.java @@ -31,11 +31,9 @@ import org.slf4j.LoggerFactory; import javax.inject.Inject; -import javax.inject.Named; import java.util.Collections; import java.util.List; -@Named public class KafkaEventSink implements ProcessEventListener, ProcessLogListener, AuditLogListener { private static final Logger log = LoggerFactory.getLogger(KafkaEventSink.class); diff --git a/server/plugins/kafka-event-sink/src/main/java/com/walmartlabs/concord/server/plugins/eventsink/kafka/KafkaEventSinkConfiguration.java b/server/plugins/kafka-event-sink/src/main/java/com/walmartlabs/concord/server/plugins/eventsink/kafka/KafkaEventSinkConfiguration.java index b47f6cfaa8..45795101de 100644 --- a/server/plugins/kafka-event-sink/src/main/java/com/walmartlabs/concord/server/plugins/eventsink/kafka/KafkaEventSinkConfiguration.java +++ b/server/plugins/kafka-event-sink/src/main/java/com/walmartlabs/concord/server/plugins/eventsink/kafka/KafkaEventSinkConfiguration.java @@ -24,10 +24,8 @@ import javax.annotation.Nullable; import javax.inject.Inject; -import javax.inject.Named; import java.io.Serializable; -@Named public class KafkaEventSinkConfiguration implements Serializable { private static final long serialVersionUID = 1L; diff --git a/server/plugins/kafka-event-sink/src/main/java/com/walmartlabs/concord/server/plugins/eventsink/kafka/KafkaModule.java b/server/plugins/kafka-event-sink/src/main/java/com/walmartlabs/concord/server/plugins/eventsink/kafka/KafkaModule.java new file mode 100644 index 0000000000..29d25563d8 --- /dev/null +++ b/server/plugins/kafka-event-sink/src/main/java/com/walmartlabs/concord/server/plugins/eventsink/kafka/KafkaModule.java @@ -0,0 +1,50 @@ +package com.walmartlabs.concord.server.plugins.eventsink.kafka; + +/*- + * ***** + * Concord + * ----- + * Copyright (C) 2017 - 2023 Walmart 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. + * ===== + */ + +import com.google.inject.Binder; +import com.google.inject.Module; +import com.walmartlabs.concord.server.sdk.BackgroundTask; +import com.walmartlabs.concord.server.sdk.audit.AuditLogListener; +import com.walmartlabs.concord.server.sdk.events.ProcessEventListener; +import com.walmartlabs.concord.server.sdk.log.ProcessLogListener; + +import javax.inject.Named; + +import static com.google.inject.Scopes.SINGLETON; +import static com.google.inject.multibindings.Multibinder.newSetBinder; + +@Named +public class KafkaModule implements Module { + + @Override + public void configure(Binder binder) { + binder.bind(KafkaEventSinkConfiguration.class).in(SINGLETON); + + binder.bind(KafkaEventSink.class).in(SINGLETON); + newSetBinder(binder, ProcessEventListener.class).addBinding().to(KafkaEventSink.class); + newSetBinder(binder, ProcessLogListener.class).addBinding().to(KafkaEventSink.class); + newSetBinder(binder, AuditLogListener.class).addBinding().to(KafkaEventSink.class); + + binder.bind(KafkaConnector.class).in(SINGLETON); + newSetBinder(binder, BackgroundTask.class).addBinding().to(KafkaConnector.class); + } +} diff --git a/server/plugins/noderoster/client/pom.xml b/server/plugins/noderoster/client/pom.xml index 0f2be8ccc5..5279f58bb2 100644 --- a/server/plugins/noderoster/client/pom.xml +++ b/server/plugins/noderoster/client/pom.xml @@ -6,7 +6,7 @@ com.walmartlabs.concord.server.plugins.noderoster parent - 2.1.1-SNAPSHOT + 2.5.1-SNAPSHOT ../pom.xml diff --git a/server/plugins/noderoster/client2/pom.xml b/server/plugins/noderoster/client2/pom.xml index 051c0e2061..0553c1222b 100644 --- a/server/plugins/noderoster/client2/pom.xml +++ b/server/plugins/noderoster/client2/pom.xml @@ -6,7 +6,7 @@ com.walmartlabs.concord.server.plugins.noderoster parent - 2.1.1-SNAPSHOT + 2.5.1-SNAPSHOT ../pom.xml diff --git a/server/plugins/noderoster/db/pom.xml b/server/plugins/noderoster/db/pom.xml index 69dffd73d2..7a29e597da 100644 --- a/server/plugins/noderoster/db/pom.xml +++ b/server/plugins/noderoster/db/pom.xml @@ -6,7 +6,7 @@ com.walmartlabs.concord.server.plugins.noderoster parent - 2.1.1-SNAPSHOT + 2.5.1-SNAPSHOT ../pom.xml diff --git a/server/plugins/noderoster/impl/pom.xml b/server/plugins/noderoster/impl/pom.xml index 0086e06800..31bb244596 100644 --- a/server/plugins/noderoster/impl/pom.xml +++ b/server/plugins/noderoster/impl/pom.xml @@ -6,7 +6,7 @@ com.walmartlabs.concord.server.plugins.noderoster parent - 2.1.1-SNAPSHOT + 2.5.1-SNAPSHOT ../pom.xml diff --git a/server/plugins/noderoster/pom.xml b/server/plugins/noderoster/pom.xml index f3ff9482ff..bc53d6cca7 100644 --- a/server/plugins/noderoster/pom.xml +++ b/server/plugins/noderoster/pom.xml @@ -6,7 +6,7 @@ com.walmartlabs.concord.server.plugins parent - 2.1.1-SNAPSHOT + 2.5.1-SNAPSHOT ../pom.xml diff --git a/server/plugins/oidc/pom.xml b/server/plugins/oidc/pom.xml index 9eaa2df207..e831a7e74f 100644 --- a/server/plugins/oidc/pom.xml +++ b/server/plugins/oidc/pom.xml @@ -5,7 +5,7 @@ com.walmartlabs.concord.server.plugins parent - 2.1.1-SNAPSHOT + 2.5.1-SNAPSHOT ../pom.xml diff --git a/server/plugins/oidc/src/main/java/com/walmartlabs/concord/server/plugins/oidc/OidcCallbackFilter.java b/server/plugins/oidc/src/main/java/com/walmartlabs/concord/server/plugins/oidc/OidcCallbackFilter.java index e529d7fc5d..6ffe4c7138 100644 --- a/server/plugins/oidc/src/main/java/com/walmartlabs/concord/server/plugins/oidc/OidcCallbackFilter.java +++ b/server/plugins/oidc/src/main/java/com/walmartlabs/concord/server/plugins/oidc/OidcCallbackFilter.java @@ -68,7 +68,7 @@ public void doFilter(ServletRequest request, ServletResponse response, FilterCha } CallbackLogic callback = pac4jConfig.getCallbackLogic(); - callback.perform(context, pac4jConfig, pac4jConfig.getHttpActionAdapter(), postLoginUrl, true, false, true, PluginModule.CLIENT_NAME); + callback.perform(context, pac4jConfig, pac4jConfig.getHttpActionAdapter(), postLoginUrl, true, false, true, OidcPluginModule.CLIENT_NAME); } @Override diff --git a/server/plugins/oidc/src/main/java/com/walmartlabs/concord/server/plugins/oidc/PluginModule.java b/server/plugins/oidc/src/main/java/com/walmartlabs/concord/server/plugins/oidc/OidcPluginModule.java similarity index 98% rename from server/plugins/oidc/src/main/java/com/walmartlabs/concord/server/plugins/oidc/PluginModule.java rename to server/plugins/oidc/src/main/java/com/walmartlabs/concord/server/plugins/oidc/OidcPluginModule.java index 1e2262785e..bc4b48b418 100644 --- a/server/plugins/oidc/src/main/java/com/walmartlabs/concord/server/plugins/oidc/PluginModule.java +++ b/server/plugins/oidc/src/main/java/com/walmartlabs/concord/server/plugins/oidc/OidcPluginModule.java @@ -41,7 +41,7 @@ import static com.google.inject.multibindings.Multibinder.newSetBinder; @Named -public class PluginModule extends AbstractModule { +public class OidcPluginModule extends AbstractModule { public static final String CLIENT_NAME = "oidc"; diff --git a/server/plugins/oneops/pom.xml b/server/plugins/oneops/pom.xml index 045d5c934a..7b0c1118a7 100644 --- a/server/plugins/oneops/pom.xml +++ b/server/plugins/oneops/pom.xml @@ -5,7 +5,7 @@ com.walmartlabs.concord.server.plugins parent - 2.1.1-SNAPSHOT + 2.5.1-SNAPSHOT ../pom.xml diff --git a/server/plugins/pfed-sso/pom.xml b/server/plugins/pfed-sso/pom.xml index acca108b90..ba42ce55d3 100644 --- a/server/plugins/pfed-sso/pom.xml +++ b/server/plugins/pfed-sso/pom.xml @@ -3,7 +3,7 @@ parent com.walmartlabs.concord.server.plugins - 2.1.1-SNAPSHOT + 2.5.1-SNAPSHOT 4.0.0 diff --git a/server/plugins/pom.xml b/server/plugins/pom.xml index 9e37a31038..7d09afe32d 100644 --- a/server/plugins/pom.xml +++ b/server/plugins/pom.xml @@ -5,7 +5,7 @@ com.walmartlabs.concord.server parent - 2.1.1-SNAPSHOT + 2.5.1-SNAPSHOT ../pom.xml diff --git a/server/pom.xml b/server/pom.xml index cc12484f5d..570f6722db 100644 --- a/server/pom.xml +++ b/server/pom.xml @@ -6,7 +6,7 @@ com.walmartlabs.concord parent - 2.1.1-SNAPSHOT + 2.5.1-SNAPSHOT ../pom.xml diff --git a/server/queue-client/pom.xml b/server/queue-client/pom.xml index b4bd7887e3..8f3989ec4f 100644 --- a/server/queue-client/pom.xml +++ b/server/queue-client/pom.xml @@ -6,7 +6,7 @@ com.walmartlabs.concord.server parent - 2.1.1-SNAPSHOT + 2.5.1-SNAPSHOT ../pom.xml diff --git a/server/sdk/pom.xml b/server/sdk/pom.xml index aa8a97e38e..f6ab8f8dc7 100644 --- a/server/sdk/pom.xml +++ b/server/sdk/pom.xml @@ -6,7 +6,7 @@ com.walmartlabs.concord.server parent - 2.1.1-SNAPSHOT + 2.5.1-SNAPSHOT ../pom.xml diff --git a/targetplatform/pom.xml b/targetplatform/pom.xml index 9c2fc07791..f3906c542c 100644 --- a/targetplatform/pom.xml +++ b/targetplatform/pom.xml @@ -5,7 +5,7 @@ com.walmartlabs.concord concord-targetplatform - 2.1.1-SNAPSHOT + 2.5.1-SNAPSHOT pom @@ -1179,6 +1179,11 @@ testcontainers ${testcontainers.version} + + org.testcontainers + postgresql + ${testcontainers.version} + uk.org.lidalia sysout-over-slf4j