0
Fork 0
mirror of https://github.com/project-zot/zot.git synced 2024-12-16 21:56:37 -05:00
zot/pkg/test/mocks
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
..
cache_mock.go refactor(storage): refactor storage into a single ImageStore (#1656) 2023-09-01 10:54:39 -07:00
cve_mock.go feat(scheduler): gracefully shutdown (#1951) 2023-11-24 00:40:10 -08:00
image_store_mock.go feat(scheduler): gracefully shutdown (#1951) 2023-11-24 00:40:10 -08:00
lint_mock.go refactor(storage): refactoring storage (#1459) 2023-05-26 11:08:19 -07:00
oci_mock.go refactor: remove pkg/extensions/search/common and move the code to the appropriate packages (#1358) 2023-04-18 11:07:47 -07:00
repo_db_mock.go feat(metadb): add support for querying for images by a blob digest (#2077) 2023-11-27 08:52:52 -08:00
secrets_manager_mock.go fix: add retry logic to recreate existing trustpolicy secret (#1776) 2023-09-11 10:13:22 +03:00
storage_driver_mock.go Update go version to 1.19 (#829) 2022-10-05 13:21:14 +03:00
sync_remote_mock.go fix(scheduler): fix data race (#2085) 2023-12-11 10:00:34 -08:00