mirror of
https://github.com/goharbor/harbor.git
synced 2025-02-07 15:31:26 +01:00
remove limitation of artifact in the GC job (#12595)
To handle the orphan blobs that created in the quota exceeding case deletion, remove the limition of artifact remove. Signed-off-by: wang yan <wangyan@vmware.com>
This commit is contained in:
parent
b2593589ec
commit
cf46775fd7
@ -184,11 +184,9 @@ func (gc *GarbageCollector) mark(ctx job.Context) error {
|
|||||||
gc.logger.Errorf("failed to get deleted Artifacts in gc job, with error: %v", err)
|
gc.logger.Errorf("failed to get deleted Artifacts in gc job, with error: %v", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
// no need to execute GC as there is no removed artifacts.
|
// just log it, the job will continue to execute, the orphan blobs that created in the quota exceeding case can be removed.
|
||||||
// Do this is to handle if user trigger GC job several times, only one job should do the following logic as artifact trash table is flushed.
|
|
||||||
if len(arts) == 0 {
|
if len(arts) == 0 {
|
||||||
gc.logger.Info("no need to execute GC as there is no removed artifacts.")
|
gc.logger.Warning("no removed artifacts.")
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
gc.trashedArts = arts
|
gc.trashedArts = arts
|
||||||
|
|
||||||
|
@ -221,6 +221,28 @@ func (suite *gcTestSuite) TestRun() {
|
|||||||
|
|
||||||
mock.OnAnything(suite.blobMgr, "CleanupAssociationsForProject").Return(nil)
|
mock.OnAnything(suite.blobMgr, "CleanupAssociationsForProject").Return(nil)
|
||||||
|
|
||||||
|
mock.OnAnything(suite.blobMgr, "UselessBlobs").Return([]*pkg_blob.Blob{
|
||||||
|
{
|
||||||
|
ID: 1,
|
||||||
|
Digest: suite.DigestString(),
|
||||||
|
ContentType: schema2.MediaTypeManifest,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ID: 2,
|
||||||
|
Digest: suite.DigestString(),
|
||||||
|
ContentType: schema2.MediaTypeLayer,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ID: 3,
|
||||||
|
Digest: suite.DigestString(),
|
||||||
|
ContentType: schema2.MediaTypeManifest,
|
||||||
|
},
|
||||||
|
}, nil)
|
||||||
|
|
||||||
|
mock.OnAnything(suite.blobMgr, "UpdateBlobStatus").Return(int64(1), nil)
|
||||||
|
|
||||||
|
mock.OnAnything(suite.blobMgr, "Delete").Return(nil)
|
||||||
|
|
||||||
gc := &GarbageCollector{
|
gc := &GarbageCollector{
|
||||||
artCtl: suite.artifactCtl,
|
artCtl: suite.artifactCtl,
|
||||||
artrashMgr: suite.artrashMgr,
|
artrashMgr: suite.artrashMgr,
|
||||||
|
Loading…
Reference in New Issue
Block a user