feat(scheduler): pass the shutdown/reload ctx to running tasks (#1671)

Signed-off-by: Petu Eusebiu <peusebiu@cisco.com>
This commit is contained in:
peusebiu
2023-09-05 19:48:56 +03:00
committed by GitHub
parent a0290b4b37
commit 59dc4c3229
28 changed files with 190 additions and 143 deletions
+4 -3
View File
@@ -2,6 +2,7 @@ package storage
import (
"bytes"
"context"
"encoding/json"
"errors"
"fmt"
@@ -1032,9 +1033,9 @@ func newDedupeTask(imgStore storageTypes.ImageStore, digest godigest.Digest, ded
return &dedupeTask{imgStore, digest, duplicateBlobs, dedupe, log}
}
func (dt *dedupeTask) DoWork() error {
func (dt *dedupeTask) DoWork(ctx context.Context) error {
// run task
err := dt.imgStore.RunDedupeForDigest(dt.digest, dt.dedupe, dt.duplicateBlobs)
err := dt.imgStore.RunDedupeForDigest(dt.digest, dt.dedupe, dt.duplicateBlobs) //nolint: contextcheck
if err != nil {
// log it
dt.log.Error().Err(err).Str("digest", dt.digest.String()).Msg("rebuild dedupe: failed to rebuild digest")
@@ -1112,7 +1113,7 @@ func NewGCTask(imgStore storageTypes.ImageStore, repo string,
return &gcTask{imgStore, repo}
}
func (gct *gcTask) DoWork() error {
func (gct *gcTask) DoWork(ctx context.Context) error {
// run task
return gct.imgStore.RunGCRepo(gct.repo)
}