Bug 2125244

Summary: Sync of a docker type repository containing schema 1 manifest fails with error
Product: Red Hat Satellite Reporter: Vladimír Sedmík <vsedmik>
Component: PulpAssignee: Ina Panova <ipanova>
Status: CLOSED ERRATA QA Contact: Vladimír Sedmík <vsedmik>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.12.0CC: amasolov, dalley, iballou, ipanova, pcreech
Target Milestone: 6.12.0Keywords: Regression, Triaged
Target Release: Unused   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: pulp_container-2.10.9, pulp_container-2.9.8 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-11-16 13:35:50 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Vladimír Sedmík 2022-09-08 12:36:11 UTC
Description of problem:
Sync of a docker type repository containing schema 1 manifest fails with error.


Version-Release number of selected component (if applicable):
6.12.0 snap 10


How reproducible:
always


Steps to Reproduce:
1. On a blank Satellite create a Product and a Repository with these specs:
   Type: docker
   Upstream URL: https://quay.io
   Upstream Repository Name: quay/busybox
2. Try to sync the repo.


Actual results:
The sync tasks fails with "undefined method `schema_version' for nil:NilClass" error


Expected results:
The task succeeds and repo is synchronized.


Additional info:
1. I can't reproduce the error in snap 8, so it looks like a regression since then.
2. Another error occurs when syncing a repository with both schemas, for example foreman/foreman from quay.io:
500, message='Internal Server Error', url=URL('https://cdn02.quay.io/sha256/b1/b1f5f4483d8c969c5fedd04eba3d136856153db431d23c3478b00bb3caeac32c?username=None&...')

Comment 1 Daniel Alley 2022-09-08 12:48:13 UTC
500 "Internal server error" doesn't sound like a Pulp problem necessarily. It could be a transient issue with Quay.

Comment 2 Ian Ballou 2022-09-08 13:41:43 UTC
After poking around the database, it looks like the repository in question is not getting the docker manifest indexed from Pulp into the Katello DB.

This has reportedly been reproduced on 3 separate Satellite machines across snaps 9 and 10

Comment 3 Ian Ballou 2022-09-08 14:21:13 UTC
Looks like I found the root issue. In Katello's manifest indexing code, we look for media types: ['application/vnd.docker.distribution.manifest.v1+json', 'application/vnd.docker.distribution.manifest.v2+json']

But, the Pulp API is returning a new manifest media type (+prettyjws):

[root@dhcp-3-187 ~]# pulp show --href /pulp/api/v3/content/container/manifests/?repository_version_added=/pulp/api/v3/repositories/container/container/055b9df9-5ae2-484d-be70-be27f4ee87ee/versions/1/
{
  "count": 1,
  "next": null,
  "previous": null,
  "results": [
    {
      "pulp_href": "/pulp/api/v3/content/container/manifests/796a10da-a1a1-4834-ac38-1816dfb4c130/",
      "pulp_created": "2022-09-08T10:57:43.725388Z",
      "artifact": "/pulp/api/v3/artifacts/80b8c577-9f82-47ab-a67c-42f6796dd5b7/",
      "digest": "sha256:ffd944135bc9fe6573e82d4578c28beb6e3fec1aea988c38d382587c7454f819",
      "schema_version": 1,
      "media_type": "application/vnd.docker.distribution.manifest.v1+prettyjws",
      "listed_manifests": [],
      "config_blob": null,
      "blobs": [
        "/pulp/api/v3/content/container/blobs/973153f7-e098-4d59-b7c1-ae3c1a0ed435/",
        "/pulp/api/v3/content/container/blobs/f3930908-96df-471b-bf75-664c3f0186f8/",
        "/pulp/api/v3/content/container/blobs/82af9e66-f3bc-45f2-b183-8d18b5e9012f/"
      ]
    }
  ]
}

I think Katello should just need to start looking out for this "new" media type.  What would be good to know though is if this means older pulp-container needs to return the signed manifest type.

Comment 4 Ian Ballou 2022-09-08 14:24:46 UTC
Edit: it sounds like Pulp shouldn't be returning this new media_type via the repository versions API. It cannot be filtered for: https://docs.pulpproject.org/pulp_container/restapi.html#tag/Content:-Manifests/operation/content_container_manifests_list

Comment 5 Ian Ballou 2022-09-08 14:41:58 UTC
After a discussion with Ina, I'm changing this to the Pulp component since the signed media type shouldn't be presented via the API.

Comment 6 Ina Panova 2022-09-08 14:53:42 UTC
This change makes it so that the media type is taken from response headers https://github.com/pulp/pulp_container/commit/89548413a8ab78af83cd34412062eb149dd41b09#diff-b4450b457692a725eeadc0ef7b13abfb35f2969203ee4c21bea33b2d8bbf37dbR28 which happens to be signed manifest. There question is how the heck it got saved if we enforce this on the DB level with the choices fields which do not have among the signed media_type https://github.com/pulp/pulp_container/blob/main/pulp_container/app/models.py#L93

Comment 8 Ina Panova 2022-09-14 13:32:18 UTC
The fix is available in pulp-container 2.10.9 and 2.9.8

Comment 9 Vladimír Sedmík 2022-09-23 15:00:57 UTC
Verified in 6.12.0 snap 12

Comment 11 Ian Ballou 2022-11-02 19:12:00 UTC
*** Bug 2134682 has been marked as a duplicate of this bug. ***

Comment 14 errata-xmlrpc 2022-11-16 13:35:50 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (Important: Satellite 6.12 Release), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2022:8506