Skip to content

Commit bc90299

Browse files
authored
Merge pull request #2021 from wind57/fix-1457
fix issue #1457
2 parents a7ba76c + 01cb7de commit bc90299

File tree

9 files changed

+25
-39
lines changed

9 files changed

+25
-39
lines changed

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/Fabric8KubernetesDiscoveryClientTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,8 @@ void getEndPointsListTestAllNamespaces() {
232232
mockClient.services().inNamespace(namespace2).resource(service2).create();
233233

234234
KubernetesDiscoveryProperties properties = new KubernetesDiscoveryProperties(true, true, Set.of(), true, 60,
235-
false, null, Set.of(), Map.of(), null, KubernetesDiscoveryProperties.Metadata.DEFAULT, 0, false, false, null);
235+
false, null, Set.of(), Map.of(), null, KubernetesDiscoveryProperties.Metadata.DEFAULT, 0, false, false,
236+
null);
236237

237238
KubernetesDiscoveryClient discoveryClient = new KubernetesDiscoveryClient(mockClient, properties,
238239
KubernetesClient::services, x -> true, new ServicePortSecureResolver(properties));

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,8 @@ void testGetServicesWithExternalNameService() {
518518

519519
// last argument is irrelevant, as getServices does not care about that flag
520520
KubernetesDiscoveryProperties properties = new KubernetesDiscoveryProperties(true, true, Set.of("a", "b"), true,
521-
60L, false, "", Set.of(), Map.of(), "", KubernetesDiscoveryProperties.Metadata.DEFAULT, 0, false, false, null);
521+
60L, false, "", Set.of(), Map.of(), "", KubernetesDiscoveryProperties.Metadata.DEFAULT, 0, false, false,
522+
null);
522523

523524
KubernetesDiscoveryClient discoveryClient = new KubernetesDiscoveryClient(client, properties, null, null, null);
524525
List<String> result = discoveryClient.getServices();

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,8 @@ void testNoExpression() {
112112
when(this.kubernetesClient.services()).thenReturn(this.serviceOperation);
113113

114114
KubernetesDiscoveryProperties properties = new KubernetesDiscoveryProperties(true, false, Set.of(), true, 60,
115-
false, "", Set.of(), Map.of(), null, KubernetesDiscoveryProperties.Metadata.DEFAULT, 0, true, false, null);
115+
false, "", Set.of(), Map.of(), null, KubernetesDiscoveryProperties.Metadata.DEFAULT, 0, true, false,
116+
null);
116117
KubernetesDiscoveryClient client = new KubernetesDiscoveryClient(this.kubernetesClient, properties,
117118
this.kubernetesClientServicesFunction);
118119

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)