Skip to content

Commit 85185e4

Browse files
committed
Adopt WatchErrorHandlerWithContext & HandleCrashWithLogger
Signed-off-by: Stefan Büringer [email protected]
1 parent 9fcd561 commit 85185e4

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

pkg/cache/cache.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,11 +207,11 @@ type Options struct {
207207
// to reduce the caches memory usage.
208208
DefaultTransform toolscache.TransformFunc
209209

210-
// DefaultWatchErrorHandler will be used to the WatchErrorHandler which is called
210+
// DefaultWatchErrorHandler will be used to set the WatchErrorHandler which is called
211211
// whenever ListAndWatch drops the connection with an error.
212212
//
213213
// After calling this handler, the informer will backoff and retry.
214-
DefaultWatchErrorHandler toolscache.WatchErrorHandler
214+
DefaultWatchErrorHandler toolscache.WatchErrorHandlerWithContext
215215

216216
// DefaultUnsafeDisableDeepCopy is the default for UnsafeDisableDeepCopy
217217
// for everything that doesn't specify this.

pkg/cache/internal/informers.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ type InformersOpts struct {
5252
Transform cache.TransformFunc
5353
UnsafeDisableDeepCopy bool
5454
EnableWatchBookmarks bool
55-
WatchErrorHandler cache.WatchErrorHandler
55+
WatchErrorHandler cache.WatchErrorHandlerWithContext
5656
}
5757

5858
// NewInformers creates a new InformersMap that can create informers under the hood.
@@ -181,10 +181,10 @@ type Informers struct {
181181
// NewInformer allows overriding of the shared index informer constructor for testing.
182182
newInformer func(cache.ListerWatcher, runtime.Object, time.Duration, cache.Indexers) cache.SharedIndexInformer
183183

184-
// WatchErrorHandler allows the shared index informer's
184+
// watchErrorHandler allows the shared index informer's
185185
// watchErrorHandler to be set by overriding the options
186186
// or to use the default watchErrorHandler
187-
watchErrorHandler cache.WatchErrorHandler
187+
watchErrorHandler cache.WatchErrorHandlerWithContext
188188
}
189189

190190
// Start calls Run on each of the informers and sets started to true. Blocks on the context.
@@ -376,7 +376,7 @@ func (ip *Informers) addInformerToMap(gvk schema.GroupVersionKind, obj runtime.O
376376

377377
// Set WatchErrorHandler on SharedIndexInformer if set
378378
if ip.watchErrorHandler != nil {
379-
if err := sharedIndexInformer.SetWatchErrorHandler(ip.watchErrorHandler); err != nil {
379+
if err := sharedIndexInformer.SetWatchErrorHandlerWithContext(ip.watchErrorHandler); err != nil {
380380
return nil, false, err
381381
}
382382
}

pkg/internal/controller/controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ func (c *Controller[request]) Start(ctx context.Context) error {
168168
defer c.mu.Unlock()
169169

170170
// TODO(pwittrock): Reconsider HandleCrash
171-
defer utilruntime.HandleCrash()
171+
defer utilruntime.HandleCrashWithLogger(c.LogConstructor(nil))
172172

173173
// NB(directxman12): launch the sources *before* trying to wait for the
174174
// caches to sync so that they have a chance to register their intended

pkg/log/log_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,12 +194,12 @@ var _ = Describe("logging", func() {
194194
}()
195195
go func() {
196196
defer GinkgoRecover()
197-
delegLog.WithValues("with-value")
197+
delegLog.WithValues("key", "with-value")
198198
close(withValuesDone)
199199
}()
200200
go func() {
201201
defer GinkgoRecover()
202-
child.WithValues("grandchild")
202+
child.WithValues("key", "grandchild")
203203
close(grandChildDone)
204204
}()
205205
go func() {

0 commit comments

Comments
 (0)