0
Fork 0
mirror of https://github.com/project-zot/zot.git synced 2024-12-16 21:56:37 -05:00
zot/pkg/api
peusebiu 7642e5af98
fix(scheduler): fix data race (#2085)
* fix(scheduler): data race when pushing new tasks

the problem here is that scheduler can be closed in two ways:
- canceling the context given as argument to scheduler.RunScheduler()
- running scheduler.Shutdown()

because of this shutdown can trigger a data race between calling scheduler.inShutdown()
and actually pushing tasks into the pool workers

solved that by keeping a quit channel and listening on both quit channel and ctx.Done()
and closing the worker chan and scheduler afterwards.

Signed-off-by: Petu Eusebiu <peusebiu@cisco.com>

* refactor(scheduler): refactor into a single shutdown

before this we could stop scheduler either by closing the context
provided to RunScheduler(ctx) or by running Shutdown().

simplify things by getting rid of the external context in RunScheduler().
keep an internal context in the scheduler itself and pass it down to all tasks.

Signed-off-by: Petu Eusebiu <peusebiu@cisco.com>

---------

Signed-off-by: Petu Eusebiu <peusebiu@cisco.com>
2023-12-11 10:00:34 -08:00
..
config feat(ldap): add option to load ldap from file (#1778) 2023-11-14 16:21:36 -08:00
constants feat: use the "zot" namespace for the authentication url (#1947) 2023-10-20 15:30:56 +03:00
errors fix: metrics endpoint must be secured behind authN (#1864) 2023-10-02 16:37:21 +03:00
authn.go refactor(test): add lint rule for messages starting with the component (#2045) 2023-12-08 10:05:02 +02:00
authn_test.go fix(scheduler): fix data race (#2085) 2023-12-11 10:00:34 -08:00
authz.go fix: metrics should be protected behind authZ (#1895) 2023-10-20 10:33:26 +03:00
controller.go fix(scheduler): fix data race (#2085) 2023-12-11 10:00:34 -08:00
controller_test.go fix(scheduler): fix data race (#2085) 2023-12-11 10:00:34 -08:00
cookiestore.go fix(scheduler): fix data race (#2085) 2023-12-11 10:00:34 -08:00
ldap.go refactor(test): add lint rule for messages starting with the component (#2045) 2023-12-08 10:05:02 +02:00
routes.go refactor(test): add lint rule for messages starting with the component (#2045) 2023-12-08 10:05:02 +02:00
routes_test.go fix: tests refactoring (#1950) 2023-10-26 11:20:39 +03:00
session.go refactor(test): add lint rule for messages starting with the component (#2045) 2023-12-08 10:05:02 +02:00