mirror of
https://github.com/project-zot/zot.git
synced 2026-06-16 20:38:08 +08:00
test: stop task scheduler between test runs (#1311)
sync: remove sync WaitGroup, it's stopped with context sync: onDemand will always try to sync newest image when a tag is used if a digest is used then onDemand will serve local image test(sync): fix flaky coverage in sync package closes #1294 Signed-off-by: Petu Eusebiu <peusebiu@cisco.com>
This commit is contained in:
+9
-1
@@ -283,6 +283,8 @@ type Controller interface {
|
||||
|
||||
type ControllerManager struct {
|
||||
controller Controller
|
||||
// used to stop background tasks(goroutines) - task scheduler
|
||||
cancelRoutinesFunc context.CancelFunc
|
||||
}
|
||||
|
||||
func (cm *ControllerManager) RunServer(ctx context.Context) {
|
||||
@@ -293,7 +295,8 @@ func (cm *ControllerManager) RunServer(ctx context.Context) {
|
||||
}
|
||||
|
||||
func (cm *ControllerManager) StartServer() {
|
||||
ctx := context.Background()
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
cm.cancelRoutinesFunc = cancel
|
||||
|
||||
if err := cm.controller.Init(ctx); err != nil {
|
||||
panic(err)
|
||||
@@ -305,6 +308,11 @@ func (cm *ControllerManager) StartServer() {
|
||||
}
|
||||
|
||||
func (cm *ControllerManager) StopServer() {
|
||||
// stop background tasks - task scheduler
|
||||
if cm.cancelRoutinesFunc != nil {
|
||||
cm.cancelRoutinesFunc()
|
||||
}
|
||||
|
||||
cm.controller.Shutdown()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user