17
17
import io .kubernetes .client .informer .SharedInformer ;
18
18
import io .kubernetes .client .informer .SharedInformerFactory ;
19
19
import io .kubernetes .client .informer .cache .Lister ;
20
+ import io .kubernetes .client .informer .cache .ReflectorRunnable ;
20
21
import io .kubernetes .client .openapi .ApiClient ;
21
22
import io .kubernetes .client .spring .extended .controller .annotation .KubernetesInformer ;
22
23
import io .kubernetes .client .spring .extended .controller .annotation .KubernetesInformers ;
24
+ import io .kubernetes .client .spring .extended .controller .factory .KubernetesControllerFactory ;
23
25
import io .kubernetes .client .util .generic .GenericKubernetesApi ;
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,18 @@ 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
137
+ .getHttpClient ()
138
+ .newBuilder ()
139
+ .readTimeout (ReflectorRunnable .REFLECTOR_WATCH_CLIENTSIDE_TIMEOUT )
140
+ .build ());
141
+ }
142
+
125
143
SharedInformerFactory sharedInformerFactory =
126
144
this .beanFactory .getBean (SharedInformerFactory .class );
127
145
final GenericKubernetesApi api =
0 commit comments