Unverified Commit 262f22f5 authored by Wang Yan's avatar Wang Yan Committed by GitHub
Browse files

fix gc log issue (#12943)



1, Do not log redis url, just log the user input from UI.
2, Format the artifact trash items.
Signed-off-by: default avatarwang yan <wangyan@vmware.com>
parent 05489fca
......@@ -112,7 +112,6 @@ func (gc *GarbageCollector) init(ctx job.Context, params job.Parameters) error {
// parseParams set the parameters according to the GC API call.
func (gc *GarbageCollector) parseParams(params job.Parameters) {
// redis url
gc.logger.Info(params)
gc.redisURL = params["redis_url_reg"].(string)
// delete untagged: default is to delete the untagged artifact
......@@ -141,6 +140,9 @@ func (gc *GarbageCollector) parseParams(params job.Parameters) {
gc.dryRun = dryRun
}
}
gc.logger.Infof("Garbage Collection parameters: [delete_untagged: %t, dry_run: %t, time_window: %d]",
gc.deleteUntagged, gc.dryRun, gc.timeWindowHours)
}
// Run implements the interface in job/Interface
......@@ -395,18 +397,21 @@ func (gc *GarbageCollector) deletedArt(ctx job.Context) (map[string][]model.Arti
}
// group the deleted artifact by digest. The repositories of blob is needed when to delete as a manifest.
for _, art := range arts {
_, exist := artMap[art.Digest]
if !exist {
artMap[art.Digest] = []model.ArtifactTrash{art}
} else {
repos := artMap[art.Digest]
repos = append(repos, art)
artMap[art.Digest] = repos
if len(arts) > 0 {
gc.logger.Info("artifact trash candidates.")
for _, art := range arts {
gc.logger.Info(art.String())
_, exist := artMap[art.Digest]
if !exist {
artMap[art.Digest] = []model.ArtifactTrash{art}
} else {
repos := artMap[art.Digest]
repos = append(repos, art)
artMap[art.Digest] = repos
}
}
}
gc.logger.Info("required candidate: %+v", arts)
return artMap, nil
}
......
......@@ -15,6 +15,7 @@
package model
import (
"fmt"
"github.com/astaxie/beego/orm"
"time"
)
......@@ -37,3 +38,8 @@ type ArtifactTrash struct {
func (at *ArtifactTrash) TableName() string {
return "artifact_trash"
}
func (at *ArtifactTrash) String() string {
return fmt.Sprintf("ID-%d MediaType-%s ManifestMediaType-%s RepositoryName-%s Digest-%s CreationTime-%s",
at.ID, at.MediaType, at.ManifestMediaType, at.RepositoryName, at.Digest, at.CreationTime.Format("2006-01-02 15:04:05"))
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment