File tree 2 files changed +22
-1
lines changed
2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -63,11 +63,17 @@ func (m *InformersMap) Start(stop <-chan struct{}) error {
63
63
return nil
64
64
}
65
65
66
- // WaitForCacheSync waits until all the caches have been synced.
66
+ // WaitForCacheSync waits until all the caches have been started and synced.
67
67
func (m * InformersMap ) WaitForCacheSync (stop <- chan struct {}) bool {
68
68
syncedFuncs := append ([]cache.InformerSynced (nil ), m .structured .HasSyncedFuncs ()... )
69
69
syncedFuncs = append (syncedFuncs , m .unstructured .HasSyncedFuncs ()... )
70
70
71
+ if ! m .structured .waitForStarted (stop ) {
72
+ return false
73
+ }
74
+ if ! m .unstructured .waitForStarted (stop ) {
75
+ return false
76
+ }
71
77
return cache .WaitForCacheSync (stop , syncedFuncs ... )
72
78
}
73
79
Original file line number Diff line number Diff line change @@ -54,6 +54,7 @@ func newSpecificInformersMap(config *rest.Config,
54
54
codecs : serializer .NewCodecFactory (scheme ),
55
55
paramCodec : runtime .NewParameterCodec (scheme ),
56
56
resync : resync ,
57
+ startWait : make (chan struct {}),
57
58
createListWatcher : createListWatcher ,
58
59
namespace : namespace ,
59
60
}
@@ -104,6 +105,10 @@ type specificInformersMap struct {
104
105
// start is true if the informers have been started
105
106
started bool
106
107
108
+ // startWait is a channel that is closed after the
109
+ // informer has been started.
110
+ startWait chan struct {}
111
+
107
112
// createClient knows how to create a client and a list object,
108
113
// and allows for abstracting over the particulars of structured vs
109
114
// unstructured objects.
@@ -131,10 +136,20 @@ func (ip *specificInformersMap) Start(stop <-chan struct{}) {
131
136
132
137
// Set started to true so we immediately start any informers added later.
133
138
ip .started = true
139
+ close (ip .startWait )
134
140
}()
135
141
<- stop
136
142
}
137
143
144
+ func (ip * specificInformersMap ) waitForStarted (stop <- chan struct {}) bool {
145
+ select {
146
+ case <- ip .startWait :
147
+ return true
148
+ case <- stop :
149
+ return false
150
+ }
151
+ }
152
+
138
153
// HasSyncedFuncs returns all the HasSynced functions for the informers in this map.
139
154
func (ip * specificInformersMap ) HasSyncedFuncs () []cache.InformerSynced {
140
155
ip .mu .RLock ()
You can’t perform that action at this time.
0 commit comments