Fix image usage calculation error
Including snapshotter usage in total calculation should be gated by the option `snapshotter` boolean. Signed-off-by: Phil Estes <estesp@linux.vnet.ibm.com>
This commit is contained in:
parent
4e08c2de67
commit
0c9b05fa60
2
image.go
2
image.go
@ -203,6 +203,7 @@ func (i *image) Usage(ctx context.Context, opts ...UsageOpt) (int64, error) {
|
|||||||
desc.Size = info.Size
|
desc.Size = info.Size
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if config.snapshots {
|
||||||
for k, v := range info.Labels {
|
for k, v := range info.Labels {
|
||||||
const prefix = "containerd.io/gc.ref.snapshot."
|
const prefix = "containerd.io/gc.ref.snapshot."
|
||||||
if !strings.HasPrefix(k, prefix) {
|
if !strings.HasPrefix(k, prefix) {
|
||||||
@ -224,6 +225,7 @@ func (i *image) Usage(ctx context.Context, opts ...UsageOpt) (int64, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Ignore unknown sizes. Generally unknown sizes should
|
// Ignore unknown sizes. Generally unknown sizes should
|
||||||
// never be set in manifests, however, the usage
|
// never be set in manifests, however, the usage
|
||||||
|
@ -180,6 +180,7 @@ func TestImageUsage(t *testing.T) {
|
|||||||
|
|
||||||
// Pin image name to specific version for future fetches
|
// Pin image name to specific version for future fetches
|
||||||
imageName = imageName + "@" + image.Target().Digest.String()
|
imageName = imageName + "@" + image.Target().Digest.String()
|
||||||
|
defer client.ImageService().Delete(ctx, imageName, images.SynchronousDelete())
|
||||||
|
|
||||||
// Fetch single platforms, but all manifests pulled
|
// Fetch single platforms, but all manifests pulled
|
||||||
if _, err := client.Fetch(ctx, imageName, WithPlatformMatcher(testPlatform), WithAllMetadata()); err != nil {
|
if _, err := client.Fetch(ctx, imageName, WithPlatformMatcher(testPlatform), WithAllMetadata()); err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user