Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
Vad1mo authored Jan 15, 2024
2 parents f847954 + f17d90f commit 5c2e635
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/controller/artifact/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ func (c *controller) ensureArtifact(ctx context.Context, repository, digest stri
if !errors.IsConflictErr(err) {
return false, nil, err
}
log.Debugf("failed to create artifact %s@%s: %v", repository, digest, err)
// if got conflict error, try to get the artifact again
artifact, err = c.artMgr.GetByDigest(ctx, repository, digest)
if err != nil {
Expand Down
15 changes: 15 additions & 0 deletions src/controller/artifact/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,21 @@ func (c *controllerTestSuite) TestEnsureArtifact() {
c.Require().Nil(err)
c.True(created)
c.Equal(int64(1), art.ID)

// reset the mock
c.SetupTest()

// the artifact doesn't exist and get a conflict error on creating the artifact and fail to get again
c.repoMgr.On("GetByName", mock.Anything, mock.Anything).Return(&repomodel.RepoRecord{
ProjectID: 1,
}, nil)
c.artMgr.On("GetByDigest", mock.Anything, mock.Anything, mock.Anything).Return(nil, errors.NotFoundError(nil))
c.artMgr.On("Create", mock.Anything, mock.Anything).Return(int64(1), errors.ConflictError(nil))
c.abstractor.On("AbstractMetadata").Return(nil)
created, art, err = c.ctl.ensureArtifact(orm.NewContext(nil, &ormtesting.FakeOrmer{}), "library/hello-world", digest)
c.Require().Error(err, errors.NotFoundError(nil))
c.False(created)
c.Require().Nil(art)
}

func (c *controllerTestSuite) TestEnsure() {
Expand Down
1 change: 0 additions & 1 deletion src/lib/config/userconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,6 @@ func SkipAuditLogDatabase(ctx context.Context) bool {

// ScannerSkipUpdatePullTime returns the scanner skip update pull time setting
func ScannerSkipUpdatePullTime(ctx context.Context) bool {
log.Infof("skip_update_pull_time:%v", DefaultMgr().Get(ctx, common.ScannerSkipUpdatePullTime).GetBool())
return DefaultMgr().Get(ctx, common.ScannerSkipUpdatePullTime).GetBool()
}

Expand Down

0 comments on commit 5c2e635

Please sign in to comment.