mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-04 09:49:50 +00:00
Make DeltaFIFO Resync atomic
Make DeltaFIFO's Resync operation atomic, so it enqueues the entire queue before allowing adds/updates/deletes.
This commit is contained in:
parent
cb758738f9
commit
d8205df171
@ -505,14 +505,12 @@ func (f *DeltaFIFO) Replace(list []interface{}, resourceVersion string) error {
|
|||||||
|
|
||||||
// Resync will send a sync event for each item
|
// Resync will send a sync event for each item
|
||||||
func (f *DeltaFIFO) Resync() error {
|
func (f *DeltaFIFO) Resync() error {
|
||||||
var keys []string
|
f.lock.Lock()
|
||||||
func() {
|
defer f.lock.Unlock()
|
||||||
f.lock.RLock()
|
|
||||||
defer f.lock.RUnlock()
|
keys := f.knownObjects.ListKeys()
|
||||||
keys = f.knownObjects.ListKeys()
|
|
||||||
}()
|
|
||||||
for _, k := range keys {
|
for _, k := range keys {
|
||||||
if err := f.syncKey(k); err != nil {
|
if err := f.syncKeyLocked(k); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -522,6 +520,11 @@ func (f *DeltaFIFO) Resync() error {
|
|||||||
func (f *DeltaFIFO) syncKey(key string) error {
|
func (f *DeltaFIFO) syncKey(key string) error {
|
||||||
f.lock.Lock()
|
f.lock.Lock()
|
||||||
defer f.lock.Unlock()
|
defer f.lock.Unlock()
|
||||||
|
|
||||||
|
return f.syncKeyLocked(key)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *DeltaFIFO) syncKeyLocked(key string) error {
|
||||||
obj, exists, err := f.knownObjects.GetByKey(key)
|
obj, exists, err := f.knownObjects.GetByKey(key)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Errorf("Unexpected error %v during lookup of key %v, unable to queue object for sync", err, key)
|
glog.Errorf("Unexpected error %v during lookup of key %v, unable to queue object for sync", err, key)
|
||||||
|
Loading…
Reference in New Issue
Block a user