From e3234845e95fa43dd8daab2079fc38d8a8b751ec Mon Sep 17 00:00:00 2001 From: Artem Vysochyn Date: Tue, 9 Mar 2021 21:35:17 +0200 Subject: [PATCH 1/6] Changed behavior in VaultConfigSource when vault returns 404 --- .../io/scalecube/config/vault/VaultConfigSource.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/config-vault/src/main/java/io/scalecube/config/vault/VaultConfigSource.java b/config-vault/src/main/java/io/scalecube/config/vault/VaultConfigSource.java index 011f3be..b89ff3d 100644 --- a/config-vault/src/main/java/io/scalecube/config/vault/VaultConfigSource.java +++ b/config-vault/src/main/java/io/scalecube/config/vault/VaultConfigSource.java @@ -2,11 +2,13 @@ import com.bettercloud.vault.EnvironmentLoader; import com.bettercloud.vault.VaultConfig; +import com.bettercloud.vault.VaultException; import com.bettercloud.vault.response.LogicalResponse; import io.scalecube.config.ConfigProperty; import io.scalecube.config.ConfigSourceNotAvailableException; import io.scalecube.config.source.ConfigSource; import io.scalecube.config.source.LoadedConfigProperty; +import io.scalecube.config.utils.ThrowableUtil; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -55,8 +57,14 @@ public Map loadConfig() { .map(LoadedConfigProperty.Builder::build) .collect(Collectors.toMap(LoadedConfigProperty::name, Function.identity())); result.putAll(pathProps); + } catch (VaultException e) { + if (e.getHttpStatusCode() == 404) { + LOGGER.warn("Unable to load config properties from: {}", path); + } else { + throw ThrowableUtil.propagate(e); + } } catch (Exception ex) { - LOGGER.warn("Unable to load config properties from {}", path, ex); + LOGGER.error("Unable to load config properties from: {}, cause:", path, ex); throw new ConfigSourceNotAvailableException(ex); } } From b1a45bf3ede4cae11d69938d598e49c65f4c1a9e Mon Sep 17 00:00:00 2001 From: Artem Vysochyn Date: Tue, 9 Mar 2021 21:41:53 +0200 Subject: [PATCH 2/6] Updated testcontainers --- config-vault/pom.xml | 10 +++++++++- .../java/io/scalecube/config/vault/VaultInstance.java | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/config-vault/pom.xml b/config-vault/pom.xml index 17bea9d..9f3487c 100644 --- a/config-vault/pom.xml +++ b/config-vault/pom.xml @@ -13,7 +13,9 @@ 2.13.3 5.1.0 - 1.12.3 + 1.15.2 + + 5.5.0 @@ -33,6 +35,12 @@ ${testcontainers.version} test + + net.java.dev.jna + jna + ${jna.version} + test + org.apache.logging.log4j log4j-slf4j-impl diff --git a/config-vault/src/test/java/io/scalecube/config/vault/VaultInstance.java b/config-vault/src/test/java/io/scalecube/config/vault/VaultInstance.java index 4396c10..cafc10c 100644 --- a/config-vault/src/test/java/io/scalecube/config/vault/VaultInstance.java +++ b/config-vault/src/test/java/io/scalecube/config/vault/VaultInstance.java @@ -32,7 +32,7 @@ public class VaultInstance implements AutoCloseable { private static final Logger LOGGER = LoggerFactory.getLogger(VaultInstance.class); - private static final String VAULT_IMAGE_NAME = "vault:1.2.3"; + private static final String VAULT_IMAGE_NAME = "vault:1.6.1"; private static final int VAULT_PORT = 8200; private static final AtomicInteger PORT_COUNTER = new AtomicInteger(VAULT_PORT); private static final String UNSEAL_KEY_LOG = "Unseal Key: "; From fef904621eb989fe40d06c3e360f5b4159cc66d7 Mon Sep 17 00:00:00 2001 From: Artem Vysochyn Date: Tue, 9 Mar 2021 21:49:01 +0200 Subject: [PATCH 3/6] Updated testcontainers --- config-vault/pom.xml | 8 -------- pom.xml | 8 ++++++++ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/config-vault/pom.xml b/config-vault/pom.xml index 9f3487c..900d607 100644 --- a/config-vault/pom.xml +++ b/config-vault/pom.xml @@ -14,8 +14,6 @@ 2.13.3 5.1.0 1.15.2 - - 5.5.0 @@ -35,12 +33,6 @@ ${testcontainers.version} test - - net.java.dev.jna - jna - ${jna.version} - test - org.apache.logging.log4j log4j-slf4j-impl diff --git a/pom.xml b/pom.xml index 5dce1e6..2ea7f01 100644 --- a/pom.xml +++ b/pom.xml @@ -53,6 +53,8 @@ 2.27.0 5.1.1 1.3 + + 5.5.0 @@ -142,6 +144,12 @@ ${hamcrest.version} test + + net.java.dev.jna + jna + ${jna.version} + test + From 6d76609cb8311ab04cb49ee2531f2595d7297e5b Mon Sep 17 00:00:00 2001 From: Artem Vysochyn Date: Tue, 9 Mar 2021 21:55:32 +0200 Subject: [PATCH 4/6] Fixed dependencies --- config-vault/pom.xml | 17 +++-------------- config/pom.xml | 16 +++------------- pom.xml | 23 +++++++++++++++++++---- 3 files changed, 25 insertions(+), 31 deletions(-) diff --git a/config-vault/pom.xml b/config-vault/pom.xml index 900d607..f3417e8 100644 --- a/config-vault/pom.xml +++ b/config-vault/pom.xml @@ -1,5 +1,7 @@ - + 4.0.0 @@ -11,7 +13,6 @@ config-vault - 2.13.3 5.1.0 1.15.2 @@ -33,17 +34,5 @@ ${testcontainers.version} test - - org.apache.logging.log4j - log4j-slf4j-impl - ${log4j.version} - test - - - org.apache.logging.log4j - log4j-core - ${log4j.version} - test - diff --git a/config/pom.xml b/config/pom.xml index 6d56fea..d6f0207 100644 --- a/config/pom.xml +++ b/config/pom.xml @@ -1,5 +1,7 @@ - + io.scalecube @@ -21,18 +23,6 @@ - - org.apache.logging.log4j - log4j-slf4j-impl - ${log4j.version} - test - - - org.apache.logging.log4j - log4j-core - ${log4j.version} - test - com.fasterxml.jackson.datatype jackson-datatype-jdk8 diff --git a/pom.xml b/pom.xml index 2ea7f01..7df9ac4 100644 --- a/pom.xml +++ b/pom.xml @@ -1,5 +1,7 @@ - + 4.0.0 @@ -50,6 +52,7 @@ 2.26-b09 2.6 + 2.13.3 2.27.0 5.1.1 1.3 @@ -109,6 +112,12 @@ commons-io ${commons-io.version} + + net.java.dev.jna + jna + ${jna.version} + test + @@ -145,9 +154,15 @@ test - net.java.dev.jna - jna - ${jna.version} + org.apache.logging.log4j + log4j-slf4j-impl + ${log4j.version} + test + + + org.apache.logging.log4j + log4j-core + ${log4j.version} test From befcf948e67dc66c8cc150b6ee23f21990586715 Mon Sep 17 00:00:00 2001 From: Artem Vysochyn Date: Tue, 9 Mar 2021 22:03:47 +0200 Subject: [PATCH 5/6] Fixed CI --- .../java/io/scalecube/config/vault/VaultConfigSource.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/config-vault/src/main/java/io/scalecube/config/vault/VaultConfigSource.java b/config-vault/src/main/java/io/scalecube/config/vault/VaultConfigSource.java index b89ff3d..c4524eb 100644 --- a/config-vault/src/main/java/io/scalecube/config/vault/VaultConfigSource.java +++ b/config-vault/src/main/java/io/scalecube/config/vault/VaultConfigSource.java @@ -8,7 +8,6 @@ import io.scalecube.config.ConfigSourceNotAvailableException; import io.scalecube.config.source.ConfigSource; import io.scalecube.config.source.LoadedConfigProperty; -import io.scalecube.config.utils.ThrowableUtil; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -57,11 +56,11 @@ public Map loadConfig() { .map(LoadedConfigProperty.Builder::build) .collect(Collectors.toMap(LoadedConfigProperty::name, Function.identity())); result.putAll(pathProps); - } catch (VaultException e) { - if (e.getHttpStatusCode() == 404) { + } catch (VaultException ex) { + if (ex.getHttpStatusCode() == 404) { LOGGER.warn("Unable to load config properties from: {}", path); } else { - throw ThrowableUtil.propagate(e); + throw new ConfigSourceNotAvailableException(ex); } } catch (Exception ex) { LOGGER.error("Unable to load config properties from: {}, cause:", path, ex); From ee41e57a5e6345872888fe563fef64228a659997 Mon Sep 17 00:00:00 2001 From: Artem Vysochyn Date: Tue, 9 Mar 2021 22:17:24 +0200 Subject: [PATCH 6/6] Fixed CI (one more time) --- .../config/vault/VaultConfigSourceTest.java | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/config-vault/src/test/java/io/scalecube/config/vault/VaultConfigSourceTest.java b/config-vault/src/test/java/io/scalecube/config/vault/VaultConfigSourceTest.java index c4a56f5..2d16cd8 100644 --- a/config-vault/src/test/java/io/scalecube/config/vault/VaultConfigSourceTest.java +++ b/config-vault/src/test/java/io/scalecube/config/vault/VaultConfigSourceTest.java @@ -135,14 +135,11 @@ void testMissingProperty() { @Test void testMissingTenant() { - VaultConfigSource vaultConfigSource = - VaultConfigSource.builder() - .config(c -> c.token(vaultContainerExtension.vaultInstance().rootToken())) - .config(c -> c.address(vaultContainerExtension.vaultInstance().address())) - .addSecretsPath("secrets/unknown/path") - .build(); - - assertThrows(ConfigSourceNotAvailableException.class, vaultConfigSource::loadConfig); + VaultConfigSource.builder() + .config(c -> c.token(vaultContainerExtension.vaultInstance().rootToken())) + .config(c -> c.address(vaultContainerExtension.vaultInstance().address())) + .addSecretsPath("secrets/unknown/path") + .build(); } @Test