Skip to content

Commit

Permalink
Upgrade dependencies (kube client) (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
GregoireW authored Mar 26, 2024
1 parent f69fc74 commit 01a9a58
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 21 deletions.
12 changes: 9 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.2.0</version>
<version>3.2.4</version>
<relativePath/>
</parent>
<groupId>com.decathlon.github</groupId>
Expand All @@ -15,7 +15,7 @@
<description>Status for deployment</description>
<properties>
<java.version>21</java.version>
<fabric8-lib.version>6.9.2</fabric8-lib.version>
<fabric8-lib.version>6.11.0</fabric8-lib.version>
</properties>
<dependencies>
<dependency>
Expand Down Expand Up @@ -50,7 +50,13 @@
<dependency>
<groupId>io.kubernetes</groupId>
<artifactId>client-java-spring-integration</artifactId>
<version>19.0.0</version>
<version>20.0.1</version>
<exclusions>
<exclusion>
<artifactId>aws-java-sdk-sts</artifactId>
<groupId>com.amazonaws</groupId>
</exclusion>
</exclusions>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package com.decathlon.github.kubernetesstatus.configuration.process;

import org.apache.hc.client5.http.classic.HttpClient;
import org.apache.hc.client5.http.config.ConnectionConfig;
import org.apache.hc.client5.http.config.RequestConfig;
import org.apache.hc.client5.http.impl.classic.HttpClientBuilder;
import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager;
import org.apache.hc.client5.http.impl.routing.SystemDefaultRoutePlanner;
import org.apache.hc.client5.http.routing.HttpRoutePlanner;
import org.apache.hc.core5.util.Timeout;
Expand All @@ -13,6 +15,7 @@
import org.springframework.web.client.RestTemplate;

import java.net.ProxySelector;
import java.util.concurrent.TimeUnit;

@Configuration(proxyBeanMethods=false)
public class RestConfiguration {
Expand All @@ -23,16 +26,24 @@ public RestTemplate template(RestTemplateBuilder builder){

int timeout=30;

ConnectionConfig connConfig = ConnectionConfig.custom()
.setConnectTimeout(timeout, TimeUnit.SECONDS)
.setSocketTimeout(timeout, TimeUnit.SECONDS)
.build();

PoolingHttpClientConnectionManager poolingConnManager = new PoolingHttpClientConnectionManager();
poolingConnManager.setDefaultConnectionConfig(connConfig);

var requestConfig = RequestConfig.custom()
.setConnectTimeout(Timeout.ofSeconds(timeout))
.setConnectionRequestTimeout(Timeout.ofSeconds(timeout))
// .setSocketTimeout(...) param not accessible with httpComponent5 ?
.build();


HttpClient httpClient = HttpClientBuilder
.create()
.setRoutePlanner(routePlanner)
.setDefaultRequestConfig(requestConfig)
.setConnectionManager(poolingConnManager)
.build();

return builder
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.decathlon.github.kubernetesstatus.registration;

import com.google.gson.annotations.JsonAdapter;
import io.swagger.annotations.ApiModel;
import lombok.extern.slf4j.Slf4j;
import org.reflections.Reflections;
import org.reflections.scanners.Scanners;
import org.springframework.aot.hint.MemberCategory;
import org.springframework.aot.hint.RuntimeHints;
import org.springframework.aot.hint.RuntimeHintsRegistrar;
Expand All @@ -25,19 +25,16 @@ public class OfficialKubeRegistration implements RuntimeHintsRegistrar {

@Override
public void registerHints(@NonNull RuntimeHints hints, @Nullable ClassLoader classLoader) {
var reflections = new Reflections("io.kubernetes");
var apiModels = reflections.getTypesAnnotatedWith(ApiModel.class);
var jsonAdapters = findJsonAdapters(reflections);
var reflections = new Reflections("io.kubernetes", Scanners.SubTypes.filterResultsBy(x->true), Scanners.TypesAnnotated);

var all = new HashSet<Class<?>>();
all.addAll(jsonAdapters);
all.addAll(apiModels);
all.addAll(reflections.getSubTypesOf(Object.class));
all.addAll(findJsonAdapters(reflections));
all.forEach(clzz -> hints.reflection().registerType(clzz, MemberCategory.values()));

Stream.of(
okhttp3.internal.http.RetryAndFollowUpInterceptor.Companion.class,
io.kubernetes.client.informer.cache.ProcessorListener.class,
io.kubernetes.client.extended.controller.Controller.class,
io.kubernetes.client.extended.controller.ControllerManager.class,
io.kubernetes.client.util.generic.GenericKubernetesApi.StatusPatch.class,
io.kubernetes.client.util.Watch.Response.class
).forEach(clzz -> hints.reflection().registerType(clzz, MemberCategory.values()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,15 @@ public class EventManager {

public void addEvent(GitHubDeployment deployment, KubeObjectResult status, GitHubDeploymentSpec.NamespacedObject sourceRef, GitHubDeployment patch) {
try {
Call fn = new CustomObjectsApi(apiClient).patchNamespacedCustomObjectStatusCall(
Call fn = new CustomObjectsApi(apiClient).patchNamespacedCustomObjectStatus(
GithubDeploymentRef.GROUP,
GithubDeploymentRef.CURRENT_VERSION,
deployment.getMetadata().getNamespace(),
GithubDeploymentRef.PLURAL,
deployment.getMetadata().getName(),
patch,
null,
null,
null,
null
);

patch
).buildCall(null);

PatchUtils.<GitHubDeployment>patch(GitHubDeployment.class, () -> fn, V1Patch.PATCH_FORMAT_JSON_MERGE_PATCH, apiClient);

eventRecorder.event(
Expand Down

0 comments on commit 01a9a58

Please sign in to comment.