Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

c8d/list: Fix Total size calculation #48330

Merged
merged 3 commits into from
Aug 14, 2024

Conversation

vvoland
Copy link
Contributor

@vvoland vvoland commented Aug 14, 2024

- What I did
Fixed a bug where individual image sub-manifests were also accumulating the total size of the image.

- How I did it

- How to verify it
TestImageListCheckTotalSize

- Description for the changelog

No changelog, as the bug hasn't been released yet

- A picture of a cute animal (not mandatory but encouraged)

@vvoland vvoland added area/images kind/bugfix PR's that fix bugs containerd-integration Issues and PRs related to containerd integration process/cherry-pick/27.x labels Aug 14, 2024
@vvoland vvoland added this to the 28.0.0 milestone Aug 14, 2024
@vvoland vvoland self-assigned this Aug 14, 2024
@vvoland vvoland requested review from thaJeztah and laurazard August 14, 2024 11:54
// readConfig reads content pointed by the descriptor and unmarshals it into a specified output.
func readConfig(ctx context.Context, store content.Provider, desc ocispec.Descriptor, out interface{}) error {
// readJSON reads content pointed by the descriptor and unmarshals it into a specified output.
func readJSON(ctx context.Context, store content.Provider, desc ocispec.Descriptor, out interface{}) error {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Perhaps it could be extracted to the github.com/containerd/containerd/content package.

There's already content.ReadBlob , so I guess it could be named content.ReadJSONBlob.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, except our version also translates the cerrdefs.NotFound into errdefs.NotFound

Copy link
Member

Choose a reason for hiding this comment

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

Ah, except our version also translates the cerrdefs.NotFound into errdefs.NotFound

That problem should probably go away at some point; at least, Derek is working on unifying errdefs to make them interoperable.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
@vvoland vvoland force-pushed the c8d-list-multiplatform-fixsize branch from 578ec00 to 6bb6bef Compare August 14, 2024 12:12
Copy link
Member

@laurazard laurazard left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

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

LGTM

left one question, but good to go if that's not a concern


// contentSize was already added to total, adjust it by the difference
// between the newly calculated size and the old size.
d := imgContentSize - contentSize
Copy link
Member

Choose a reason for hiding this comment

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

Any risk of contentSize being larger than imgContentSize here (so getting negative values?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Possibly, and that's also fine here - if imgContentSize is larger then adding a negative will still adjust the total size correctly.

Copy link
Member

Choose a reason for hiding this comment

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

I had the exact same thought, and then realized it was fine either way 😅

Copy link
Member

Choose a reason for hiding this comment

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

Ha! Yes, it just crossed my mind, so thought I'd double check. Thanks both!

// readConfig reads content pointed by the descriptor and unmarshals it into a specified output.
func readConfig(ctx context.Context, store content.Provider, desc ocispec.Descriptor, out interface{}) error {
// readJSON reads content pointed by the descriptor and unmarshals it into a specified output.
func readJSON(ctx context.Context, store content.Provider, desc ocispec.Descriptor, out interface{}) error {
Copy link
Member

Choose a reason for hiding this comment

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

Ah, except our version also translates the cerrdefs.NotFound into errdefs.NotFound

That problem should probably go away at some point; at least, Derek is working on unifying errdefs to make them interoperable.

@vvoland vvoland merged commit 1c282d1 into moby:master Aug 14, 2024
139 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/images containerd-integration Issues and PRs related to containerd integration kind/bugfix PR's that fix bugs process/cherry-picked
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants