mirror of
https://github.com/project-zot/zot.git
synced 2026-06-17 04:48:26 +08:00
feat(scheduler): gracefully shutdown (#1951)
wait for workers to finish before exiting should fix tests reporting they couldn't remove rootDir because it's being written by tasks Signed-off-by: Petu Eusebiu <peusebiu@cisco.com>
This commit is contained in:
@@ -256,8 +256,12 @@ func (validityT *validityTask) DoWork(ctx context.Context) error {
|
||||
validityT.log.Info().Msg("update signatures validity")
|
||||
|
||||
for signedManifest, sigs := range validityT.repo.Signatures {
|
||||
if zcommon.IsContextDone(ctx) {
|
||||
return ctx.Err()
|
||||
}
|
||||
|
||||
if len(sigs[zcommon.CosignSignature]) != 0 || len(sigs[zcommon.NotationSignature]) != 0 {
|
||||
err := validityT.metaDB.UpdateSignaturesValidity(validityT.repo.Name, godigest.Digest(signedManifest))
|
||||
err := validityT.metaDB.UpdateSignaturesValidity(ctx, validityT.repo.Name, godigest.Digest(signedManifest))
|
||||
if err != nil {
|
||||
validityT.log.Info().Msg("error while verifying signatures")
|
||||
|
||||
|
||||
@@ -1215,6 +1215,13 @@ func RunVerificationTests(t *testing.T, dbDriverParams map[string]interface{}) {
|
||||
repo := "repo" //nolint:goconst
|
||||
tag := "test" //nolint:goconst
|
||||
|
||||
Convey("verify running an image trust with context done", func() {
|
||||
image := CreateRandomImage()
|
||||
|
||||
err = UploadImage(image, baseURL, repo, tag)
|
||||
So(err, ShouldBeNil)
|
||||
})
|
||||
|
||||
Convey("verify cosign signature is trusted", func() {
|
||||
image := CreateRandomImage()
|
||||
|
||||
@@ -1291,6 +1298,18 @@ func RunVerificationTests(t *testing.T, dbDriverParams map[string]interface{}) {
|
||||
So(err, ShouldBeNil)
|
||||
So(isTrusted, ShouldBeTrue)
|
||||
So(author, ShouldNotBeEmpty)
|
||||
|
||||
Convey("run imagetrust task with context done", func() {
|
||||
repoMeta, err := ctlr.MetaDB.GetRepoMeta(context.Background(), repo)
|
||||
So(err, ShouldBeNil)
|
||||
|
||||
cancelCtx, cancel := context.WithCancel(context.Background())
|
||||
cancel()
|
||||
|
||||
task := imagetrust.NewValidityTask(ctlr.MetaDB, repoMeta, ctlr.Log)
|
||||
err = task.DoWork(cancelCtx)
|
||||
So(err, ShouldEqual, cancelCtx.Err())
|
||||
})
|
||||
})
|
||||
|
||||
Convey("verify notation signature is trusted", func() {
|
||||
|
||||
Reference in New Issue
Block a user