mirror of
https://github.com/goharbor/harbor.git
synced 2024-12-30 12:38:17 +01:00
fix(gc,quota): clean blob size cache in redis when gc
Closes #9151 Signed-off-by: He Weiwei <hweiwei@vmware.com>
This commit is contained in:
parent
70bca1251d
commit
cc86664730
@ -17,6 +17,7 @@ package gc
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/garyburd/redigo/redis"
|
"github.com/garyburd/redigo/redis"
|
||||||
@ -29,7 +30,6 @@ import (
|
|||||||
"github.com/goharbor/harbor/src/jobservice/logger"
|
"github.com/goharbor/harbor/src/jobservice/logger"
|
||||||
"github.com/goharbor/harbor/src/pkg/types"
|
"github.com/goharbor/harbor/src/pkg/types"
|
||||||
"github.com/goharbor/harbor/src/registryctl/client"
|
"github.com/goharbor/harbor/src/registryctl/client"
|
||||||
"strconv"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -38,6 +38,7 @@ const (
|
|||||||
dialWriteTimeout = 10 * time.Second
|
dialWriteTimeout = 10 * time.Second
|
||||||
blobPrefix = "blobs::*"
|
blobPrefix = "blobs::*"
|
||||||
repoPrefix = "repository::*"
|
repoPrefix = "repository::*"
|
||||||
|
uploadSizePattern = "upload:*:size"
|
||||||
)
|
)
|
||||||
|
|
||||||
// GarbageCollector is the struct to run registry's garbage collection
|
// GarbageCollector is the struct to run registry's garbage collection
|
||||||
@ -156,15 +157,13 @@ func (gc *GarbageCollector) cleanCache() error {
|
|||||||
// sample of keys in registry redis:
|
// sample of keys in registry redis:
|
||||||
// 1) "blobs::sha256:1a6fd470b9ce10849be79e99529a88371dff60c60aab424c077007f6979b4812"
|
// 1) "blobs::sha256:1a6fd470b9ce10849be79e99529a88371dff60c60aab424c077007f6979b4812"
|
||||||
// 2) "repository::library/hello-world::blobs::sha256:4ab4c602aa5eed5528a6620ff18a1dc4faef0e1ab3a5eddeddb410714478c67f"
|
// 2) "repository::library/hello-world::blobs::sha256:4ab4c602aa5eed5528a6620ff18a1dc4faef0e1ab3a5eddeddb410714478c67f"
|
||||||
err = delKeys(con, blobPrefix)
|
// 3) "upload:fbd2e0a3-262d-40bb-abe4-2f43aa6f9cda:size"
|
||||||
if err != nil {
|
patterns := []string{blobPrefix, repoPrefix, uploadSizePattern}
|
||||||
gc.logger.Errorf("failed to clean registry cache %v, pattern blobs::*", err)
|
for _, pattern := range patterns {
|
||||||
return err
|
if err := delKeys(con, pattern); err != nil {
|
||||||
}
|
gc.logger.Errorf("failed to clean registry cache %v, pattern %s", err, pattern)
|
||||||
err = delKeys(con, repoPrefix)
|
return err
|
||||||
if err != nil {
|
}
|
||||||
gc.logger.Errorf("failed to clean registry cache %v, pattern repository::*", err)
|
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
Loading…
Reference in New Issue
Block a user