@@ -450,6 +450,8 @@ func NewCacherFromConfig(config Config) (*Cacher, error) {
450
450
}
451
451
452
452
func (c * Cacher ) startCaching (stopChannel <- chan struct {}) {
453
+ fmt .Printf ("#### 2a groupResource=%v startCaching\n " , c .groupResource )
454
+
453
455
// The 'usable' lock is always 'RLock'able when it is safe to use the cache.
454
456
// It is safe to use the cache after a successful list until a disconnection.
455
457
// We start with usable (write) locked. The below OnReplace function will
@@ -465,6 +467,7 @@ func (c *Cacher) startCaching(stopChannel <-chan struct{}) {
465
467
})
466
468
defer func () {
467
469
if successfulList {
470
+ fmt .Printf ("#### 2b groupResource=%v setting to false\n " , c .groupResource )
468
471
c .ready .set (false )
469
472
}
470
473
}()
@@ -477,6 +480,7 @@ func (c *Cacher) startCaching(stopChannel <-chan struct{}) {
477
480
if err := c .reflector .ListAndWatch (stopChannel ); err != nil {
478
481
klog .Errorf ("cacher (%v): unexpected ListAndWatch error: %v; reinitializing..." , c .groupResource .String (), err )
479
482
}
483
+ fmt .Printf ("#### 2e groupResource=%v exiting\n " , c .groupResource )
480
484
}
481
485
482
486
// Versioner implements storage.Interface.
@@ -536,17 +540,20 @@ func (c *Cacher) Watch(ctx context.Context, key string, opts storage.ListOptions
536
540
537
541
var readyGeneration int
538
542
if utilfeature .DefaultFeatureGate .Enabled (features .ResilientWatchCacheInitialization ) {
543
+ fmt .Printf ("#### 1a groupResource=%v\n " , c .groupResource )
539
544
var ok bool
540
545
readyGeneration , ok = c .ready .checkAndReadGeneration ()
541
546
if ! ok {
542
547
return nil , errors .NewTooManyRequests ("storage is (re)initializing" , 1 )
543
548
}
544
549
} else {
550
+ fmt .Printf ("#### 1b groupResource=%v\n " , c .groupResource )
545
551
readyGeneration , err = c .ready .waitAndReadGeneration (ctx )
546
552
if err != nil {
547
553
return nil , errors .NewServiceUnavailable (err .Error ())
548
554
}
549
555
}
556
+ fmt .Printf ("#### 1c groupResource=%v, originalReadyGeneration=%d\n " , c .groupResource , readyGeneration )
550
557
551
558
// determine the namespace and name scope of the watch, first from the request, secondarily from the field selector
552
559
scope := namespacedName {}
@@ -659,6 +666,7 @@ func (c *Cacher) Watch(ctx context.Context, key string, opts storage.ListOptions
659
666
defer c .Unlock ()
660
667
661
668
if generation , ok := c .ready .checkAndReadGeneration (); generation != readyGeneration || ! ok {
669
+ fmt .Printf ("#### 1o groupResource=%v currentReadyGeneration=%d, originalReadyGeneration=%d, ok=%v\n " , c .groupResource , generation , readyGeneration , ok )
662
670
// We went unready or are already on a different generation.
663
671
// Avoid registering and starting the watch as it will have to be
664
672
// terminated immediately anyway.
@@ -680,6 +688,7 @@ func (c *Cacher) Watch(ctx context.Context, key string, opts storage.ListOptions
680
688
}()
681
689
682
690
if ! addedWatcher {
691
+ fmt .Printf ("#### 1x groupResource=%v returning the immediate closer thing\n " , c .groupResource )
683
692
// Watcher isn't really started at this point, so it's safe to just drop it.
684
693
//
685
694
// We're simulating the immediate watch termination, which boils down to simply
0 commit comments