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

chore: add isManifest function to determine a manifest #6707

Merged
merged 5 commits into from
Apr 8, 2024

Conversation

cdrage
Copy link
Contributor

@cdrage cdrage commented Apr 8, 2024

chore: add isManifest function to determine a manifest

What does this PR do?

Adds a guessIsManifest function to try and determine if an image is a
manifest or not:

  • By checking the repotags and digests
  • Checking labels does not exist, as labels are not added when creating
    a manifest
  • VirtualSize is under 1MB as a manifest list is just text that points
    to other images

We are unable to check the history (manifest commonly has no history) as
Dockerode API does not support getting the history of the image.

Screenshot / video of UI

N/A

What issues does this PR fix or reference?

Closes #6690

How to test this PR?

  • Tests are covering the bug fix or the new feature

Signed-off-by: Charlie Drage charlie@charliedrage.com

@cdrage cdrage requested review from benoitf and a team as code owners April 8, 2024 13:47
@cdrage cdrage requested review from dgolovin and axel7083 and removed request for a team April 8, 2024 13:47
@cdrage cdrage force-pushed the add-is-manifest branch 2 times, most recently from b1df702 to c497fcb Compare April 8, 2024 14:00
@cdrage cdrage marked this pull request as draft April 8, 2024 14:49
@cdrage
Copy link
Contributor Author

cdrage commented Apr 8, 2024

Switching to draft for two things:

  • Check that the engine is podman
  • Check history is blank

You are right @benoitf with docker.io/hello-world it would be considered a manifest due to the small size:

  {
    "Id": "ee301c921b8aadc002973b2e0c3da17d701dcd994b606769a7e6eaa100b81d44",
    "ParentId": "",
    "RepoTags": [
      "docker.io/library/hello-world:latest"
    ],
    "RepoDigests": [
      "docker.io/library/hello-world@sha256:2d4e459f4ecb5329407ae3e47cbc107a2fbace221354ca75960af4c047b3cb13",
      "docker.io/library/hello-world@sha256:53641cd209a4fecfc68e21a99871ce8c6920b2e7502df0a20671c6fccc73a7c6"
    ],
    "Created": 1683046167,
    "Size": 23301,
    "SharedSize": 0,
    "VirtualSize": 23301,
    "Labels": null,
    "Containers": 0,
    "Names": [
      "docker.io/library/hello-world:latest"
    ],
    "Digest": "sha256:53641cd209a4fecfc68e21a99871ce8c6920b2e7502df0a20671c6fccc73a7c6",
    "History": [
      "docker.io/library/hello-world:latest"
    ]
  }

So we have to make sure history is blank / does not exist as well.

@cdrage
Copy link
Contributor Author

cdrage commented Apr 8, 2024

Updated and ready for review.

Requires #6713 before merging.

  • Switched to 50KB max for the manifest size
  • Updated tests
  • Check for null / empty history
  • Check engine name matches to 'podman'

@cdrage cdrage marked this pull request as ready for review April 8, 2024 18:18
@cdrage
Copy link
Contributor Author

cdrage commented Apr 8, 2024

TODO:

  • Add test for the following output and making sure it's "not a manifest":
  {
    "Id": "ee301c921b8aadc002973b2e0c3da17d701dcd994b606769a7e6eaa100b81d44",
    "ParentId": "",
    "RepoTags": [
      "docker.io/library/hello-world:latest"
    ],
    "RepoDigests": [
      "docker.io/library/hello-world@sha256:2d4e459f4ecb5329407ae3e47cbc107a2fbace221354ca75960af4c047b3cb13",
      "docker.io/library/hello-world@sha256:53641cd209a4fecfc68e21a99871ce8c6920b2e7502df0a20671c6fccc73a7c6"
    ],
    "Created": 1683046167,
    "Size": 23301,
    "SharedSize": 0,
    "VirtualSize": 23301,
    "Labels": null,
    "Containers": 0,
    "Names": [
      "docker.io/library/hello-world:latest"
    ],
    "Digest": "sha256:53641cd209a4fecfc68e21a99871ce8c6920b2e7502df0a20671c6fccc73a7c6",
    "History": [
      "docker.io/library/hello-world:latest"
    ]
  }

@cdrage
Copy link
Contributor Author

cdrage commented Apr 8, 2024

Ready for another review, test has been added 💯

### What does this PR do?

Adds a guessIsManifest function to try and determine if an image is a
manifest or not:

- By checking the repotags and digests
- Checking labels does not exist, as labels are not added when creating
  a manifest
- VirtualSize is under 1MB as a manifest list is just text that points
  to other images

We are unable to check the history (manifest commonly has no history) as
Dockerode API does not support getting the history of the image.

### Screenshot / video of UI

<!-- If this PR is changing UI, please include
screenshots or screencasts showing the difference -->

N/A

### What issues does this PR fix or reference?

<!-- Include any related issues from Podman Desktop
repository (or from another issue tracker). -->

Closes  containers#6690

### How to test this PR?

<!-- Please explain steps to verify the functionality,
do not forget to provide unit/component tests -->

- [X] Tests are covering the bug fix or the new feature

Signed-off-by: Charlie Drage <charlie@charliedrage.com>
Signed-off-by: Charlie Drage <charlie@charliedrage.com>
Signed-off-by: Charlie Drage <charlie@charliedrage.com>
packages/main/src/plugin/util/manifest.spec.ts Outdated Show resolved Hide resolved
packages/main/src/plugin/util/manifest.ts Outdated Show resolved Hide resolved
Signed-off-by: Charlie Drage <charlie@charliedrage.com>
@benoitf
Copy link
Collaborator

benoitf commented Apr 8, 2024

still approving

Co-authored-by: Florent BENOIT <fbenoit@redhat.com>
Signed-off-by: Charlie Drage <charlie@charliedrage.com>
@benoitf benoitf enabled auto-merge (squash) April 8, 2024 21:13
@benoitf benoitf merged commit b3dc71f into containers:main Apr 8, 2024
8 checks passed
@podman-desktop-bot podman-desktop-bot added this to the 1.10.0 milestone Apr 8, 2024
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.

Add functionality to guess if an image is a manifest
3 participants