Prevent data race condition in csi unit tests

Kubernetes-commit: 92d0f8e6cc3b3d40194759afa4c7f2880dd5ada4
This commit is contained in:
Mengjiao Liu 2021-05-18 18:00:03 +08:00 committed by Kubernetes Publisher
parent b0c8a7cef1
commit 8cb6ac7646

View File

@ -106,11 +106,15 @@ func (c *Fake) PrependReactor(verb, resource string, reaction ReactionFunc) {
// AddWatchReactor appends a reactor to the end of the chain.
func (c *Fake) AddWatchReactor(resource string, reaction WatchReactionFunc) {
c.Lock()
defer c.Unlock()
c.WatchReactionChain = append(c.WatchReactionChain, &SimpleWatchReactor{resource, reaction})
}
// PrependWatchReactor adds a reactor to the beginning of the chain.
func (c *Fake) PrependWatchReactor(resource string, reaction WatchReactionFunc) {
c.Lock()
defer c.Unlock()
c.WatchReactionChain = append([]WatchReactor{&SimpleWatchReactor{resource, reaction}}, c.WatchReactionChain...)
}