20
20
import io .kubernetes .client .openapi .ApiClient ;
21
21
import io .kubernetes .client .spring .extended .controller .annotation .KubernetesInformer ;
22
22
import io .kubernetes .client .spring .extended .controller .annotation .KubernetesInformers ;
23
+ import io .kubernetes .client .spring .extended .controller .factory .KubernetesControllerFactory ;
23
24
import io .kubernetes .client .util .generic .GenericKubernetesApi ;
25
+ import java .time .Duration ;
26
+ import org .slf4j .Logger ;
27
+ import org .slf4j .LoggerFactory ;
24
28
import org .springframework .beans .BeansException ;
25
29
import org .springframework .beans .factory .BeanFactory ;
26
30
import org .springframework .beans .factory .config .ConfigurableListableBeanFactory ;
@@ -45,6 +49,8 @@ public class KubernetesInformerFactoryProcessor
45
49
46
50
public static final int ORDER = 0 ;
47
51
52
+ private static final Logger log = LoggerFactory .getLogger (KubernetesControllerFactory .class );
53
+
48
54
private ConfigurableListableBeanFactory beanFactory ;
49
55
50
56
@ Override
@@ -122,6 +128,14 @@ private <T extends KubernetesObject> Lister<T> lister(Class<T> type) {
122
128
private <T extends KubernetesObject > SharedInformer <T > informer (
123
129
Class <T > type , KubernetesInformer kubernetesInformer ) {
124
130
ApiClient apiClient = this .beanFactory .getBean (ApiClient .class );
131
+
132
+ if (apiClient .getHttpClient ().readTimeoutMillis () > 0 ) {
133
+ log .warn (
134
+ "Enforcing read-timeout of the ApiClient to zero so that the watch connection won't abort from client-side" );
135
+ apiClient .setHttpClient (
136
+ apiClient .getHttpClient ().newBuilder ().readTimeout (Duration .ZERO ).build ());
137
+ }
138
+
125
139
SharedInformerFactory sharedInformerFactory =
126
140
this .beanFactory .getBean (SharedInformerFactory .class );
127
141
final GenericKubernetesApi api =
0 commit comments