Skip to content

Conversation

@ndeloof
Copy link
Collaborator

@ndeloof ndeloof commented Jul 12, 2022

- What I did
implement GetContainerLayerSize using containerd snapshotter
container's RW layer (i.e active snapshot) size is available as a standard snapshotter API
container's virtual size isn't but can be computed as base image size (which we already have computation logic in place) + active snapshot size

@ndeloof ndeloof requested review from rumpl, thaJeztah and vvoland July 12, 2022 13:59
@ndeloof ndeloof force-pushed the GetContainerLayerSize branch from a6814a3 to e754dff Compare July 12, 2022 14:44
if err != nil {
return 0, 0, err
}
return size, size + virtualSize, nil
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went looking "why are we also including the image size here?" but it's just some odd thing from the past I guess 🤷‍♂️

Comment on lines 31 to +32
logrus.Errorf("Failed to compute size of container rootfs %v: %v", containerID, err)
return sizeRw, sizeRootfs
return sizeRw, sizeRootfs, nil
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like the old code didn't return the error if we failed to get the size; not sure why that was done (could've been to make sure that docker inspect also worked on a dead container); should we (for now) keep the same behaviour?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm.. not sure why it was; looking at this code, it looks like we're already returning early if there's no RWLayer 🤔 https://github.com/moby/moby/blob/7b9275c0da707b030e62c96b679a976f31f929d3/daemon/inspect.go#L187-L192

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Log was added in moby@77ae978 (but possibly because the function didn't have an error return; size was added in moby@a91b710 (no mention of error handling there)

@ndeloof ndeloof force-pushed the GetContainerLayerSize branch 2 times, most recently from cefb3ab to 6c51341 Compare July 12, 2022 16:20
@ndeloof ndeloof force-pushed the GetContainerLayerSize branch 3 times, most recently from 44d5f62 to 5cdf491 Compare July 25, 2022 09:03
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
@ndeloof ndeloof force-pushed the GetContainerLayerSize branch from 5cdf491 to 96c85f8 Compare July 25, 2022 12:13
@ndeloof ndeloof merged commit 94503af into rumpl:master Jul 25, 2022
@ndeloof ndeloof deleted the GetContainerLayerSize branch July 25, 2022 16:16
@thaJeztah thaJeztah mentioned this pull request Sep 1, 2022
@thaJeztah
Copy link
Collaborator

This one should be upstreamed together with #46

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants