Skip to content
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

Handle the special case when publishing simple and structured and the upstream repo contains a distribution named "default" #601

Closed
quba42 opened this issue Aug 4, 2022 · 0 comments · Fixed by #602
Labels
.bugfix CHANGES/<issue_number>.bugfix

Comments

@quba42
Copy link
Collaborator

quba42 commented Aug 4, 2022

Describe the bug
If an upstream repo contains a distribution named "default", and the user tries to publish this using structured=True AND simple=True, the structured "default" distribution will collide weith the simple "default" distribution and the publication will fail as follows:

    "error": {
        "description": "duplicate key value violates unique constraint \"core_publishedmetadata_publication_id_relative__60dd832b_uniq\"\nDETAIL:  Key (publication_id, relative_path)=(8b7f14bf-ca06-4c9b-9233-2e14edcf5322, dists/default/all/binary-amd64/Packages) already exists.\n",
        "traceback": "  File \"/opt/theforeman/tfm-pulpcore/root/usr/lib/python3.8/site-packages/pulpcore/tasking/pulpcore_worker.py\", line 380, in _perform_task\n    result = func(*args, **kwargs)\n  File \"/opt/theforeman/tfm-pulpcore/root/usr/lib/python3.8/site-packages/pulp_deb/app/tasks/publishing.py\", line 172, in publish\n    release_helper.finish()\n  File \"/opt/theforeman/tfm-pulpcore/root/usr/lib/python3.8/site-packages/pulp_deb/app/tasks/publishing.py\", line 293, in finish\n    component.finish()\n  File \"/opt/theforeman/tfm-pulpcore/root/usr/lib/python3.8/site-packages/pulp_deb/app/tasks/publishing.py\", line 216, in finish\n    package_index = PublishedMetadata.create_from_file(\n  File \"/opt/theforeman/tfm-pulpcore/root/usr/lib/python3.8/site-packages/pulpcore/app/models/publication.py\", line 281, in create_from_file\n    content.save()\n  File \"/opt/theforeman/tfm-pulpcore/root/usr/lib/python3.8/site-packages/pulpcore/app/models/base.py\", line 149, in save\n    return super().save(*args, **kwargs)\n  File \"/opt/rh/rh-python38/root/usr/lib64/python3.8/contextlib.py\", line 75, in inner\n    return func(*args, **kwds)\n  File \"/opt/theforeman/tfm-pulpcore/root/usr/lib/python3.8/site-packages/django_lifecycle/mixins.py\", line 134, in save\n    save(*args, **kwargs)\n  File \"/opt/theforeman/tfm-pulpcore/root/usr/lib/python3.8/site-packages/django/db/models/base.py\", line 739, in save\n    self.save_base(using=using, force_insert=force_insert,\n  File \"/opt/theforeman/tfm-pulpcore/root/usr/lib/python3.8/site-packages/django/db/models/base.py\", line 776, in save_base\n    updated = self._save_table(\n  File \"/opt/theforeman/tfm-pulpcore/root/usr/lib/python3.8/site-packages/django/db/models/base.py\", line 881, in _save_table\n    results = self._do_insert(cls._base_manager, using, fields, returning_fields, raw)\n  File \"/opt/theforeman/tfm-pulpcore/root/usr/lib/python3.8/site-packages/django/db/models/base.py\", line 919, in _do_insert\n    return manager._insert(\n  File \"/opt/theforeman/tfm-pulpcore/root/usr/lib/python3.8/site-packages/django/db/models/manager.py\", line 85, in manager_method\n    return getattr(self.get_queryset(), name)(*args, **kwargs)\n  File \"/opt/theforeman/tfm-pulpcore/root/usr/lib/python3.8/site-packages/django/db/models/query.py\", line 1270, in _insert\n    return query.get_compiler(using=using).execute_sql(returning_fields)\n  File \"/opt/theforeman/tfm-pulpcore/root/usr/lib/python3.8/site-packages/django/db/models/sql/compiler.py\", line 1416, in execute_sql\n    cursor.execute(sql, params)\n  File \"/opt/theforeman/tfm-pulpcore/root/usr/lib/python3.8/site-packages/django/db/backends/utils.py\", line 66, in execute\n    return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)\n  File \"/opt/theforeman/tfm-pulpcore/root/usr/lib/python3.8/site-packages/django/db/backends/utils.py\", line 75, in _execute_with_wrappers\n    return executor(sql, params, many, context)\n  File \"/opt/theforeman/tfm-pulpcore/root/usr/lib/python3.8/site-packages/django/db/backends/utils.py\", line 84, in _execute\n    return self.cursor.execute(sql, params)\n  File \"/opt/theforeman/tfm-pulpcore/root/usr/lib/python3.8/site-packages/django/db/utils.py\", line 90, in __exit__\n    raise dj_exc_value.with_traceback(traceback) from exc_value\n  File \"/opt/theforeman/tfm-pulpcore/root/usr/lib/python3.8/site-packages/django/db/backends/utils.py\", line 84, in _execute\n    return self.cursor.execute(sql, params)\n"
    },

Expected behavior

Either handle this special case, or at least provide a meaningful error message!

Additional context

This is most likely to occur during Pulp to Pulp syncs, since I have never seen a repo in the wild with a distribution="default" anywhere outside of pulp_deb...

@quba42 quba42 added Triage-Needed .bugfix CHANGES/<issue_number>.bugfix and removed Triage-Needed labels Aug 4, 2022
quba42 added a commit to ATIX-AG/pulp_deb that referenced this issue Aug 4, 2022
closes pulp#601

This occurs when an upstream repo contains a distribution named
"default" and we then try to publish using both "simple=True" and
"structured=True".
quba42 added a commit to ATIX-AG/pulp_deb that referenced this issue Aug 4, 2022
closes pulp#601

This occurs when an upstream repo contains a distribution named
"default" and we then try to publish using both "simple=True" and
"structured=True".
quba42 added a commit that referenced this issue Aug 9, 2022
closes #601

This occurs when an upstream repo contains a distribution named
"default" and we then try to publish using both "simple=True" and
"structured=True".
patchback bot pushed a commit that referenced this issue Aug 9, 2022
closes #601

This occurs when an upstream repo contains a distribution named
"default" and we then try to publish using both "simple=True" and
"structured=True".

(cherry picked from commit a2ba551)
patchback bot pushed a commit that referenced this issue Aug 9, 2022
closes #601

This occurs when an upstream repo contains a distribution named
"default" and we then try to publish using both "simple=True" and
"structured=True".

(cherry picked from commit a2ba551)
patchback bot pushed a commit that referenced this issue Aug 9, 2022
closes #601

This occurs when an upstream repo contains a distribution named
"default" and we then try to publish using both "simple=True" and
"structured=True".

(cherry picked from commit a2ba551)
patchback bot pushed a commit that referenced this issue Aug 9, 2022
closes #601

This occurs when an upstream repo contains a distribution named
"default" and we then try to publish using both "simple=True" and
"structured=True".

(cherry picked from commit a2ba551)
quba42 added a commit that referenced this issue Aug 9, 2022
closes #601

This occurs when an upstream repo contains a distribution named
"default" and we then try to publish using both "simple=True" and
"structured=True".

(cherry picked from commit a2ba551)
quba42 added a commit that referenced this issue Aug 9, 2022
closes #601

This occurs when an upstream repo contains a distribution named
"default" and we then try to publish using both "simple=True" and
"structured=True".

(cherry picked from commit a2ba551)
quba42 added a commit that referenced this issue Aug 9, 2022
closes #601

This occurs when an upstream repo contains a distribution named
"default" and we then try to publish using both "simple=True" and
"structured=True".

(cherry picked from commit a2ba551)
quba42 added a commit that referenced this issue Aug 9, 2022
closes #601

This occurs when an upstream repo contains a distribution named
"default" and we then try to publish using both "simple=True" and
"structured=True".

(cherry picked from commit a2ba551)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
.bugfix CHANGES/<issue_number>.bugfix
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant