Review and fix import behavior on unknown media types

Problem

While working on &7528 (closed), I pushed a Singularity image (as described here) to an old repository and then migrated it.

This image manifest looked like this:

{
  "schemaVersion": 2,
  "config": {
    "mediaType": "application/vnd.unknown.config.v1+json",
    "digest": "sha256:44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a",
    "size": 2
  },
  "layers": [
    {
      "mediaType": "application/vnd.sylabs.sif.layer.v1.sif",
      "digest": "sha256:b1fb64bfeb58e4075f4c481fa18f2899f002c0574b70d4cd5268ed86435f0636",
      "size": 51236864,
      "annotations": {
        "org.opencontainers.image.title": "hello.sif"
      }
    }
  ]
}

The manifest media type (application/vnd.unknown.config.v1+json) may look unexpected but it's actually OK, we added support for it in !912 (merged). The problem here was the layer media type, application/vnd.sylabs.sif.layer.v1.sif. This media type is unknown to the registry database and as such the layer import will fail.

The problem is that the repository import did not fail. Looking at the logs I found no error and looking at the database I found the manifest record but no associated layer records.

Solution

The importer should halt an import whenever failed to import a manifest or layer with an unknown media type. This is true for layer media types but also for manifest media types (either atomic or referenced by a list).

We should review the code and test coverage to make sure we fix any problems related to this. We're clearly missing a couple of integration tests.

  • Ensure the import fails if a layer has an unknown media type
  • Ensure the import fails if a manifest has an unknown media type
Edited by João Pereira