Skip to content

Commit

Permalink
add fail lock
Browse files Browse the repository at this point in the history
Signed-off-by: allenshen <[email protected]>
  • Loading branch information
AllenShen committed Feb 9, 2022
1 parent 6209371 commit 19acd74
Showing 1 changed file with 3 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2480,6 +2480,7 @@ func intervalExecutor(interval time.Duration, serviceList []*commonmodels.Servic
return nil
}
wg := sync.WaitGroup{}
var failLock sync.Mutex
wg.Add(len(serviceList))
errList := make([]error, 0)
ticker := time.NewTicker(interval)
Expand All @@ -2490,6 +2491,8 @@ func intervalExecutor(interval time.Duration, serviceList []*commonmodels.Servic
defer wg.Done()
err := handler(singleService, isRetry, log)
if err != nil {
failLock.Lock()
defer failLock.Unlock()
errList = append(errList, err)
*failedServices = append(*failedServices, singleService)
log.Errorf("service:%s apply failed, err %s", singleService.ServiceName, err)
Expand Down

0 comments on commit 19acd74

Please sign in to comment.