Skip to content

Commit 3bb9594

Browse files
committed
merge main
2 parents 8048d49 + 258247f commit 3bb9594

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

@@ -102,12 +100,11 @@ public void afterEach() {
102100

103101
/**
104102
* <pre>
105-
* we try to read all config maps in a namespace and fail,
106-
* thus generate a well defined name for the source.
103+
* we try to read all config maps in a namespace and fail.
107104
* </pre>
108105
*/
109106
@Test
110-
void namedSingleConfigMapFails() {
107+
void namedSingleConfigMapFails(CapturedOutput output) {
111108
String name = "my-config";
112109
String namespace = "spring-k8s";
113110
String path = "/api/v1/namespaces/" + namespace + "/configmaps";
@@ -122,13 +119,10 @@ void namedSingleConfigMapFails() {
122119
configMapConfigProperties, new KubernetesNamespaceProvider(new MockEnvironment()));
123120

124121
CompositePropertySource propertySource = (CompositePropertySource) locator.locate(new MockEnvironment());
125-
MapPropertySource mapPropertySource = (MapPropertySource) propertySource.getPropertySources()
126-
.stream()
127-
.findAny()
128-
.orElseThrow();
129122

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

133127
}
134128

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

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

179174
}
180175

@@ -214,20 +209,19 @@ void namedTwoConfigMapsBothFail(CapturedOutput output) {
214209
configMapConfigProperties, new KubernetesNamespaceProvider(new MockEnvironment()));
215210

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

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

227222
/**
228223
* <pre>
229-
* we try to read all config maps in a namespace and fail,
230-
* thus generate a well defined name for the source.
224+
* we try to read all config maps in a namespace and fail.
231225
* </pre>
232226
*/
233227
@Test
@@ -259,12 +253,11 @@ void labeledSingleConfigMapFails(CapturedOutput output) {
259253
configMapConfigProperties, new KubernetesNamespaceProvider(new MockEnvironment()));
260254

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

264-
assertThat(sourceNames).containsExactly("configmap..spring-k8s");
265-
assertThat(propertySource.getProperty(Constants.ERROR_PROPERTY)).isEqualTo("true");
266-
assertThat(output).contains("failure in reading labeled sources");
267-
assertThat(output).contains("failure in reading named sources");
257+
assertThat(propertySource.getPropertySources()).isEmpty();
258+
assertThat(output.getOut()).contains("Failure in reading labeled sources");
259+
assertThat(output.getOut()).contains("Failure in reading named sources");
260+
assertThat(output.getOut()).contains("Failed to load source: { config map labels : '{a=b}'");
268261
}
269262

270263
/**
@@ -314,12 +307,11 @@ void labeledTwoConfigMapsOneFails(CapturedOutput output) {
314307
CompositePropertySource propertySource = (CompositePropertySource) locator.locate(new MockEnvironment());
315308
List<String> names = propertySource.getPropertySources().stream().map(PropertySource::getName).toList();
316309

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

324316
}
325317

@@ -367,15 +359,12 @@ void labeledTwoConfigMapsBothFail(CapturedOutput output) {
367359
configMapConfigProperties, new KubernetesNamespaceProvider(new MockEnvironment()));
368360

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

363+
assertThat(propertySource.getPropertySources()).isEmpty();
364+
assertThat(output).contains("Failure in reading labeled sources");
365+
assertThat(output).contains("Failure in reading named sources");
366+
assertThat(output.getOut()).contains("Failed to load source: { config map labels : '{one=1}'");
367+
assertThat(output.getOut()).contains("Failed to load source: { config map labels : '{two=2}'");
379368
}
380369

381370
}

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 boolean NAMESPACED_BATCH_READ = true;
@@ -192,7 +198,7 @@ public void locateShouldThrowExceptionOnFailureWhenFailFastIsEnabled() {
192198
}
193199

194200
@Test
195-
public void locateShouldNotThrowExceptionOnFailureWhenFailFastIsDisabled() {
201+
public void locateShouldNotThrowExceptionOnFailureWhenFailFastIsDisabled(CapturedOutput output) {
196202
CoreV1Api api = new CoreV1Api();
197203
stubFor(get("/api/v1/namespaces/default/configmaps")
198204
.willReturn(aResponse().withStatus(500).withBody("Internal Server Error")));
@@ -204,7 +210,17 @@ public void locateShouldNotThrowExceptionOnFailureWhenFailFastIsDisabled() {
204210
KubernetesClientConfigMapPropertySourceLocator locator = new KubernetesClientConfigMapPropertySourceLocator(api,
205211
configMapConfigProperties, new KubernetesNamespaceProvider(new MockEnvironment()));
206212

207-
assertThatNoException().isThrownBy(() -> locator.locate(new MockEnvironment()));
213+
List<PropertySource<?>> result = new ArrayList<>();
214+
assertThatNoException().isThrownBy(() -> {
215+
PropertySource<?> source = locator.locate(new MockEnvironment());
216+
result.add(source);
217+
});
218+
219+
assertThat(result.get(0)).isInstanceOf(CompositePropertySource.class);
220+
CompositePropertySource composite = (CompositePropertySource) result.get(0);
221+
assertThat(composite.getPropertySources()).hasSize(0);
222+
assertThat(output.getOut()).contains("Failed to load source:");
223+
208224
}
209225

210226
}

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 boolean NAMESPACED_BATCH_READ = true;
@@ -205,7 +211,7 @@ void locateShouldThrowExceptionOnFailureWhenFailFastIsEnabled() {
205211
}
206212

207213
@Test
208-
void locateShouldNotThrowExceptionOnFailureWhenFailFastIsDisabled() {
214+
void locateShouldNotThrowExceptionOnFailureWhenFailFastIsDisabled(CapturedOutput output) {
209215
CoreV1Api api = new CoreV1Api();
210216
stubFor(get(LIST_API).willReturn(aResponse().withStatus(500).withBody("Internal Server Error")));
211217

@@ -216,7 +222,16 @@ void locateShouldNotThrowExceptionOnFailureWhenFailFastIsDisabled() {
216222
KubernetesClientSecretsPropertySourceLocator locator = new KubernetesClientSecretsPropertySourceLocator(api,
217223
new KubernetesNamespaceProvider(new MockEnvironment()), secretsConfigProperties);
218224

219-
assertThatNoException().isThrownBy(() -> locator.locate(new MockEnvironment()));
225+
List<PropertySource<?>> result = new ArrayList<>();
226+
assertThatNoException().isThrownBy(() -> {
227+
PropertySource<?> source = locator.locate(new MockEnvironment());
228+
result.add(source);
229+
});
230+
231+
assertThat(result.get(0)).isInstanceOf(CompositePropertySource.class);
232+
CompositePropertySource composite = (CompositePropertySource) result.get(0);
233+
assertThat(composite.getPropertySources()).hasSize(0);
234+
assertThat(output.getOut()).contains("Failed to load source:");
220235
}
221236

222237
}

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)