Skip to content

Commit 34cd596

Browse files
committed
Merge branch 'main' into simplify_config_reload
2 parents 0f6c1b2 + fae4e7f commit 34cd596

File tree

10 files changed

+32
-68
lines changed

10 files changed

+32
-68
lines changed

docs/modules/ROOT/partials/_configprops.adoc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
|spring.cloud.kubernetes.client.proxy-username | |
3737
|spring.cloud.kubernetes.client.request-timeout | |
3838
|spring.cloud.kubernetes.client.requestTimeout | `+++10s+++` | Request timeout
39-
|spring.cloud.kubernetes.client.rolling-timeout | |
4039
|spring.cloud.kubernetes.client.rollingTimeout | `+++900s+++` | Rolling timeout
4140
|spring.cloud.kubernetes.client.service-account-namespace-path | `+++/var/run/secrets/kubernetes.io/serviceaccount/namespace+++` |
4241
|spring.cloud.kubernetes.client.trust-certs | |

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -499,8 +499,7 @@ static class LocalTestConfig {
499499
@Bean
500500
KubernetesClientProperties kubernetesClientProperties() {
501501
return new KubernetesClientProperties(null, null, null, "default", null, null, null, null, null, null, null,
502-
null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null,
503-
null);
502+
null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null);
504503
}
505504

506505
@Bean

spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/KubernetesClientProperties.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ public record KubernetesClientProperties(Boolean trustCerts, String masterUrl, S
3333
String caCertFile, String caCertData, String clientCertFile, String clientCertData, String clientKeyFile,
3434
String clientKeyData, String clientKeyAlgo, String clientKeyPassphrase, String username, String password,
3535
Duration watchReconnectInterval, Duration watchReconnectLimit, Duration connectionTimeout,
36-
Duration requestTimeout, @Deprecated(forRemoval = true) Duration rollingTimeout, Duration loggingInterval,
37-
String httpProxy, String httpsProxy, String proxyUsername, String proxyPassword, String oauthToken,
38-
String[] noProxy, @DefaultValue(SERVICE_ACCOUNT_NAMESPACE_PATH) String serviceAccountNamespacePath,
36+
Duration requestTimeout, Duration loggingInterval, String httpProxy, String httpsProxy, String proxyUsername,
37+
String proxyPassword, String oauthToken, String[] noProxy,
38+
@DefaultValue(SERVICE_ACCOUNT_NAMESPACE_PATH) String serviceAccountNamespacePath,
3939
@DefaultValue(DEFAULT_USER_AGENT) String userAgent) {
4040

4141
/**
@@ -61,9 +61,9 @@ public KubernetesClientProperties withNamespace(String namespace) {
6161
this.caCertFile(), this.caCertData(), this.clientCertFile(), this.clientCertData(),
6262
this.clientKeyFile(), this.clientKeyData(), this.clientKeyAlgo(), this.clientKeyPassphrase(),
6363
this.username(), this.password(), this.watchReconnectInterval(), this.watchReconnectLimit(),
64-
this.connectionTimeout(), this.requestTimeout(), this.rollingTimeout(), this.loggingInterval(),
65-
this.httpProxy(), this.httpsProxy(), this.proxyUsername(), this.proxyPassword(), this.oauthToken(),
66-
this.noProxy(), this.serviceAccountNamespacePath(), this.userAgent());
64+
this.connectionTimeout(), this.requestTimeout(), this.loggingInterval(), this.httpProxy(),
65+
this.httpsProxy(), this.proxyUsername(), this.proxyPassword(), this.oauthToken(), this.noProxy(),
66+
this.serviceAccountNamespacePath(), this.userAgent());
6767
}
6868

6969
}

spring-cloud-kubernetes-commons/src/test/java/org/springframework/cloud/kubernetes/commons/KubernetesClientPropertiesTests.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ void testDefaults() {
5454
assertThat(properties.watchReconnectLimit()).isNull();
5555
assertThat(properties.connectionTimeout()).isNull();
5656
assertThat(properties.requestTimeout()).isNull();
57-
assertThat(properties.rollingTimeout()).isNull();
5857
assertThat(properties.loggingInterval()).isNull();
5958
assertThat(properties.httpProxy()).isNull();
6059
assertThat(properties.httpsProxy()).isNull();
@@ -89,7 +88,6 @@ void testNonDefaults() {
8988
"spring.cloud.kubernetes.client.watch-reconnect-limit=300ms",
9089
"spring.cloud.kubernetes.client.connection-timeout=400ms",
9190
"spring.cloud.kubernetes.client.request-timeout=500ms",
92-
"spring.cloud.kubernetes.client.rolling-timeout=600ms",
9391
"spring.cloud.kubernetes.client.logging-interval=700ms",
9492
"spring.cloud.kubernetes.client.http-proxy=http-proxy",
9593
"spring.cloud.kubernetes.client.https-proxy=https-proxy",
@@ -120,7 +118,6 @@ void testNonDefaults() {
120118
assertThat(properties.watchReconnectLimit()).isEqualTo(Duration.ofMillis(300));
121119
assertThat(properties.connectionTimeout()).isEqualTo(Duration.ofMillis(400));
122120
assertThat(properties.requestTimeout()).isEqualTo(Duration.ofMillis(500));
123-
assertThat(properties.rollingTimeout()).isEqualTo(Duration.ofMillis(600));
124121
assertThat(properties.loggingInterval()).isEqualTo(Duration.ofMillis(700));
125122
assertThat(properties.httpProxy()).isEqualTo("http-proxy");
126123
assertThat(properties.httpsProxy()).isEqualTo("https-proxy");
@@ -156,7 +153,6 @@ void testCopyWithNamespaceConstructor() {
156153
"spring.cloud.kubernetes.client.watch-reconnect-limit=300ms",
157154
"spring.cloud.kubernetes.client.connection-timeout=400ms",
158155
"spring.cloud.kubernetes.client.request-timeout=500ms",
159-
"spring.cloud.kubernetes.client.rolling-timeout=600ms",
160156
"spring.cloud.kubernetes.client.logging-interval=700ms",
161157
"spring.cloud.kubernetes.client.http-proxy=http-proxy",
162158
"spring.cloud.kubernetes.client.https-proxy=https-proxy",
@@ -188,7 +184,6 @@ void testCopyWithNamespaceConstructor() {
188184
assertThat(properties.watchReconnectLimit()).isEqualTo(Duration.ofMillis(300));
189185
assertThat(properties.connectionTimeout()).isEqualTo(Duration.ofMillis(400));
190186
assertThat(properties.requestTimeout()).isEqualTo(Duration.ofMillis(500));
191-
assertThat(properties.rollingTimeout()).isEqualTo(Duration.ofMillis(600));
192187
assertThat(properties.loggingInterval()).isEqualTo(Duration.ofMillis(700));
193188
assertThat(properties.httpProxy()).isEqualTo("http-proxy");
194189
assertThat(properties.httpsProxy()).isEqualTo("https-proxy");

spring-cloud-kubernetes-commons/src/test/java/org/springframework/cloud/kubernetes/commons/config/KubernetesConfigDataLocationResolverTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ void testResolveProfileSpecificTwo() {
156156
DefaultBootstrapContext context = new DefaultBootstrapContext();
157157
KubernetesClientProperties properties = new KubernetesClientProperties(null, null, null, null, null, null, null,
158158
null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null,
159-
null, null, null, "user-agent");
159+
null, null, "user-agent");
160160
context.register(KubernetesClientProperties.class, BootstrapRegistry.InstanceSupplier.of(properties));
161161

162162
Mockito.when(RESOLVER_CONTEXT.getBinder()).thenReturn(binder);

spring-cloud-kubernetes-fabric8-autoconfig/src/main/java/org/springframework/cloud/kubernetes/fabric8/Fabric8AutoConfiguration.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,6 @@ private static Integer orDurationInt(Duration left, Integer right) {
5252
return left != null ? (int) left.toMillis() : right;
5353
}
5454

55-
private static Long orDurationLong(Duration left, Long right) {
56-
return left != null ? left.toMillis() : right;
57-
}
58-
5955
@Bean
6056
@ConditionalOnMissingBean(Config.class)
6157
public Config kubernetesClientConfig(KubernetesClientProperties kubernetesClientProperties) {

spring-cloud-kubernetes-fabric8-discovery/src/test/java/org/springframework/cloud/kubernetes/fabric8/discovery/Fabric8EndpointsAndEndpointSlicesTests.java

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@
5858
*/
5959
abstract class Fabric8EndpointsAndEndpointSlicesTests {
6060

61+
static KubernetesClient mockClient;
62+
6163
static final KubernetesNamespaceProvider NAMESPACE_PROVIDER = Mockito.mock(KubernetesNamespaceProvider.class);
6264

6365
static final ArgumentCaptor<HeartbeatEvent> HEARTBEAT_EVENT_ARGUMENT_CAPTOR = ArgumentCaptor
@@ -68,7 +70,7 @@ abstract class Fabric8EndpointsAndEndpointSlicesTests {
6870
@BeforeAll
6971
static void setUp() {
7072
// Configure the kubernetes master url to point to the mock server
71-
System.setProperty(Config.KUBERNETES_MASTER_SYSTEM_PROPERTY, mockClient().getConfiguration().getMasterUrl());
73+
System.setProperty(Config.KUBERNETES_MASTER_SYSTEM_PROPERTY, mockClient.getConfiguration().getMasterUrl());
7274
System.setProperty(Config.KUBERNETES_TRUST_CERT_SYSTEM_PROPERTY, "true");
7375
System.setProperty(Config.KUBERNETES_AUTH_TRYKUBECONFIG_SYSTEM_PROPERTY, "false");
7476
System.setProperty(Config.KUBERNETES_AUTH_TRYSERVICEACCOUNT_SYSTEM_PROPERTY, "false");
@@ -79,8 +81,8 @@ static void setUp() {
7981
@AfterEach
8082
void afterEach() {
8183
Mockito.reset(APPLICATION_EVENT_PUBLISHER);
82-
mockClient().discovery().v1().endpointSlices().inAnyNamespace().delete();
83-
mockClient().endpoints().inAnyNamespace().delete();
84+
mockClient.discovery().v1().endpointSlices().inAnyNamespace().delete();
85+
mockClient.endpoints().inAnyNamespace().delete();
8486
}
8587

8688
/**
@@ -251,7 +253,7 @@ KubernetesCatalogWatch createWatcherInAllNamespacesWithLabels(Map<String, String
251253
boolean allNamespaces = true;
252254
KubernetesDiscoveryProperties properties = new KubernetesDiscoveryProperties(true, allNamespaces, namespaces,
253255
true, 60, false, "", Set.of(), labels, "", null, 0, endpointSlices, false, null);
254-
KubernetesCatalogWatch watch = new KubernetesCatalogWatch(mockClient(), properties, NAMESPACE_PROVIDER);
256+
KubernetesCatalogWatch watch = new KubernetesCatalogWatch(mockClient, properties, NAMESPACE_PROVIDER);
255257

256258
if (endpointSlices) {
257259
watch = Mockito.spy(watch);
@@ -272,7 +274,7 @@ KubernetesCatalogWatch createWatcherInSpecificNamespaceWithLabels(String namespa
272274
boolean allNamespaces = false;
273275
KubernetesDiscoveryProperties properties = new KubernetesDiscoveryProperties(true, allNamespaces,
274276
Set.of(namespace), true, 60, false, "", Set.of(), labels, "", null, 0, endpointSlices, false, null);
275-
KubernetesCatalogWatch watch = new KubernetesCatalogWatch(mockClient(), properties, NAMESPACE_PROVIDER);
277+
KubernetesCatalogWatch watch = new KubernetesCatalogWatch(mockClient, properties, NAMESPACE_PROVIDER);
276278

277279
if (endpointSlices) {
278280
watch = Mockito.spy(watch);
@@ -291,7 +293,7 @@ KubernetesCatalogWatch createWatcherInSpecificNamespacesWithLabels(Set<String> n
291293
// all-namespaces = false
292294
KubernetesDiscoveryProperties properties = new KubernetesDiscoveryProperties(true, false, namespaces, true, 60,
293295
false, "", Set.of(), labels, "", null, 0, false, false, null);
294-
KubernetesCatalogWatch watch = new KubernetesCatalogWatch(mockClient(), properties, NAMESPACE_PROVIDER);
296+
KubernetesCatalogWatch watch = new KubernetesCatalogWatch(mockClient, properties, NAMESPACE_PROVIDER);
295297

296298
if (endpointSlices) {
297299
watch = Mockito.spy(watch);
@@ -316,7 +318,7 @@ void endpoints(String namespace, Map<String, String> labels, String podName) {
316318
.withMetadata(new ObjectMetaBuilder().withLabels(labels).withName("endpoints-" + podName).build())
317319
.withSubsets(List.of(endpointSubset))
318320
.build();
319-
mockClient().endpoints().inNamespace(namespace).resource(endpoints).create();
321+
mockClient.endpoints().inNamespace(namespace).resource(endpoints).create();
320322
}
321323

322324
Endpoints endpointsWithoutSubsets(String namespace, Map<String, String> labels, String podName) {
@@ -330,7 +332,7 @@ Endpoints endpointsWithoutSubsets(String namespace, Map<String, String> labels,
330332
.withMetadata(new ObjectMetaBuilder().withLabels(labels).withName("endpoints-" + podName).build())
331333
.withSubsets(endpointSubsets)
332334
.build();
333-
mockClient().endpoints().inNamespace(namespace).resource(endpoints).create();
335+
mockClient.endpoints().inNamespace(namespace).resource(endpoints).create();
334336
return endpoints;
335337
}
336338

@@ -339,7 +341,7 @@ void service(String namespace, Map<String, String> labels, String podName) {
339341
Service service = new ServiceBuilder()
340342
.withMetadata(new ObjectMetaBuilder().withLabels(labels).withName("endpoints-" + podName).build())
341343
.build();
342-
mockClient().services().inNamespace(namespace).resource(service).create();
344+
mockClient.services().inNamespace(namespace).resource(service).create();
343345
}
344346

345347
static void endpointSlice(String namespace, Map<String, String> labels, String podName) {
@@ -356,7 +358,7 @@ static void endpointSlice(String namespace, Map<String, String> labels, String p
356358
.withEndpoints(endpoint)
357359
.build();
358360

359-
mockClient().discovery().v1().endpointSlices().inNamespace(namespace).resource(slice).create();
361+
mockClient.discovery().v1().endpointSlices().inNamespace(namespace).resource(slice).create();
360362

361363
}
362364

@@ -372,7 +374,7 @@ static EndpointSlice endpointSliceWithoutEndpoints(String namespace, Map<String,
372374
.withEndpoints(endpoints)
373375
.build();
374376

375-
mockClient().discovery().v1().endpointSlices().inNamespace(namespace).resource(slice).create();
377+
mockClient.discovery().v1().endpointSlices().inNamespace(namespace).resource(slice).create();
376378
return slice;
377379

378380
}
@@ -389,11 +391,4 @@ static void invokeAndAssert(KubernetesCatalogWatch watch, List<EndpointNameAndNa
389391
assertThat(event.getValue()).isEqualTo(state);
390392
}
391393

392-
// work-around for : https://github.com/fabric8io/kubernetes-client/issues/4649
393-
private static KubernetesClient mockClient() {
394-
return Fabric8KubernetesCatalogWatchEndpointsTests.endpointsMockClient() != null
395-
? Fabric8KubernetesCatalogWatchEndpointsTests.endpointsMockClient()
396-
: Fabric8KubernetesCatalogWatchEndpointSlicesTests.endpointSlicesMockClient();
397-
}
398-
399394
}

spring-cloud-kubernetes-fabric8-discovery/src/test/java/org/springframework/cloud/kubernetes/fabric8/discovery/Fabric8KubernetesCatalogWatchEndpointSlicesTests.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -203,9 +203,4 @@ void generateStateEndpointsWithoutEndpoints() {
203203
assertThat(catalogWatch.generateState(List.of(sliceNoEndpoints))).isEmpty();
204204
}
205205

206-
// work-around for : https://github.com/fabric8io/kubernetes-client/issues/4649
207-
static KubernetesClient endpointSlicesMockClient() {
208-
return mockClient;
209-
}
210-
211206
}

spring-cloud-kubernetes-fabric8-discovery/src/test/java/org/springframework/cloud/kubernetes/fabric8/discovery/Fabric8KubernetesCatalogWatchEndpointsTests.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import java.util.Set;
2222

2323
import io.fabric8.kubernetes.api.model.Endpoints;
24-
import io.fabric8.kubernetes.client.KubernetesClient;
2524
import io.fabric8.kubernetes.client.server.mock.EnableKubernetesMockClient;
2625
import org.junit.jupiter.api.AfterEach;
2726
import org.junit.jupiter.api.Test;
@@ -40,8 +39,6 @@ class Fabric8KubernetesCatalogWatchEndpointsTests extends Fabric8EndpointsAndEnd
4039

4140
private static final Boolean ENDPOINT_SLICES = false;
4241

43-
private static KubernetesClient mockClient;
44-
4542
@AfterEach
4643
void afterEach() {
4744
mockClient.endpoints().inAnyNamespace().delete();
@@ -264,9 +261,4 @@ void generateStateEndpointsWithoutSubsets() {
264261
assertThat(result).isEmpty();
265262
}
266263

267-
// work-around for : https://github.com/fabric8io/kubernetes-client/issues/4649
268-
static KubernetesClient endpointsMockClient() {
269-
return mockClient;
270-
}
271-
272264
}

spring-cloud-kubernetes-test-support/src/main/java/org/springframework/cloud/kubernetes/integration/tests/commons/fabric8_client/Util.java

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -115,14 +115,14 @@ public void createAndWait(String namespace, String name, @Nullable Deployment de
115115
public void busybox(String namespace, Phase phase) {
116116
InputStream deploymentStream = inputStream("busybox/deployment.yaml");
117117
InputStream serviceStream = inputStream("busybox/service.yaml");
118-
Deployment deployment = client.apps().deployments().load(deploymentStream).item();
118+
Deployment deployment = Serialization.unmarshal(deploymentStream, Deployment.class);
119119

120120
String busyboxVersion = Images.busyboxVersion();
121121
String imageWithoutVersion = deployment.getSpec().getTemplate().getSpec().getContainers().get(0).getImage();
122122
String imageWithVersion = imageWithoutVersion + ":" + busyboxVersion;
123123
deployment.getSpec().getTemplate().getSpec().getContainers().get(0).setImage(imageWithVersion);
124124

125-
Service service = client.services().load(serviceStream).item();
125+
Service service = Serialization.unmarshal(serviceStream, Service.class);
126126

127127
if (phase.equals(Phase.CREATE)) {
128128
createAndWait(namespace, "busybox", deployment, service, false);
@@ -307,12 +307,12 @@ public void wiremock(String namespace, Phase phase, boolean withNodePort) {
307307
InputStream deploymentStream = inputStream("wiremock/wiremock-deployment.yaml");
308308
InputStream serviceStream = inputStream("wiremock/wiremock-service.yaml");
309309

310-
Deployment deployment = client.apps().deployments().load(deploymentStream).item();
310+
Deployment deployment = Serialization.unmarshal(deploymentStream, Deployment.class);
311311
String imageWithoutVersion = deployment.getSpec().getTemplate().getSpec().getContainers().get(0).getImage();
312312
String imageWithVersion = imageWithoutVersion + ":" + Images.wiremockVersion();
313313
deployment.getSpec().getTemplate().getSpec().getContainers().get(0).setImage(imageWithVersion);
314314

315-
Service service = client.services().load(serviceStream).item();
315+
Service service = Serialization.unmarshal(serviceStream, Service.class);
316316
if (!withNodePort) {
317317
// we assume we only have one 'http' port
318318
service.getSpec().getPorts().get(0).setNodePort(null);
@@ -394,31 +394,24 @@ private boolean isDeploymentReady(String namespace, String deploymentName) {
394394

395395
private void innerSetup(String namespace, InputStream serviceAccountAsStream, InputStream roleBindingAsStream,
396396
InputStream roleAsStream) {
397-
ServiceAccount serviceAccountFromStream = client.serviceAccounts()
398-
.inNamespace(namespace)
399-
.load(serviceAccountAsStream)
400-
.item();
397+
ServiceAccount serviceAccount = Serialization.unmarshal(serviceAccountAsStream, ServiceAccount.class);
401398
if (client.serviceAccounts()
402399
.inNamespace(namespace)
403-
.withName(serviceAccountFromStream.getMetadata().getName())
400+
.withName(serviceAccount.getMetadata().getName())
404401
.get() == null) {
405-
client.serviceAccounts().inNamespace(namespace).resource(serviceAccountFromStream).create();
402+
client.serviceAccounts().inNamespace(namespace).resource(serviceAccount).create();
406403
}
407404

408-
RoleBinding roleBindingFromStream = client.rbac()
409-
.roleBindings()
410-
.inNamespace(namespace)
411-
.load(roleBindingAsStream)
412-
.item();
405+
RoleBinding roleBinding = Serialization.unmarshal(roleBindingAsStream, RoleBinding.class);
413406
if (client.rbac()
414407
.roleBindings()
415408
.inNamespace(namespace)
416-
.withName(roleBindingFromStream.getMetadata().getName())
409+
.withName(roleBinding.getMetadata().getName())
417410
.get() == null) {
418-
client.rbac().roleBindings().inNamespace(namespace).resource(roleBindingFromStream).create();
411+
client.rbac().roleBindings().inNamespace(namespace).resource(roleBinding).create();
419412
}
420413

421-
Role roleFromStream = client.rbac().roles().inNamespace(namespace).load(roleAsStream).item();
414+
Role roleFromStream = Serialization.unmarshal(roleAsStream, Role.class);
422415
if (client.rbac()
423416
.roles()
424417
.inNamespace(namespace)

0 commit comments

Comments
 (0)