File tree Expand file tree Collapse file tree 2 files changed +9
-12
lines changed Expand file tree Collapse file tree 2 files changed +9
-12
lines changed Original file line number Diff line number Diff line change @@ -257,9 +257,11 @@ func (m *Manager) Run(ctx context.Context) {
257257
258258 close (m .started )
259259
260+ // copy to prevent data race when setting the stopChannel to nil
261+ stopChannel := m .stopChannel
260262 for {
261263 select {
262- case signalChannel := <- m . stopChannel :
264+ case signalChannel := <- stopChannel :
263265 m .logger .Debugf ("got stop signal" )
264266 m .stopPipelines (ctx )
265267 m .pipelinesWaitGroup .Wait ()
@@ -291,14 +293,9 @@ func (m *Manager) Stop(ctx context.Context) error {
291293 m .logger .Info ("stopping manager" )
292294 signalChannel := make (chan error , 1 )
293295
294- if m .stopChannel == nil {
295- return nil
296- }
297-
298296 select {
299297 case m .stopChannel <- signalChannel :
300298 close (m .stopChannel )
301- m .stopChannel = nil
302299 m .logger .Debug ("stopping manager signal sent" )
303300 select {
304301 case <- signalChannel :
Original file line number Diff line number Diff line change @@ -33,12 +33,6 @@ func startManager(
3333 WithSyncPeriod (time .Second ),
3434 )
3535 go manager .Run (ctx )
36- t .Cleanup (func () {
37- ctx , cancel := context .WithTimeout (ctx , time .Second )
38- defer cancel ()
39-
40- require .NoError (t , manager .Stop (ctx ))
41- })
4236
4337 return manager
4438}
@@ -122,6 +116,9 @@ func TestManagerExportersNominal(t *testing.T) {
122116 driverFactory ,
123117 exporterConfigValidator ,
124118 )
119+ t .Cleanup (func () {
120+ require .NoError (t , manager .Stop (ctx ))
121+ })
125122 <- manager .Started ()
126123
127124 err := manager .StartPipeline (ctx , pipeline .ID )
@@ -208,6 +205,9 @@ func TestManagerExportersUpdate(t *testing.T) {
208205 driverFactory ,
209206 exporterConfigValidator ,
210207 )
208+ t .Cleanup (func () {
209+ require .NoError (t , manager .Stop (ctx ))
210+ })
211211 <- manager .Started ()
212212
213213 err := manager .StartPipeline (ctx , pipeline .ID )
You can’t perform that action at this time.
0 commit comments