@@ -36,6 +36,8 @@ type ClientFactory struct {
3636 clients map [string ]* clientImpl
3737}
3838
39+ const validity = 15 * time .Minute
40+
3941func NewClientFactory (name string , config * rest.Config , schemeBuilder types.SchemeBuilder ) (* ClientFactory , error ) {
4042 scheme := runtime .NewScheme ()
4143 if err := clientgoscheme .AddToScheme (scheme ); err != nil {
@@ -69,6 +71,8 @@ func NewClientFactory(name string, config *rest.Config, schemeBuilder types.Sche
6971 for key , client := range factory .clients {
7072 if client .validUntil .Before (now ) {
7173 client .eventBroadcaster .Shutdown ()
74+ // TODO: add some (debug) log output when client is removed; unfortunately, we have no logger in here ...
75+ // TODO: add metrics about running clients
7276 delete (factory .clients , key )
7377 }
7478 }
@@ -114,7 +118,7 @@ func (f *ClientFactory) Get(kubeConfig []byte, impersonationUser string, imperso
114118 key := sha256sum (keyData )
115119
116120 if client , ok := f .clients [key ]; ok {
117- client .validUntil = time .Now ().Add (15 * time . Minute )
121+ client .validUntil = time .Now ().Add (validity )
118122 return client , nil
119123 }
120124
@@ -138,10 +142,12 @@ func (f *ClientFactory) Get(kubeConfig []byte, impersonationUser string, imperso
138142 discoveryClient : clientset ,
139143 eventBroadcaster : eventBroadcaster ,
140144 eventRecorder : eventRecorder ,
141- validUntil : time .Now ().Add (15 * time . Minute ),
145+ validUntil : time .Now ().Add (validity ),
142146 }
143147 f .clients [key ] = client
144148
149+ // TODO: add some (debug) log output when new client is created; unfortunately, we have no logger in here ...
150+ // TODO: add metrics about running clients
145151 return client , nil
146152}
147153
0 commit comments