Project

Profile

Help

Issue #5252

closed

second sync creates orphaned tags with null tagged_manifests

Added by amacdona@redhat.com over 4 years ago. Updated about 4 years ago.

Status:
CLOSED - CURRENTRELEASE
Priority:
Normal
Sprint/Milestone:
Start date:
Due date:
Estimated time:
Severity:
2. Medium
Platform Release:
OS:
Triaged:
No
Groomed:
No
Sprint Candidate:
No
Tags:
Sprint:
Quarter:

Description

Syncing from a repository more than once creates corrupt tags.

After syncing exactly 1 time, the tags appears correct.

(pulp) [vagrant@pulp3-source-fedora29 pulp_docker]$ http http://localhost:24817/pulp/api/v3/content/docker/tags/?name=manifest_a
HTTP/1.1 200 OK
Allow: GET, POST, HEAD, OPTIONS
Connection: close
Content-Length: 387
Content-Type: application/json
Date: Mon, 12 Aug 2019 18:43:44 GMT
Server: gunicorn/19.9.0
Vary: Accept, Cookie
X-Frame-Options: SAMEORIGIN

{
    "count": 1,
    "next": null,
    "previous": null,
    "results": [
        {
            "_artifact": "/pulp/api/v3/artifacts/435553c9-1ec7-4c61-b4cd-5a04d281f2e1/",
            "_created": "2019-08-12T18:43:37.635061Z",
            "_href": "/pulp/api/v3/content/docker/tags/0579ffee-8014-4e74-9ccd-b2f77a37a6a6/",
            "_type": "docker.tag",
            "name": "manifest_a",
            "tagged_manifest": "/pulp/api/v3/content/docker/manifests/e53bba07-5759-4515-b033-e12f9c6da82b/"
        }
    ]
}

The second sync erroneously creates a new tag of the same name with `tagged_manifest=null`

(pulp) [vagrant@pulp3-source-fedora29 pulp_docker]$ http http://localhost:24817/pulp/api/v3/content/docker/tags/?name=manifest_a
HTTP/1.1 200 OK
Allow: GET, POST, HEAD, OPTIONS
Connection: close
Content-Length: 650
Content-Type: application/json
Date: Mon, 12 Aug 2019 18:45:24 GMT
Server: gunicorn/19.9.0
Vary: Accept, Cookie
X-Frame-Options: SAMEORIGIN

{
    "count": 2,
    "next": null,
    "previous": null,
    "results": [
        {
            "_artifact": "/pulp/api/v3/artifacts/435553c9-1ec7-4c61-b4cd-5a04d281f2e1/",
            "_created": "2019-08-12T18:45:19.139870Z",
            "_href": "/pulp/api/v3/content/docker/tags/6e6f41fd-a40c-4c21-816b-deb52fc8ddaa/",
            "_type": "docker.tag",
            "name": "manifest_a",
            "tagged_manifest": null
        },
        {
            "_artifact": "/pulp/api/v3/artifacts/435553c9-1ec7-4c61-b4cd-5a04d281f2e1/",
            "_created": "2019-08-12T18:43:37.635061Z",
            "_href": "/pulp/api/v3/content/docker/tags/0579ffee-8014-4e74-9ccd-b2f77a37a6a6/",
            "_type": "docker.tag",
            "name": "manifest_a",
            "tagged_manifest": "/pulp/api/v3/content/docker/manifests/e53bba07-5759-4515-b033-e12f9c6da82b/"
        }
    ]
}

Fortunately, the repositories seem to be unaffected. Both repository versions only contain the original tag, which has tagged_manifest correctly set. The extra tag is an orphan.

(pulp) [vagrant@pulp3-source-fedora29 pulp_docker]$ http "http://localhost:24817/pulp/api/v3/content/docker/tags/?repository_version=/pulp/api/v3/repositories/0786cb63-7f87-4c14-8782-7e74bae341ee/versions/1/&name=manifest_a"
HTTP/1.1 200 OK
Allow: GET, POST, HEAD, OPTIONS
Connection: close
Content-Length: 387
Content-Type: application/json
Date: Mon, 12 Aug 2019 18:54:00 GMT
Server: gunicorn/19.9.0
Vary: Accept, Cookie
X-Frame-Options: SAMEORIGIN

{
    "count": 1,
    "next": null,
    "previous": null,
    "results": [
        {
            "_artifact": "/pulp/api/v3/artifacts/435553c9-1ec7-4c61-b4cd-5a04d281f2e1/",
            "_created": "2019-08-12T18:43:37.635061Z",
            "_href": "/pulp/api/v3/content/docker/tags/0579ffee-8014-4e74-9ccd-b2f77a37a6a6/",
            "_type": "docker.tag",
            "name": "manifest_a",
            "tagged_manifest": "/pulp/api/v3/content/docker/manifests/e53bba07-5759-4515-b033-e12f9c6da82b/"
        }
    ]
}

(pulp) [vagrant@pulp3-source-fedora29 pulp_docker]$ http "http://localhost:24817/pulp/api/v3/content/docker/tags/?repository_version=/pulp/api/v3/repositories/0786cb63-7f87-4c14-8782-7e74bae341ee/versions/2/&name=manifest_a"
HTTP/1.1 200 OK
Allow: GET, POST, HEAD, OPTIONS
Connection: close
Content-Length: 387
Content-Type: application/json
Date: Mon, 12 Aug 2019 18:54:08 GMT
Server: gunicorn/19.9.0
Vary: Accept, Cookie
X-Frame-Options: SAMEORIGIN

{
    "count": 1,
    "next": null,
    "previous": null,
    "results": [
        {
            "_artifact": "/pulp/api/v3/artifacts/435553c9-1ec7-4c61-b4cd-5a04d281f2e1/",
            "_created": "2019-08-12T18:43:37.635061Z",
            "_href": "/pulp/api/v3/content/docker/tags/0579ffee-8014-4e74-9ccd-b2f77a37a6a6/",
            "_type": "docker.tag",
            "name": "manifest_a",
            "tagged_manifest": "/pulp/api/v3/content/docker/manifests/e53bba07-5759-4515-b033-e12f9c6da82b/"
        }
    ]
}

Heres a functional test to reproduce the error:


import unittest

from pulp_smash import api, config
from pulp_smash.pulp3.constants import REPO_PATH
from pulp_smash.pulp3.utils import gen_repo, sync

from pulp_docker.tests.functional.constants import (
    DOCKER_TAG_PATH,
    DOCKER_REMOTE_PATH,
    DOCKERHUB_PULP_FIXTURE_1,
)
from pulp_docker.tests.functional.utils import gen_docker_remote

class TestSanity(unittest.TestCase):

    @classmethod
    def setUpClass(cls):
        cls.cfg = config.get_config()
        cls.client = api.Client(cls.cfg, api.json_handler)
        cls.from_repo = cls.client.post(REPO_PATH, gen_repo())
        remote_data = gen_docker_remote(upstream_name=DOCKERHUB_PULP_FIXTURE_1)
        cls.remote = cls.client.post(DOCKER_REMOTE_PATH, remote_data)

    @classmethod
    def tearDownClass(cls):
        """Delete things made in setUpClass. addCleanup feature does not work with setupClass."""
        cls.client.delete(cls.from_repo['_href'])
        cls.client.delete(cls.remote['_href'])

    def test_sync_idempotentcy(self):
        sync(self.cfg, self.remote, self.from_repo)
        first_sync_tags_named_a = self.client.get("{unit_path}?{filters}".format(
            unit_path=DOCKER_TAG_PATH,
            filters="name=manifest_a",
        ))
        sync(self.cfg, self.remote, self.from_repo)
        second_sync_tags_named_a = self.client.get("{unit_path}?{filters}".format(
            unit_path=DOCKER_TAG_PATH,
            filters="name=manifest_a",
        ))
        self.assertEqual(first_sync_tags_named_a['count'], second_sync_tags_named_a['count'])

RESULT:

>       self.assertEqual(first_sync_tags_named_a['count'], second_sync_tags_named_a['count'])
E       AssertionError: 1 != 2

pulp_docker/tests/functional/api/test_sanity.py:44: AssertionError

Also available in: Atom PDF