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

fix: handle ancient empty docker layers #522

Merged
merged 1 commit into from
Oct 26, 2023

Conversation

rchincha
Copy link
Contributor

@rchincha rchincha commented Oct 4, 2023

Earlier versions of docker images had empty layers of 1024 zero-valued octets.

What type of PR is this?

Which issue does this PR fix:

What does this PR do / Why do we need it:

If an issue # is not available please add repro steps and logs showing the issue:

Testing done on this change:

Automation added to e2e:

Will this break upgrades or downgrades?

Does this PR introduce any user-facing change?:


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@rchincha rchincha requested review from smoser and hallyn as code owners October 4, 2023 23:37
@hallyn
Copy link
Contributor

hallyn commented Oct 5, 2023

@rchincha the only file in the only patch is a .bats file. Did you forget some git-add action?

@codecov
Copy link

codecov bot commented Oct 5, 2023

Codecov Report

Merging #522 (e761a50) into main (0cf2d70) will decrease coverage by 0.03%.
The diff coverage is 0.00%.

@@            Coverage Diff             @@
##             main     #522      +/-   ##
==========================================
- Coverage   13.34%   13.32%   -0.03%     
==========================================
  Files          40       40              
  Lines        5852     5863      +11     
==========================================
  Hits          781      781              
- Misses       4943     4954      +11     
  Partials      128      128              
Files Coverage Δ
pkg/types/layer_type.go 0.00% <0.00%> (ø)
pkg/log/log.go 55.31% <0.00%> (-2.46%) ⬇️
pkg/stacker/base.go 0.00% <0.00%> (ø)
pkg/overlay/metadata.go 0.00% <0.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@rchincha
Copy link
Contributor Author

rchincha commented Oct 5, 2023

@rchincha the only file in the only patch is a .bats file. Did you forget some git-add action?

3 files right?

test/docker-base.bats Outdated Show resolved Hide resolved
@rchincha
Copy link
Contributor Author

Without this PR, the same test fails.
#525

A real-world image has been copied over to ghcr.io so should be internal without any dependency on dockerhub.

@raharper
Copy link
Contributor

https://github.com/containers/image/blob/main/image/docker_schema2.go
https://github.com/containers/image/blob/main/internal/image/docker_schema2.go

I think this means it is a well-known type -- can we test if the image has the matching sha256?

I'm going to see if I can programmatically create a simple image with such a layer.

@rchincha
Copy link
Contributor Author

https://github.com/containers/image/blob/main/image/docker_schema2.go https://github.com/containers/image/blob/main/internal/image/docker_schema2.go

I think this means it is a well-known type -- can we test if the image has the matching sha256?

I'm going to see if I can programmatically create a simple image with such a layer.

A single layer doesn't make sense IMO. What Dockerfile directive would make only that?

@rchincha
Copy link
Contributor Author

@raharper
Copy link
Contributor

https://github.com/containers/image/blob/main/image/docker_schema2.go https://github.com/containers/image/blob/main/internal/image/docker_schema2.go
I think this means it is a well-known type -- can we test if the image has the matching sha256?
I'm going to see if I can programmatically create a simple image with such a layer.

A single layer doesn't make sense IMO. What Dockerfile directive would make only that?

ENV or RUN; any command that doesn't actually modify the rootfs. Why? I do not know.

@rchincha rchincha closed this Oct 18, 2023
@rchincha rchincha reopened this Oct 18, 2023
@rchincha
Copy link
Contributor Author

FROM scratch
ENV a=b

gives us

{
  "schemaVersion": 2,
  "mediaType": "application/vnd.oci.image.manifest.v1+json",
  "config": {
    "mediaType": "application/vnd.oci.image.config.v1+json",
    "digest": "sha256:2b4a446f5ab37b5895b62507c572303f16ab4f8d9161a35799c994301722d3d5",
    "size": 334
  },
  "layers": []
}

@rchincha rchincha added this to the v1.0.0 milestone Oct 19, 2023
@rchincha rchincha force-pushed the empty-layer branch 2 times, most recently from acb522e to c370eb2 Compare October 23, 2023 18:05
@rchincha
Copy link
Contributor Author

Included your example in the unit tests.

@rchincha rchincha force-pushed the empty-layer branch 2 times, most recently from 100addb to 78da0a8 Compare October 25, 2023 22:38
Earlier versions of docker images had empty layers of 1024 zero-valued
octets.

moby/moby#20917 (comment)

Signed-off-by: Ramkumar Chinchani <[email protected]>
@rchincha
Copy link
Contributor Author

Will move the ghcr test to a SLOW_TEST (nightly) once you review/approve

@raharper
Copy link
Contributor

This PR should close #525 right?

@rchincha
Copy link
Contributor Author

This PR should close #525 right?

Correct, PR #525 was only to demo that this PR is needed.

@rchincha rchincha merged commit f0f9642 into project-stacker:main Oct 26, 2023
7 of 9 checks passed
rchincha added a commit to rchincha/stacker that referenced this pull request Nov 8, 2023
Earlier versions of docker images had empty layers of 1024 zero-valued
octets.

moby/moby#20917 (comment)

Signed-off-by: Ramkumar Chinchani <[email protected]>
(cherry picked from commit f0f9642)
rchincha added a commit to rchincha/stacker that referenced this pull request Nov 8, 2023
Earlier versions of docker images had empty layers of 1024 zero-valued
octets.

moby/moby#20917 (comment)

Signed-off-by: Ramkumar Chinchani <[email protected]>
(cherry picked from commit f0f9642)
Signed-off-by: Ramkumar Chinchani <[email protected]>
rchincha added a commit to rchincha/stacker that referenced this pull request Nov 8, 2023
Earlier versions of docker images had empty layers of 1024 zero-valued
octets.

moby/moby#20917 (comment)

Signed-off-by: Ramkumar Chinchani <[email protected]>
(cherry picked from commit f0f9642)
Signed-off-by: Ramkumar Chinchani <[email protected]>
rchincha added a commit to rchincha/stacker that referenced this pull request Nov 8, 2023
Earlier versions of docker images had empty layers of 1024 zero-valued
octets.

moby/moby#20917 (comment)

Signed-off-by: Ramkumar Chinchani <[email protected]>
(cherry picked from commit f0f9642)
Signed-off-by: Ramkumar Chinchani <[email protected]>
rchincha added a commit to rchincha/stacker that referenced this pull request Nov 8, 2023
Earlier versions of docker images had empty layers of 1024 zero-valued
octets.

moby/moby#20917 (comment)

(cherry picked from commit f0f9642)

Signed-off-by: Ramkumar Chinchani <[email protected]>
rchincha added a commit that referenced this pull request Nov 8, 2023
Earlier versions of docker images had empty layers of 1024 zero-valued
octets.

moby/moby#20917 (comment)

(cherry picked from commit f0f9642)

Signed-off-by: Ramkumar Chinchani <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants