diff --git a/pulp_container/app/management/commands/init-image-nature.py b/pulp_container/app/management/commands/init-image-nature.py index 5524e0275..7c0f0ede0 100644 --- a/pulp_container/app/management/commands/init-image-nature.py +++ b/pulp_container/app/management/commands/init-image-nature.py @@ -31,7 +31,7 @@ class Command(BaseCommand): def handle(self, *args, **options): manifests = Manifest.objects.exclude( - media_type__in=[MEDIA_TYPE.MANIFEST_LIST, MEDIA_TYPE.INDEX_OCI] + media_type__in=[MEDIA_TYPE.MANIFEST_LIST, MEDIA_TYPE.INDEX_OCI, MEDIA_TYPE.MANIFEST_V1] ).order_by("pulp_id") self.update_manifests(manifests) diff --git a/pulp_container/app/models.py b/pulp_container/app/models.py index c93eb63d6..123229581 100644 --- a/pulp_container/app/models.py +++ b/pulp_container/app/models.py @@ -125,6 +125,9 @@ def init_metadata(self, manifest_data=None): return has_annotations or has_labels or has_image_nature def init_annotations(self, manifest_data=None): + # annotations are part of OCI only + if self.media_type not in (MEDIA_TYPE.MANIFEST_OCI, MEDIA_TYPE.INDEX_OCI): + return False if manifest_data is None: manifest_artifact = self._artifacts.get() manifest_data, _ = get_content_data(manifest_artifact) diff --git a/pulp_container/app/registry.py b/pulp_container/app/registry.py index c8c7a40d0..007b789a4 100644 --- a/pulp_container/app/registry.py +++ b/pulp_container/app/registry.py @@ -426,7 +426,9 @@ async def init_pending_content(self, digest, manifest_data, media_type, artifact config_blob=config_blob, ) - await sync_to_async(manifest.init_metadata)(manifest_data=manifest_data) + # skip if media_type of schema1 + if media_type in (MEDIA_TYPE.MANIFEST_V2, MEDIA_TYPE.MANIFEST_OCI): + await sync_to_async(manifest.init_metadata)(manifest_data=manifest_data) try: await manifest.asave() diff --git a/pulp_container/app/tasks/sync_stages.py b/pulp_container/app/tasks/sync_stages.py index 5f4f11bbf..000a13b0e 100644 --- a/pulp_container/app/tasks/sync_stages.py +++ b/pulp_container/app/tasks/sync_stages.py @@ -372,7 +372,10 @@ def create_tagged_manifest_list(self, tag_name, saved_artifact, manifest_list_da """ digest = f"sha256:{saved_artifact.sha256}" manifest_list = Manifest( - digest=digest, schema_version=manifest_list_data["schemaVersion"], media_type=media_type + digest=digest, + schema_version=manifest_list_data["schemaVersion"], + media_type=media_type, + annotations=manifest_list_data.get("annotations", {}), ) manifest_list_dc = self._create_manifest_declarative_content(