imagemetaresolver: use platform in cache
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>docker-18.09
parent
628681f8e4
commit
c9df92f4c5
|
@ -5,6 +5,7 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
|
"github.com/containerd/containerd/platforms"
|
||||||
"github.com/containerd/containerd/remotes"
|
"github.com/containerd/containerd/remotes"
|
||||||
"github.com/containerd/containerd/remotes/docker"
|
"github.com/containerd/containerd/remotes/docker"
|
||||||
"github.com/docker/docker/pkg/locker"
|
"github.com/docker/docker/pkg/locker"
|
||||||
|
@ -74,19 +75,28 @@ func (imr *imageMetaResolver) ResolveImageConfig(ctx context.Context, ref string
|
||||||
imr.locker.Lock(ref)
|
imr.locker.Lock(ref)
|
||||||
defer imr.locker.Unlock(ref)
|
defer imr.locker.Unlock(ref)
|
||||||
|
|
||||||
if res, ok := imr.cache[ref]; ok {
|
|
||||||
return res.dgst, res.config, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
if platform == nil {
|
if platform == nil {
|
||||||
platform = imr.platform
|
platform = imr.platform
|
||||||
}
|
}
|
||||||
|
|
||||||
|
k := imr.key(ref, platform)
|
||||||
|
|
||||||
|
if res, ok := imr.cache[k]; ok {
|
||||||
|
return res.dgst, res.config, nil
|
||||||
|
}
|
||||||
|
|
||||||
dgst, config, err := imageutil.Config(ctx, ref, imr.resolver, imr.buffer, platform)
|
dgst, config, err := imageutil.Config(ctx, ref, imr.resolver, imr.buffer, platform)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", nil, err
|
return "", nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
imr.cache[ref] = resolveResult{dgst: dgst, config: config}
|
imr.cache[k] = resolveResult{dgst: dgst, config: config}
|
||||||
return dgst, config, nil
|
return dgst, config, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (imr *imageMetaResolver) key(ref string, platform *specs.Platform) string {
|
||||||
|
if platform != nil {
|
||||||
|
ref += platforms.Format(*platform)
|
||||||
|
}
|
||||||
|
return ref
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue