Skip to content

Commit 767dc19

Browse files
committed
more
1 parent 324c320 commit 767dc19

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

Diff for: staging/src/k8s.io/apiserver/pkg/storage/cacher/cache_watcher.go

+7
Original file line numberDiff line numberDiff line change
@@ -124,24 +124,31 @@ func (c *cacheWatcher) Stop() {
124124

125125
// we rely on the fact that stopLocked is actually protected by Cacher.Lock()
126126
func (c *cacheWatcher) stopLocked() {
127+
fmt.Printf("#### 4a groupResource=%v \n", c.groupResource)
127128
if !c.stopped {
129+
fmt.Printf("#### 4b groupResource=%v \n", c.groupResource)
128130
c.stopped = true
129131
// stop without draining the input channel was requested.
130132
if !c.drainInputBuffer {
133+
fmt.Printf("#### 4c groupResource=%v \n", c.groupResource)
131134
close(c.done)
132135
}
136+
fmt.Printf("#### 4d groupResource=%v \n", c.groupResource)
133137
close(c.input)
134138
}
135139

140+
fmt.Printf("#### 4e groupResource=%v \n", c.groupResource)
136141
// Even if the watcher was already stopped, if it previously was
137142
// using draining mode and it's not using it now we need to
138143
// close the done channel now. Otherwise we could leak the
139144
// processing goroutine if it will be trying to put more objects
140145
// into result channel, the channel will be full and there will
141146
// already be noone on the processing the events on the receiving end.
142147
if !c.drainInputBuffer && !c.isDoneChannelClosedLocked() {
148+
fmt.Printf("#### 4f groupResource=%v \n", c.groupResource)
143149
close(c.done)
144150
}
151+
fmt.Printf("#### 4g groupResource=%v \n", c.groupResource)
145152
}
146153

147154
func (c *cacheWatcher) nonblockingAdd(event *watchCacheEvent) bool {

Diff for: staging/src/k8s.io/apiserver/pkg/storage/cacher/cacher.go

+12
Original file line numberDiff line numberDiff line change
@@ -661,6 +661,7 @@ func (c *Cacher) Watch(ctx context.Context, key string, opts storage.ListOptions
661661
}
662662

663663
addedWatcher := false
664+
fmt.Printf("#### 1n groupResource=%v \n", c.groupResource)
664665
func() {
665666
c.Lock()
666667
defer c.Unlock()
@@ -673,19 +674,24 @@ func (c *Cacher) Watch(ctx context.Context, key string, opts storage.ListOptions
673674
return
674675
}
675676

677+
fmt.Printf("#### 1p groupResource=%v \n", c.groupResource)
676678
// Update watcher.forget function once we can compute it.
677679
watcher.forget = forgetWatcher(c, watcher, c.watcherIdx, scope, triggerValue, triggerSupported)
678680
// Update the bookMarkAfterResourceVersion
679681
watcher.setBookmarkAfterResourceVersion(bookmarkAfterResourceVersionFn())
680682
c.watchers.addWatcher(watcher, c.watcherIdx, scope, triggerValue, triggerSupported)
681683
addedWatcher = true
682684

685+
fmt.Printf("#### 1q groupResource=%v \n", c.groupResource)
683686
// Add it to the queue only when the client support watch bookmarks.
684687
if watcher.allowWatchBookmarks {
685688
c.bookmarkWatchers.addWatcherThreadUnsafe(watcher)
686689
}
687690
c.watcherIdx++
691+
692+
fmt.Printf("#### 1r groupResource=%v \n", c.groupResource)
688693
}()
694+
fmt.Printf("#### 1s groupResource=%v \n", c.groupResource)
689695

690696
if !addedWatcher {
691697
fmt.Printf("#### 1x groupResource=%v returning the immediate closer thing\n", c.groupResource)
@@ -696,6 +702,7 @@ func (c *Cacher) Watch(ctx context.Context, key string, opts storage.ListOptions
696702
return newImmediateCloseWatcher(), nil
697703
}
698704

705+
fmt.Printf("#### 1y groupResource=%v \n", c.groupResource)
699706
go watcher.processInterval(ctx, cacheInterval, requiredResourceVersion)
700707
return watcher, nil
701708
}
@@ -1342,13 +1349,18 @@ func forgetWatcher(c *Cacher, w *cacheWatcher, index int, scope namespacedName,
13421349
c.Lock()
13431350
defer c.Unlock()
13441351

1352+
fmt.Printf("#### 3a groupResource=%v \n", c.groupResource)
1353+
13451354
w.setDrainInputBufferLocked(drainWatcher)
1355+
fmt.Printf("#### 3b groupResource=%v \n", c.groupResource)
13461356

13471357
// It's possible that the watcher is already not in the structure (e.g. in case of
13481358
// simultaneous Stop() and terminateAllWatchers(), but it is safe to call stopLocked()
13491359
// on a watcher multiple times.
13501360
c.watchers.deleteWatcher(index, scope, triggerValue, triggerSupported)
1361+
fmt.Printf("#### 3c groupResource=%v \n", c.groupResource)
13511362
c.stopWatcherLocked(w)
1363+
fmt.Printf("#### 3d groupResource=%v \n", c.groupResource)
13521364
}
13531365
}
13541366

0 commit comments

Comments
 (0)