Skip to content

feat: Support docker image manifest v2 schema1 scanning #2815

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

Merged

Conversation

jopemachine
Copy link
Member

@jopemachine jopemachine commented Sep 6, 2024

Overview

This PR adds support for docker image manifest V2 schema1 for legacy system.
(Fix https://github.com/lablup/giftbox/issues/719)

About docker image manifest V2 schema1 refer to below link:
https://github.com/openshift/docker-distribution/blob/master/docs/spec/manifest-v2-1.md

Test

Manually tested it by following the steps below.

  1. Create a private docker registry for testing.
❯ docker run -d -p 5000:5000 --restart always --name registry registry:2

The registry returns a content type of application/vnd.docker.distribution.manifest.v1+prettyjws in the response in the /manifests API.

  1. Create a fixture file for testing this registry and apply.
{
    "container_registries": [
        {
            "id": "abc42a05-4471-41fa-8772-10bf6452c7d9",
            "registry_name": "localhost",
            "url": "http://localhost:5000",
            "type": "docker",
            "project": "stable"
        }
    ]
}
❯ ./backend.ai mgr fixture populate ./fixtures/manager/example-container-registries-dockerhub.json
  1. Tag and push an image

Let's assume there is a locally built image named stable/bai-python here.

❯ docker tag stable/bai-python:3.11 localhost:5000/stable/bai-python:3.11
❯ docker push localhost:5000/stable/bai-python:3.11
  1. Rescan images

Scan the added container registry.

❯ ./backend.ai mgr image rescan localhost
2024-09-06 03:54:58.965 INFO ai.backend.manager.models.image [164836] Scanning kernel images from the registry "localhost"
2024-09-06 03:54:58.968 INFO ai.backend.manager.container_registry.base [164836] rescan_single_registry()
2024-09-06 03:54:58.971 INFO ai.backend.manager.container_registry.base [164836] _scan_image()
2024-09-06 03:54:58.974 WARNING ai.backend.manager.container_registry.base [164836] Docker image manifest v1 is deprecated.
2024-09-06 03:54:58.977 INFO ai.backend.manager.container_registry.base [164836] Scanned image - stable/bai-python:3.11/x86_64 (sha256:3a7829f911d5c601af3273f21df405b289acb51c35d90ac661a845f3a4a4a9f6)
2024-09-06 03:54:58.990 INFO ai.backend.manager.container_registry.base [164836] Updated image - localhost/stable/bai-python:3.11/x86_64 (sha256:3a7829f911d5c601af3273f21df405b289acb51c35d90ac661a845f3a4a4a9f6)

Check that the image has been correctly updated in the database with the following command.

❯ ./backend.ai mgr dbshell
2024-09-06 04:38:30.349 INFO ai.backend.manager.cli [212600] using the db container backendai-backendai-half-db-1 ...
psql (16.3)
Type "help" for help.

backend=# SELECT * FROM images
backend-# ORDER BY created_at DESC
backend-# LIMIT 1;
                  id                  |               name               | project |       image       |          created_at           | tag  | registry  |             registry_id              | architecture |                              config_digest                               | size_bytes | is_local |  type   | accelerators |                                                                                                      labels                                                                                                       |                                   resources                                   
--------------------------------------+----------------------------------+---------+-------------------+-------------------------------+------+-----------+--------------------------------------+--------------+--------------------------------------------------------------------------+------------+----------+---------+--------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------
 e8925a8a-1251-4935-b995-ffd797ce337c | localhost/stable/bai-python:3.11 | stable  | stable/bai-python | 2024-09-06 03:54:58.979416+00 | 3.11 | localhost | abc42a05-4471-41fa-8772-10bf6452c7d9 | x86_64       | sha256:3a7829f911d5c601af3273f21df405b289acb51c35d90ac661a845f3a4a4a9f6  |  409172485 | f        | COMPUTE |              | {"ai.backend.base-distro": "ubuntu18.04", "ai.backend.features": "uid-match batch query", "ai.backend.kernelspec": "1", "ai.backend.runtime-path": "/usr/local/bin/python3", "ai.backend.runtime-type": "python"} | {"cpu": {"max": null, "min": "1"}, "mem": {"max": null, "min": "1073741824"}}
(1 row)

Checklist: (if applicable)

  • Milestone metadata specifying the target backport version
  • Mention to the original issue

@github-actions github-actions bot added comp:manager Related to Manager component size:M 30~100 LoC labels Sep 6, 2024
@jopemachine jopemachine added this to the 24.09 milestone Sep 6, 2024
@jopemachine jopemachine changed the title feat: Support legacy docker image manifest feat: Support docker image manifest v2 schema1 Sep 6, 2024
@jopemachine jopemachine changed the title feat: Support docker image manifest v2 schema1 feat: Support docker image manifest v2 schema1 scanning Sep 6, 2024
@jopemachine jopemachine modified the milestones: 24.09, 24.03 Sep 6, 2024
@jopemachine jopemachine marked this pull request as ready for review September 6, 2024 04:46
@jopemachine jopemachine force-pushed the topic/08-03-refactor_base_containerregistry_s_scan_tag_and_implement_media_type_docker_manifest_type_handling branch from 34ebe36 to cffeb12 Compare September 9, 2024 01:28
@jopemachine jopemachine force-pushed the topic/09-06-feat_support_legacy_docker_image_manifest branch from d101175 to 42141af Compare September 9, 2024 01:28
@jopemachine jopemachine force-pushed the topic/08-03-refactor_base_containerregistry_s_scan_tag_and_implement_media_type_docker_manifest_type_handling branch from cffeb12 to 353ff4e Compare September 18, 2024 06:23
@jopemachine jopemachine force-pushed the topic/09-06-feat_support_legacy_docker_image_manifest branch from 42141af to 83f273a Compare September 18, 2024 06:24
@jopemachine jopemachine force-pushed the topic/08-03-refactor_base_containerregistry_s_scan_tag_and_implement_media_type_docker_manifest_type_handling branch from 353ff4e to c8911dd Compare September 18, 2024 06:29
@jopemachine jopemachine force-pushed the topic/09-06-feat_support_legacy_docker_image_manifest branch from 83f273a to cccaee2 Compare September 18, 2024 06:29
@jopemachine jopemachine force-pushed the topic/08-03-refactor_base_containerregistry_s_scan_tag_and_implement_media_type_docker_manifest_type_handling branch from c8911dd to a86f011 Compare September 18, 2024 06:48
@jopemachine jopemachine force-pushed the topic/09-06-feat_support_legacy_docker_image_manifest branch from cccaee2 to f42a5db Compare September 18, 2024 06:48
@jopemachine jopemachine force-pushed the topic/08-03-refactor_base_containerregistry_s_scan_tag_and_implement_media_type_docker_manifest_type_handling branch from a86f011 to 9ca2260 Compare September 18, 2024 06:58
@jopemachine jopemachine force-pushed the topic/09-06-feat_support_legacy_docker_image_manifest branch from f42a5db to 8eaba4c Compare September 18, 2024 06:58
@jopemachine jopemachine force-pushed the topic/08-03-refactor_base_containerregistry_s_scan_tag_and_implement_media_type_docker_manifest_type_handling branch from 9ca2260 to 3e50364 Compare September 19, 2024 07:20
@jopemachine jopemachine force-pushed the topic/09-06-feat_support_legacy_docker_image_manifest branch from 8eaba4c to 1e39787 Compare September 19, 2024 07:20
@jopemachine jopemachine force-pushed the topic/08-03-refactor_base_containerregistry_s_scan_tag_and_implement_media_type_docker_manifest_type_handling branch from 3e50364 to 65189eb Compare September 19, 2024 07:34
@jopemachine jopemachine force-pushed the topic/09-06-feat_support_legacy_docker_image_manifest branch from 1e39787 to 40922c3 Compare September 19, 2024 07:34
@jopemachine jopemachine force-pushed the topic/08-03-refactor_base_containerregistry_s_scan_tag_and_implement_media_type_docker_manifest_type_handling branch from 65189eb to 679c9e2 Compare September 19, 2024 07:57
@jopemachine jopemachine force-pushed the topic/09-06-feat_support_legacy_docker_image_manifest branch from 40922c3 to bc78e16 Compare September 19, 2024 07:57
@jopemachine jopemachine force-pushed the topic/08-03-refactor_base_containerregistry_s_scan_tag_and_implement_media_type_docker_manifest_type_handling branch from 679c9e2 to 2a1ca89 Compare September 30, 2024 12:21
@jopemachine jopemachine force-pushed the topic/09-06-feat_support_legacy_docker_image_manifest branch from bc78e16 to e3f3c66 Compare September 30, 2024 12:21
@jopemachine jopemachine force-pushed the topic/08-03-refactor_base_containerregistry_s_scan_tag_and_implement_media_type_docker_manifest_type_handling branch from 2a1ca89 to 493be6a Compare September 30, 2024 12:26
@jopemachine jopemachine force-pushed the topic/09-06-feat_support_legacy_docker_image_manifest branch from e3f3c66 to 27d8b1b Compare September 30, 2024 12:26
@jopemachine jopemachine force-pushed the topic/08-03-refactor_base_containerregistry_s_scan_tag_and_implement_media_type_docker_manifest_type_handling branch from 493be6a to 5a7b249 Compare September 30, 2024 12:39
@jopemachine jopemachine force-pushed the topic/09-06-feat_support_legacy_docker_image_manifest branch from 27d8b1b to 3794db3 Compare September 30, 2024 12:39
@jopemachine jopemachine force-pushed the topic/08-03-refactor_base_containerregistry_s_scan_tag_and_implement_media_type_docker_manifest_type_handling branch from 5a7b249 to 0d22e40 Compare September 30, 2024 14:36
@jopemachine jopemachine force-pushed the topic/09-06-feat_support_legacy_docker_image_manifest branch from 3794db3 to 13bbbc3 Compare September 30, 2024 14:36
@jopemachine jopemachine modified the milestones: 24.03, 24.09 Sep 30, 2024
Base automatically changed from topic/08-03-refactor_base_containerregistry_s_scan_tag_and_implement_media_type_docker_manifest_type_handling to main September 30, 2024 15:03
@kyujin-cho kyujin-cho force-pushed the topic/09-06-feat_support_legacy_docker_image_manifest branch from 13bbbc3 to ab9a9f7 Compare September 30, 2024 15:05
Copy link
Member

Merge activity

  • Sep 30, 11:06 AM EDT: Graphite rebased this pull request after merging its parent, because this pull request is set to merge when ready.

@kyujin-cho kyujin-cho added this pull request to the merge queue Sep 30, 2024
Merged via the queue into main with commit 2bda676 Sep 30, 2024
19 checks passed
@kyujin-cho kyujin-cho deleted the topic/09-06-feat_support_legacy_docker_image_manifest branch September 30, 2024 15:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp:manager Related to Manager component size:M 30~100 LoC
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants