Option to configure proxy cache TTL
Currently when registry is run as proxy it tries to cleanup unused blobs from its cache after 7 days which is hard-coded. This PR makes that value configurable. Co-authored-by: Shiming Zhang <wzshiming@foxmail.com> Co-authored-by: Manish Tomar <manish.tomar@docker.com> Signed-off-by: Shiming Zhang <wzshiming@foxmail.com>
This commit is contained in:
parent
0c958010ac
commit
8fe4ca4038
8 changed files with 131 additions and 59 deletions
|
@ -6,18 +6,21 @@ import (
|
|||
"net/http"
|
||||
"strconv"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/opencontainers/go-digest"
|
||||
|
||||
"github.com/distribution/distribution/v3"
|
||||
dcontext "github.com/distribution/distribution/v3/context"
|
||||
"github.com/distribution/distribution/v3/reference"
|
||||
"github.com/distribution/distribution/v3/registry/proxy/scheduler"
|
||||
"github.com/opencontainers/go-digest"
|
||||
)
|
||||
|
||||
type proxyBlobStore struct {
|
||||
localStore distribution.BlobStore
|
||||
remoteStore distribution.BlobService
|
||||
scheduler *scheduler.TTLExpirationScheduler
|
||||
ttl *time.Duration
|
||||
repositoryName reference.Named
|
||||
authChallenger authChallenger
|
||||
}
|
||||
|
@ -146,7 +149,10 @@ func (pbs *proxyBlobStore) ServeBlob(ctx context.Context, w http.ResponseWriter,
|
|||
return
|
||||
}
|
||||
|
||||
pbs.scheduler.AddBlob(blobRef, repositoryTTL)
|
||||
if pbs.scheduler != nil && pbs.ttl != nil {
|
||||
pbs.scheduler.AddBlob(blobRef, *pbs.ttl)
|
||||
}
|
||||
|
||||
}(dgst)
|
||||
|
||||
_, err = pbs.copyContent(ctx, dgst, w)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue