Merge pull request #102090 from mengjiao-liu/fix-data-race-csi
Prevent data race condition in csi unit tests
This commit is contained in:
		@@ -106,11 +106,15 @@ func (c *Fake) PrependReactor(verb, resource string, reaction ReactionFunc) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// AddWatchReactor appends a reactor to the end of the chain.
 | 
					// AddWatchReactor appends a reactor to the end of the chain.
 | 
				
			||||||
func (c *Fake) AddWatchReactor(resource string, reaction WatchReactionFunc) {
 | 
					func (c *Fake) AddWatchReactor(resource string, reaction WatchReactionFunc) {
 | 
				
			||||||
 | 
						c.Lock()
 | 
				
			||||||
 | 
						defer c.Unlock()
 | 
				
			||||||
	c.WatchReactionChain = append(c.WatchReactionChain, &SimpleWatchReactor{resource, reaction})
 | 
						c.WatchReactionChain = append(c.WatchReactionChain, &SimpleWatchReactor{resource, reaction})
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// PrependWatchReactor adds a reactor to the beginning of the chain.
 | 
					// PrependWatchReactor adds a reactor to the beginning of the chain.
 | 
				
			||||||
func (c *Fake) PrependWatchReactor(resource string, reaction WatchReactionFunc) {
 | 
					func (c *Fake) PrependWatchReactor(resource string, reaction WatchReactionFunc) {
 | 
				
			||||||
 | 
						c.Lock()
 | 
				
			||||||
 | 
						defer c.Unlock()
 | 
				
			||||||
	c.WatchReactionChain = append([]WatchReactor{&SimpleWatchReactor{resource, reaction}}, c.WatchReactionChain...)
 | 
						c.WatchReactionChain = append([]WatchReactor{&SimpleWatchReactor{resource, reaction}}, c.WatchReactionChain...)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user