0
Fork 0
mirror of https://github.com/project-zot/zot.git synced 2025-02-17 23:45:36 -05:00

Fix negative WaitGroup counter at runtime

Signed-off-by: Petu Eusebiu <peusebiu@cisco.com>
This commit is contained in:
Petu Eusebiu 2021-12-17 18:37:02 +02:00 committed by Ramkumar Chinchani
parent fc4a34d43a
commit 5f04092e71

View file

@ -476,9 +476,6 @@ func Run(cfg Config, storeController storage.StoreController, wg *goSync.WaitGro
continue continue
} }
// increment reference since will be busy, so shutdown has to wait
wg.Add(1)
ticker := time.NewTicker(regCfg.PollInterval) ticker := time.NewTicker(regCfg.PollInterval)
// fork a new zerolog child to avoid data race // fork a new zerolog child to avoid data race
@ -490,6 +487,9 @@ func Run(cfg Config, storeController storage.StoreController, wg *goSync.WaitGro
go func(regCfg RegistryConfig, l log.Logger) { go func(regCfg RegistryConfig, l log.Logger) {
// run on intervals // run on intervals
for ; true; <-ticker.C { for ; true; <-ticker.C {
// increment reference since will be busy, so shutdown has to wait
wg.Add(1)
if err := syncRegistry(regCfg, storeController, l, localCtx, policyCtx, if err := syncRegistry(regCfg, storeController, l, localCtx, policyCtx,
credentialsFile[upstreamRegistry], uuid.String()); err != nil { credentialsFile[upstreamRegistry], uuid.String()); err != nil {
l.Error().Err(err).Msg("sync exited with error, stopping it...") l.Error().Err(err).Msg("sync exited with error, stopping it...")