Skip to content

Instantly share code, notes, and snippets.

@sttts
Created April 16, 2025 19:06
Show Gist options
  • Save sttts/c9a841cd1638c45fb39ef0abf609bc1c to your computer and use it in GitHub Desktop.
Save sttts/c9a841cd1638c45fb39ef0abf609bc1c to your computer and use it in GitHub Desktop.
diff --git a/staging/src/k8s.io/client-go/testing/fixture.go b/staging/src/k8s.io/client-go/testing/fixture.go
index 878ae7403ea..6662424f917 100644
--- a/staging/src/k8s.io/client-go/testing/fixture.go
+++ b/staging/src/k8s.io/client-go/testing/fixture.go
@@ -22,6 +22,7 @@ import (
"sort"
"strings"
"sync"
+ "time"
"sigs.k8s.io/structured-merge-diff/v4/typed"
"sigs.k8s.io/yaml"
@@ -361,15 +362,20 @@ func (t *tracker) Watch(logger klog.Logger, gvr schema.GroupVersionResource, ns
return nil, err
}
- t.lock.Lock()
- defer t.lock.Unlock()
-
fakewatcher := watch.NewRaceFreeFakeWithLogger(logger)
- if _, exists := t.watchers[gvr]; !exists {
- t.watchers[gvr] = make(map[string][]*watch.RaceFreeFakeWatcher)
- }
- t.watchers[gvr][ns] = append(t.watchers[gvr][ns], fakewatcher)
+ go func() {
+ time.Sleep(2 * time.Second)
+
+ t.lock.Lock()
+ defer t.lock.Unlock()
+
+ if _, exists := t.watchers[gvr]; !exists {
+ t.watchers[gvr] = make(map[string][]*watch.RaceFreeFakeWatcher)
+ }
+ t.watchers[gvr][ns] = append(t.watchers[gvr][ns], fakewatcher)
+ }()
+
return fakewatcher, nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment