From 5bfc1577ba495aa38007a24ce6333fcc213ade0b Mon Sep 17 00:00:00 2001 From: buildmaster Date: Sat, 17 Jun 2023 00:27:07 +0000 Subject: [PATCH 1/3] Bumping versions --- docs/src/main/asciidoc/_configprops.adoc | 2 +- .../client/ConfigServerConfigDataLoader.java | 3 +- .../ConfigServerConfigDataLoaderTests.java | 47 ++++++++++--------- .../server/support/HttpClientSupportTest.java | 6 +-- 4 files changed, 31 insertions(+), 27 deletions(-) diff --git a/docs/src/main/asciidoc/_configprops.adoc b/docs/src/main/asciidoc/_configprops.adoc index a90f6e31..d1d39071 100644 --- a/docs/src/main/asciidoc/_configprops.adoc +++ b/docs/src/main/asciidoc/_configprops.adoc @@ -8,7 +8,7 @@ |spring.cloud.config.fail-fast | `+++false+++` | Flag to indicate that failure to connect to the server is fatal (default false). |spring.cloud.config.headers | | Additional headers used to create the client request. |spring.cloud.config.initialize-on-context-refresh | `+++false+++` | Flag to initialize bootstrap configuration on context refresh event. Default false. -|spring.cloud.config.label | | The label name to use to pull remote configuration properties. The default is set on the server (generally "master" for a git based server). +|spring.cloud.config.label | | The label name to use to pull remote configuration properties. The default is set on the server (generally "main" for a git based server). |spring.cloud.config.media-type | | The Accept header media type to send to config server. |spring.cloud.config.name | | Name of application used to fetch remote properties. |spring.cloud.config.override-none | `+++false+++` | Flag to indicate that when {@link #setAllowOverride(boolean) allowOverride} is true, external properties should take lowest priority and should not override any existing property sources (including local config files). Default false. diff --git a/spring-cloud-config-client/src/main/java/org/springframework/cloud/config/client/ConfigServerConfigDataLoader.java b/spring-cloud-config-client/src/main/java/org/springframework/cloud/config/client/ConfigServerConfigDataLoader.java index db163bed..c1430c73 100644 --- a/spring-cloud-config-client/src/main/java/org/springframework/cloud/config/client/ConfigServerConfigDataLoader.java +++ b/spring-cloud-config-client/src/main/java/org/springframework/cloud/config/client/ConfigServerConfigDataLoader.java @@ -165,7 +165,8 @@ public class ConfigServerConfigDataLoader implements ConfigDataLoader activatesOnProfileCamelCase = new HashMap<>(); activatesOnProfileCamelCase.put("spring.config.activate.onProfile", "foo"); PropertySource p5 = new PropertySource( - "configserver:git@github.com:demo/support-configuration-repo.git/Config resource 'file [/var/folders/k3/zv8hzdm17vv69j485fv3cf9r0000gp/T/config-repo-14772121892716396795/commons/application.properties' via location 'commons/' (document #1)", - activatesOnProfileCamelCase); + "configserver:git@github.com:demo/support-configuration-repo.git/Config resource 'file [/var/folders/k3/zv8hzdm17vv69j485fv3cf9r0000gp/T/config-repo-14772121892716396795/commons/application.properties' via location 'commons/' (document #1)", + activatesOnProfileCamelCase); Map activatesOnProfile = new HashMap<>(); activatesOnProfile.put("spring.config.activate.on-profile", "foo"); PropertySource p6 = new PropertySource( - "configserver:git@github.com:demo/support-configuration-repo.git/Config resource 'file [/var/folders/k3/zv8hzdm17vv69j485fv3cf9r0000gp/T/config-repo-14772121892716396795/commons/application.properties' via location 'commons/' (document #2)", - activatesOnProfile); + "configserver:git@github.com:demo/support-configuration-repo.git/Config resource 'file [/var/folders/k3/zv8hzdm17vv69j485fv3cf9r0000gp/T/config-repo-14772121892716396795/commons/application.properties' via location 'commons/' (document #2)", + activatesOnProfile); PropertySource p7 = new PropertySource( - "configserver:git@github.com:demo/support-configuration-repo.git/application-foo.yaml", - Collections.singletonMap("hello", "world")); + "configserver:git@github.com:demo/support-configuration-repo.git/application-foo.yaml", + Collections.singletonMap("hello", "world")); PropertySource p8 = new PropertySource( - "configserver:git@github.com:demo/support-configuration-repo.git/Config resource 'file [/var/folders/k3/zv8hzdm17vv69j485fv3cf9r0000gp/T/config-repo-14772121892716396795/commons/application-foo.yaml' via location 'commons/' (document #0)", - Collections.singletonMap("hello", "world")); + "configserver:git@github.com:demo/support-configuration-repo.git/Config resource 'file [/var/folders/k3/zv8hzdm17vv69j485fv3cf9r0000gp/T/config-repo-14772121892716396795/commons/application-foo.yaml' via location 'commons/' (document #0)", + Collections.singletonMap("hello", "world")); PropertySource p9 = new PropertySource( - "configserver:git@github.com:demo/support-configuration-repo.git/Config resource 'file [/var/folders/k3/zv8hzdm17vv69j485fv3cf9r0000gp/T/config-repo-14772121892716396795/commons/application-foo.yaml' via location 'commons/' (document #1)", - Collections.singletonMap("hello", "world")); + "configserver:git@github.com:demo/support-configuration-repo.git/Config resource 'file [/var/folders/k3/zv8hzdm17vv69j485fv3cf9r0000gp/T/config-repo-14772121892716396795/commons/application-foo.yaml' via location 'commons/' (document #1)", + Collections.singletonMap("hello", "world")); ConfigData configData = setupConfigServerConfigDataLoader(Arrays.asList(p1, p2, p3, p4, p5, p6, p7, p8, p9), - "application-slash", "foo"); + "application-slash", "foo"); assertThat(configData.getPropertySources().size()).isEqualTo(7); } diff --git a/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/support/HttpClientSupportTest.java b/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/support/HttpClientSupportTest.java index 41110e3f..1050c953 100644 --- a/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/support/HttpClientSupportTest.java +++ b/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/support/HttpClientSupportTest.java @@ -50,7 +50,7 @@ import static com.github.tomakehurst.wiremock.client.WireMock.verify; import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.options; @SpringBootTest(classes = HttpClientSupportTest.TestConfiguration.class, - webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) + webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) public class HttpClientSupportTest { @LocalServerPort @@ -71,7 +71,7 @@ public class HttpClientSupportTest { @EnabledOnJre(JRE.JAVA_8) public void httpsProxy() throws GeneralSecurityException, IOException { WireMockServer wireMockProxyServer = new WireMockServer( - options().httpDisabled(true).dynamicHttpsPort().enableBrowserProxying(true).trustAllProxyTargets(true)); + options().httpDisabled(true).dynamicHttpsPort().enableBrowserProxying(true).trustAllProxyTargets(true)); WireMockServer wireMockServer = new WireMockServer(options().httpDisabled(true).dynamicHttpsPort()); wireMockProxyServer.start(); wireMockServer.start(); @@ -91,7 +91,7 @@ public class HttpClientSupportTest { try { httpClient = HttpClientSupport.builder(properties).build(); response = httpClient - .execute(new HttpGet("https://localhost:" + wireMockServer.httpsPort() + "/test/proxy")); + .execute(new HttpGet("https://localhost:" + wireMockServer.httpsPort() + "/test/proxy")); } finally { if (response != null) { From 5c259443e146bfd0a53f927c777497974f1ac889 Mon Sep 17 00:00:00 2001 From: spencergibb Date: Tue, 27 Jun 2023 16:24:34 -0400 Subject: [PATCH 2/3] Specifies vault version in testcontainers --- .../java/sample/ConfigDataOrderingVaultIntegrationTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-cloud-config-sample/src/test/java/sample/ConfigDataOrderingVaultIntegrationTests.java b/spring-cloud-config-sample/src/test/java/sample/ConfigDataOrderingVaultIntegrationTests.java index 7475333c..4e5cfa6b 100644 --- a/spring-cloud-config-sample/src/test/java/sample/ConfigDataOrderingVaultIntegrationTests.java +++ b/spring-cloud-config-sample/src/test/java/sample/ConfigDataOrderingVaultIntegrationTests.java @@ -53,7 +53,7 @@ public class ConfigDataOrderingVaultIntegrationTests { private static ConfigurableApplicationContext server; @Container - public static VaultContainer vaultContainer = new VaultContainer<>(DockerImageName.parse("vault")) + public static VaultContainer vaultContainer = new VaultContainer<>(DockerImageName.parse("vault:1.13.3")) .withVaultToken("my-root-token").withClasspathResourceMapping("vaultordering/vault_test_policy.txt", "/tmp/vault_test_policy.txt", BindMode.READ_ONLY); From 8e090b971338899ae2b1efb51c3fff7d7a8bd61f Mon Sep 17 00:00:00 2001 From: Ryan Baxter <524254+ryanjbaxter@users.noreply.github.com> Date: Tue, 27 Jun 2023 19:39:06 -0400 Subject: [PATCH 3/3] Add documentation on additional request in config data flow. Fixes #2301 --- docs/src/main/asciidoc/spring-cloud-config.adoc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/docs/src/main/asciidoc/spring-cloud-config.adoc b/docs/src/main/asciidoc/spring-cloud-config.adoc index 8d2c3c48..1a50906c 100644 --- a/docs/src/main/asciidoc/spring-cloud-config.adoc +++ b/docs/src/main/asciidoc/spring-cloud-config.adoc @@ -1780,6 +1780,15 @@ spring.config.import=optional:configserver: This will connect to the Config Server at the default location of "http://localhost:8888". Removing the `optional:` prefix will cause the Config Client to fail if it is unable to connect to Config Server. To change the location of Config Server either set `spring.cloud.config.uri` or add the url to the `spring.config.import` statement such as, `spring.config.import=optional:configserver:http://myhost:8888`. The location in the import property has precedence over the uri property. +Spring Boot Config Data resolves configuration in a two step process. First it loads all configuration using the `default` +profile. This allows Spring Boot to gather all configuration which may activate any additional profiles. +After it has gathered all activated profiles it will load any additional configuration for the active profiles. +Due to this you may see multiple requests being made to the Spring Cloud Config Server to fetch configuration. This +is normal and is a side effect of how Spring Boot loads configuration when using `spring.config.import`. In previous +versions of Spring Cloud Config there was only a single request made but this meant you could not activate profiles +from configuration coming from the Config Server. The additional request with just the 'default` profile now makes +this possible. + NOTE: A `bootstrap` file (properties or yaml) is *not* needed for the Spring Boot Config Data method of import via `spring.config.import`. [[config-first-bootstrap]]