Skip to content

Commit 0890fd8

Browse files
committed
Merge branch 'main' into move-to-a-common-configuration-for-health
2 parents 9a937b6 + f342faf commit 0890fd8

File tree

100 files changed

+1188
-1613
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+1188
-1613
lines changed

docs/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"dependencies": {
33
"antora": "3.2.0-alpha.6",
44
"@antora/atlas-extension": "1.0.0-alpha.2",
5-
"@antora/collector-extension": "1.0.0-beta.5",
5+
"@antora/collector-extension": "1.0.1",
66
"@asciidoctor/tabs": "1.0.0-beta.6",
77
"@springio/antora-extensions": "1.14.2",
88
"@springio/asciidoctor-extensions": "1.0.0-alpha.14"

docs/pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<parent>
99
<groupId>org.springframework.cloud</groupId>
1010
<artifactId>spring-cloud-kubernetes</artifactId>
11-
<version>3.2.0-SNAPSHOT</version>
11+
<version>3.2.1-SNAPSHOT</version>
1212
<relativePath>..</relativePath>
1313
</parent>
1414
<packaging>jar</packaging>
@@ -21,7 +21,7 @@
2121
<!-- Don't upload docs jar to central / repo.spring.io -->
2222
<maven-deploy-plugin-default.phase>none</maven-deploy-plugin-default.phase>
2323
</properties>
24-
<dependencies>
24+
<!-- <dependencies>
2525
<dependency>
2626
<groupId>${project.groupId}</groupId>
2727
<artifactId>spring-cloud-starter-kubernetes-fabric8</artifactId>
@@ -34,7 +34,7 @@
3434
<groupId>${project.groupId}</groupId>
3535
<artifactId>spring-cloud-starter-kubernetes-fabric8-config</artifactId>
3636
</dependency>
37-
</dependencies>
37+
</dependencies> -->
3838
<build>
3939
<sourceDirectory>src/main/asciidoc</sourceDirectory>
4040
</build>

pom.xml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@
2525
<parent>
2626
<groupId>org.springframework.cloud</groupId>
2727
<artifactId>spring-cloud-build</artifactId>
28-
<version>4.2.0-SNAPSHOT</version>
28+
<version>4.2.1-SNAPSHOT</version>
2929
<relativePath/>
3030
</parent>
3131

3232
<artifactId>spring-cloud-kubernetes</artifactId>
33-
<version>3.2.0-SNAPSHOT</version>
33+
<version>3.2.1-SNAPSHOT</version>
3434
<packaging>pom</packaging>
3535
<name>Spring Cloud Kubernetes</name>
3636

@@ -70,10 +70,10 @@
7070
<failsafe-reports-directory>failsafe-reports</failsafe-reports-directory>
7171
<!-- Dependency Versions -->
7272
<mockito-inline.version>4.8.1</mockito-inline.version>
73-
<spring-cloud-commons.version>4.2.0-SNAPSHOT</spring-cloud-commons.version>
74-
<spring-cloud-config.version>4.2.0-SNAPSHOT</spring-cloud-config.version>
75-
<spring-cloud-bus.version>4.2.0-SNAPSHOT</spring-cloud-bus.version>
76-
<spring-cloud-contract.version>4.2.0-SNAPSHOT</spring-cloud-contract.version>
73+
<spring-cloud-commons.version>4.2.1-SNAPSHOT</spring-cloud-commons.version>
74+
<spring-cloud-config.version>4.2.1-SNAPSHOT</spring-cloud-config.version>
75+
<spring-cloud-bus.version>4.2.1-SNAPSHOT</spring-cloud-bus.version>
76+
<spring-cloud-contract.version>4.2.1-SNAPSHOT</spring-cloud-contract.version>
7777

7878
<maven-checkstyle-plugin.failsOnError>true</maven-checkstyle-plugin.failsOnError>
7979
<maven-checkstyle-plugin.failsOnViolation>true

spring-cloud-kubernetes-client-autoconfig/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>spring-cloud-kubernetes</artifactId>
77
<groupId>org.springframework.cloud</groupId>
8-
<version>3.2.0-SNAPSHOT</version>
8+
<version>3.2.1-SNAPSHOT</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

spring-cloud-kubernetes-client-config/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>spring-cloud-kubernetes</artifactId>
77
<groupId>org.springframework.cloud</groupId>
8-
<version>3.2.0-SNAPSHOT</version>
8+
<version>3.2.1-SNAPSHOT</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

spring-cloud-kubernetes-client-config/src/test/java/org/springframework/cloud/kubernetes/client/config/KubernetesClientConfigMapErrorOnReadingSourceTests.java

Lines changed: 27 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,8 @@
3939
import org.springframework.boot.test.system.OutputCaptureExtension;
4040
import org.springframework.cloud.kubernetes.commons.KubernetesNamespaceProvider;
4141
import org.springframework.cloud.kubernetes.commons.config.ConfigMapConfigProperties;
42-
import org.springframework.cloud.kubernetes.commons.config.Constants;
4342
import org.springframework.cloud.kubernetes.commons.config.RetryProperties;
4443
import org.springframework.core.env.CompositePropertySource;
45-
import org.springframework.core.env.MapPropertySource;
4644
import org.springframework.core.env.PropertySource;
4745
import org.springframework.mock.env.MockEnvironment;
4846

@@ -100,12 +98,11 @@ public void afterEach() {
10098

10199
/**
102100
* <pre>
103-
* we try to read all config maps in a namespace and fail,
104-
* thus generate a well defined name for the source.
101+
* we try to read all config maps in a namespace and fail.
105102
* </pre>
106103
*/
107104
@Test
108-
void namedSingleConfigMapFails() {
105+
void namedSingleConfigMapFails(CapturedOutput output) {
109106
String name = "my-config";
110107
String namespace = "spring-k8s";
111108
String path = "/api/v1/namespaces/" + namespace + "/configmaps";
@@ -120,13 +117,10 @@ void namedSingleConfigMapFails() {
120117
configMapConfigProperties, new KubernetesNamespaceProvider(new MockEnvironment()));
121118

122119
CompositePropertySource propertySource = (CompositePropertySource) locator.locate(new MockEnvironment());
123-
MapPropertySource mapPropertySource = (MapPropertySource) propertySource.getPropertySources()
124-
.stream()
125-
.findAny()
126-
.orElseThrow();
127120

128-
assertThat(mapPropertySource.getName()).isEqualTo("configmap..spring-k8s");
129-
assertThat(propertySource.getProperty(Constants.ERROR_PROPERTY)).isEqualTo("true");
121+
assertThat(propertySource.getPropertySources()).isEmpty();
122+
assertThat(output.getOut()).contains("Failure in reading named sources");
123+
assertThat(output.getOut()).contains("Failed to load source: { config-map name : 'Optional[my-config]'");
130124

131125
}
132126

@@ -168,11 +162,12 @@ void namedTwoConfigMapsOneFails(CapturedOutput output) {
168162
CompositePropertySource propertySource = (CompositePropertySource) locator.locate(new MockEnvironment());
169163
List<String> names = propertySource.getPropertySources().stream().map(PropertySource::getName).toList();
170164

171-
// two sources are present, one being empty
172-
assertThat(names).containsExactly("configmap.two.default", "configmap..default");
173-
assertThat(propertySource.getProperty(Constants.ERROR_PROPERTY)).isEqualTo("true");
165+
// one property source is present
166+
assertThat(names).containsExactly("configmap.two.default");
174167
assertThat(output.getOut())
175168
.doesNotContain("sourceName : two was requested, but not found in namespace : default");
169+
assertThat(output.getOut()).contains("Failure in reading named sources");
170+
assertThat(output.getOut()).contains("Failed to load source: { config-map name : 'Optional[one]'");
176171

177172
}
178173

@@ -212,20 +207,19 @@ void namedTwoConfigMapsBothFail(CapturedOutput output) {
212207
configMapConfigProperties, new KubernetesNamespaceProvider(new MockEnvironment()));
213208

214209
CompositePropertySource propertySource = (CompositePropertySource) locator.locate(new MockEnvironment());
215-
List<String> names = propertySource.getPropertySources().stream().map(PropertySource::getName).toList();
216210

217-
assertThat(names).containsExactly("configmap..default");
218-
assertThat(propertySource.getProperty(Constants.ERROR_PROPERTY)).isEqualTo("true");
211+
assertThat(propertySource.getPropertySources()).isEmpty();
219212
assertThat(output.getOut())
220213
.doesNotContain("sourceName : one was requested, but not found in namespace : default");
221214
assertThat(output.getOut())
222215
.doesNotContain("sourceName : two was requested, but not found in namespace : default");
216+
assertThat(output.getOut()).contains("Failure in reading named sources");
217+
assertThat(output.getOut()).contains("Failed to load source: { config-map name : 'Optional[one]'");
223218
}
224219

225220
/**
226221
* <pre>
227-
* we try to read all config maps in a namespace and fail,
228-
* thus generate a well defined name for the source.
222+
* we try to read all config maps in a namespace and fail.
229223
* </pre>
230224
*/
231225
@Test
@@ -256,12 +250,11 @@ void labeledSingleConfigMapFails(CapturedOutput output) {
256250
configMapConfigProperties, new KubernetesNamespaceProvider(new MockEnvironment()));
257251

258252
CompositePropertySource propertySource = (CompositePropertySource) locator.locate(new MockEnvironment());
259-
List<String> sourceNames = propertySource.getPropertySources().stream().map(PropertySource::getName).toList();
260253

261-
assertThat(sourceNames).containsExactly("configmap..spring-k8s");
262-
assertThat(propertySource.getProperty(Constants.ERROR_PROPERTY)).isEqualTo("true");
263-
assertThat(output).contains("failure in reading labeled sources");
264-
assertThat(output).contains("failure in reading named sources");
254+
assertThat(propertySource.getPropertySources()).isEmpty();
255+
assertThat(output.getOut()).contains("Failure in reading labeled sources");
256+
assertThat(output.getOut()).contains("Failure in reading named sources");
257+
assertThat(output.getOut()).contains("Failed to load source: { config map labels : '{a=b}'");
265258
}
266259

267260
/**
@@ -311,12 +304,11 @@ void labeledTwoConfigMapsOneFails(CapturedOutput output) {
311304
CompositePropertySource propertySource = (CompositePropertySource) locator.locate(new MockEnvironment());
312305
List<String> names = propertySource.getPropertySources().stream().map(PropertySource::getName).toList();
313306

314-
// two sources are present, one being empty
315-
assertThat(names).containsExactly("configmap.two.default", "configmap..default");
316-
assertThat(propertySource.getProperty(Constants.ERROR_PROPERTY)).isEqualTo("true");
317-
318-
assertThat(output).contains("failure in reading labeled sources");
319-
assertThat(output).contains("failure in reading named sources");
307+
// one source is present
308+
assertThat(names).containsExactly("configmap.two.default");
309+
assertThat(output.getOut()).contains("Failure in reading labeled sources");
310+
assertThat(output.getOut()).contains("Failure in reading named sources");
311+
assertThat(output.getOut()).contains("Failed to load source: { config map labels : '{one=1}'");
320312

321313
}
322314

@@ -364,15 +356,12 @@ void labeledTwoConfigMapsBothFail(CapturedOutput output) {
364356
configMapConfigProperties, new KubernetesNamespaceProvider(new MockEnvironment()));
365357

366358
CompositePropertySource propertySource = (CompositePropertySource) locator.locate(new MockEnvironment());
367-
List<String> names = propertySource.getPropertySources().stream().map(PropertySource::getName).toList();
368-
369-
// all 3 sources ('application' named source, and two labeled sources)
370-
assertThat(names).containsExactly("configmap..default");
371-
assertThat(propertySource.getProperty(Constants.ERROR_PROPERTY)).isEqualTo("true");
372-
373-
assertThat(output).contains("failure in reading labeled sources");
374-
assertThat(output).contains("failure in reading named sources");
375359

360+
assertThat(propertySource.getPropertySources()).isEmpty();
361+
assertThat(output).contains("Failure in reading labeled sources");
362+
assertThat(output).contains("Failure in reading named sources");
363+
assertThat(output.getOut()).contains("Failed to load source: { config map labels : '{one=1}'");
364+
assertThat(output.getOut()).contains("Failed to load source: { config map labels : '{two=2}'");
376365
}
377366

378367
}

spring-cloud-kubernetes-client-config/src/test/java/org/springframework/cloud/kubernetes/client/config/KubernetesClientConfigMapPropertySourceLocatorTests.java

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package org.springframework.cloud.kubernetes.client.config;
1818

19+
import java.util.ArrayList;
1920
import java.util.Collections;
2021
import java.util.List;
2122
import java.util.Map;
@@ -34,12 +35,16 @@
3435
import org.junit.jupiter.api.AfterEach;
3536
import org.junit.jupiter.api.BeforeAll;
3637
import org.junit.jupiter.api.Test;
38+
import org.junit.jupiter.api.extension.ExtendWith;
3739

40+
import org.springframework.boot.test.system.CapturedOutput;
41+
import org.springframework.boot.test.system.OutputCaptureExtension;
3842
import org.springframework.cloud.kubernetes.commons.KubernetesNamespaceProvider;
3943
import org.springframework.cloud.kubernetes.commons.config.ConfigMapConfigProperties;
4044
import org.springframework.cloud.kubernetes.commons.config.Constants;
4145
import org.springframework.cloud.kubernetes.commons.config.NamespaceResolutionFailedException;
4246
import org.springframework.cloud.kubernetes.commons.config.RetryProperties;
47+
import org.springframework.core.env.CompositePropertySource;
4348
import org.springframework.core.env.PropertySource;
4449
import org.springframework.mock.env.MockEnvironment;
4550

@@ -55,6 +60,7 @@
5560
* @author Ryan Baxter
5661
* @author Isik Erhan
5762
*/
63+
@ExtendWith(OutputCaptureExtension.class)
5864
class KubernetesClientConfigMapPropertySourceLocatorTests {
5965

6066
private static final V1ConfigMapList PROPERTIES_CONFIGMAP_LIST = new V1ConfigMapList()
@@ -185,7 +191,7 @@ public void locateShouldThrowExceptionOnFailureWhenFailFastIsEnabled() {
185191
}
186192

187193
@Test
188-
public void locateShouldNotThrowExceptionOnFailureWhenFailFastIsDisabled() {
194+
public void locateShouldNotThrowExceptionOnFailureWhenFailFastIsDisabled(CapturedOutput output) {
189195
CoreV1Api api = new CoreV1Api();
190196
stubFor(get("/api/v1/namespaces/default/configmaps")
191197
.willReturn(aResponse().withStatus(500).withBody("Internal Server Error")));
@@ -196,7 +202,17 @@ public void locateShouldNotThrowExceptionOnFailureWhenFailFastIsDisabled() {
196202
KubernetesClientConfigMapPropertySourceLocator locator = new KubernetesClientConfigMapPropertySourceLocator(api,
197203
configMapConfigProperties, new KubernetesNamespaceProvider(new MockEnvironment()));
198204

199-
assertThatNoException().isThrownBy(() -> locator.locate(new MockEnvironment()));
205+
List<PropertySource<?>> result = new ArrayList<>();
206+
assertThatNoException().isThrownBy(() -> {
207+
PropertySource<?> source = locator.locate(new MockEnvironment());
208+
result.add(source);
209+
});
210+
211+
assertThat(result.get(0)).isInstanceOf(CompositePropertySource.class);
212+
CompositePropertySource composite = (CompositePropertySource) result.get(0);
213+
assertThat(composite.getPropertySources()).hasSize(0);
214+
assertThat(output.getOut()).contains("Failed to load source:");
215+
200216
}
201217

202218
}

spring-cloud-kubernetes-client-config/src/test/java/org/springframework/cloud/kubernetes/client/config/KubernetesClientSecretsPropertySourceLocatorTests.java

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package org.springframework.cloud.kubernetes.client.config;
1818

19+
import java.util.ArrayList;
1920
import java.util.Collections;
2021
import java.util.List;
2122
import java.util.Map;
@@ -30,11 +31,15 @@
3031
import org.junit.jupiter.api.AfterEach;
3132
import org.junit.jupiter.api.BeforeAll;
3233
import org.junit.jupiter.api.Test;
34+
import org.junit.jupiter.api.extension.ExtendWith;
3335

36+
import org.springframework.boot.test.system.CapturedOutput;
37+
import org.springframework.boot.test.system.OutputCaptureExtension;
3438
import org.springframework.cloud.kubernetes.commons.KubernetesNamespaceProvider;
3539
import org.springframework.cloud.kubernetes.commons.config.NamespaceResolutionFailedException;
3640
import org.springframework.cloud.kubernetes.commons.config.RetryProperties;
3741
import org.springframework.cloud.kubernetes.commons.config.SecretsConfigProperties;
42+
import org.springframework.core.env.CompositePropertySource;
3843
import org.springframework.core.env.PropertySource;
3944
import org.springframework.mock.env.MockEnvironment;
4045

@@ -50,6 +55,7 @@
5055
* @author Ryan Baxter
5156
* @author Isik Erhan
5257
*/
58+
@ExtendWith(OutputCaptureExtension.class)
5359
class KubernetesClientSecretsPropertySourceLocatorTests {
5460

5561
private static final String LIST_API = "/api/v1/namespaces/default/secrets";
@@ -200,7 +206,7 @@ void locateShouldThrowExceptionOnFailureWhenFailFastIsEnabled() {
200206
}
201207

202208
@Test
203-
void locateShouldNotThrowExceptionOnFailureWhenFailFastIsDisabled() {
209+
void locateShouldNotThrowExceptionOnFailureWhenFailFastIsDisabled(CapturedOutput output) {
204210
CoreV1Api api = new CoreV1Api();
205211
stubFor(get(LIST_API).willReturn(aResponse().withStatus(500).withBody("Internal Server Error")));
206212

@@ -210,7 +216,16 @@ void locateShouldNotThrowExceptionOnFailureWhenFailFastIsDisabled() {
210216
KubernetesClientSecretsPropertySourceLocator locator = new KubernetesClientSecretsPropertySourceLocator(api,
211217
new KubernetesNamespaceProvider(new MockEnvironment()), secretsConfigProperties);
212218

213-
assertThatNoException().isThrownBy(() -> locator.locate(new MockEnvironment()));
219+
List<PropertySource<?>> result = new ArrayList<>();
220+
assertThatNoException().isThrownBy(() -> {
221+
PropertySource<?> source = locator.locate(new MockEnvironment());
222+
result.add(source);
223+
});
224+
225+
assertThat(result.get(0)).isInstanceOf(CompositePropertySource.class);
226+
CompositePropertySource composite = (CompositePropertySource) result.get(0);
227+
assertThat(composite.getPropertySources()).hasSize(0);
228+
assertThat(output.getOut()).contains("Failed to load source:");
214229
}
215230

216231
}

spring-cloud-kubernetes-client-config/src/test/java/org/springframework/cloud/kubernetes/client/config/reload_it/EventReloadConfigMapTest.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,11 +154,10 @@ void test(CapturedOutput output) {
154154

155155
// we fail while reading 'configMapOne'
156156
Awaitility.await().atMost(Duration.ofSeconds(10)).pollInterval(Duration.ofSeconds(1)).until(() -> {
157-
boolean one = output.getOut().contains("failure in reading named sources");
158-
boolean two = output.getOut()
159-
.contains("there was an error while reading config maps/secrets, no reload will happen");
157+
boolean one = output.getOut().contains("Failure in reading named sources");
158+
boolean two = output.getOut().contains("Failed to load source");
160159
boolean three = output.getOut()
161-
.contains("reloadable condition was not satisfied, reload will not be triggered");
160+
.contains("Reloadable condition was not satisfied, reload will not be triggered");
162161
boolean updateStrategyNotCalled = !strategyCalled[0];
163162
return one && two && three && updateStrategyNotCalled;
164163
});

spring-cloud-kubernetes-client-config/src/test/java/org/springframework/cloud/kubernetes/client/config/reload_it/EventReloadSecretTest.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,11 +156,10 @@ void test(CapturedOutput output) {
156156

157157
// we fail while reading 'configMapOne'
158158
Awaitility.await().atMost(Duration.ofSeconds(10)).pollInterval(Duration.ofSeconds(1)).until(() -> {
159-
boolean one = output.getOut().contains("failure in reading named sources");
160-
boolean two = output.getOut()
161-
.contains("there was an error while reading config maps/secrets, no reload will happen");
159+
boolean one = output.getOut().contains("Failure in reading named sources");
160+
boolean two = output.getOut().contains("Failed to load source");
162161
boolean three = output.getOut()
163-
.contains("reloadable condition was not satisfied, reload will not be triggered");
162+
.contains("Reloadable condition was not satisfied, reload will not be triggered");
164163
boolean updateStrategyNotCalled = !strategyCalled[0];
165164
return one && two && three && updateStrategyNotCalled;
166165
});

0 commit comments

Comments
 (0)