Merge pull request #401 from FillZpp/fix-resource-version-expectation

Fix resourceVersionExpectation lock
This commit is contained in:
Zhen Zhang 2020-10-14 14:11:43 +08:00 committed by GitHub
commit df6a76a4c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 5 deletions

View File

@ -36,7 +36,7 @@ func NewResourceVersionExpectation() ResourceVersionExpectation {
}
type realResourceVersionExpectation struct {
sync.RWMutex
sync.Mutex
objectVersions map[types.UID]string
}
@ -57,8 +57,8 @@ func (r *realResourceVersionExpectation) Observe(obj metav1.Object) {
}
func (r *realResourceVersionExpectation) IsSatisfied(obj metav1.Object) bool {
r.RLock()
defer r.RUnlock()
r.Lock()
defer r.Unlock()
if isResourceVersionNewer(r.objectVersions[obj.GetUID()], obj.GetResourceVersion()) {
delete(r.objectVersions, obj.GetUID())
}

View File

@ -33,7 +33,7 @@ func NewScaleExpectations() ScaleExpectations {
}
type realScaleExpectations struct {
sync.RWMutex
sync.Mutex
// key: parent key, workload namespace/name
controllerCache map[string]*realControllerScaleExpectations
}

View File

@ -41,7 +41,7 @@ func NewUpdateExpectations(getRevision func(metav1.Object) string) UpdateExpecta
}
type realUpdateExpectations struct {
sync.RWMutex
sync.Mutex
// key: parent key, workload namespace/name
controllerCache map[string]*realControllerUpdateExpectations
// how to get pod revision