Issue #6966
closedMigrated errata refer to repository versions that don't exist
Description
Note, that this was done on a fresh pulp3 db due to #6964
Here is my migration plan:
{
"plugins":[
{
"type":"rpm",
"repositories":[
{
"name":"pulp-uuid-rhel_6_x86_64",
"repository_versions":[
{
"pulp2_repository_id":"pulp-uuid-rhel_6_x86_64",
"pulp2_distributor_repository_ids":[
"pulp-uuid-rhel_6_x86_64"
]
}
],
"pulp2_importer_repository_id":"pulp-uuid-rhel_6_x86_64"
},
{
"name":"Published LIbrary view-355376805-405955044",
"repository_versions":[
{
"pulp2_repository_id":"8_view1_archive",
"pulp2_distributor_repository_ids":[
"8_composite_version1",
"8_composite_version1_archive",
"8_view1",
"8_view1_archive"
]
}
]
}
]
}
]
}
And here's the migrated repo versions:
pulpcore=# select * from core_repositoryversion;
pulp_id | pulp_created | pulp_last_updated | number | complete | base_version_id | repository_id
--------------------------------------+-------------------------------+-------------------------------+--------+----------+-----------------+--------------------------------------
ea25e9b4-a4c1-4d38-8efd-488348ccbc79 | 2020-06-11 18:04:07.601578+00 | 2020-06-11 18:04:07.601626+00 | 0 | t | | 9d805f90-c152-40e7-a2ee-a3734745d0c3
ccae88f8-b294-47d6-8226-5c394c9ff600 | 2020-06-11 18:04:07.646226+00 | 2020-06-11 18:04:07.646257+00 | 0 | t | | 051d6557-35e5-4be0-8dda-ea8127bd99e9
24ec87a3-da54-4483-90cd-fbf679727b2e | 2020-06-11 18:04:09.435784+00 | 2020-06-11 18:04:09.851521+00 | 1 | t | | 9d805f90-c152-40e7-a2ee-a3734745d0c3
This is basically what i would expect, since the first migrated repo has content and was migrated as (9d805f90-c152-40e7-a2ee-a3734745d0c3) version 1. The 2nd migrated repo was empty so it stays at version 0 (051d6557-35e5-4be0-8dda-ea8127bd99e9).
We can check version 1 and see that it has errata:
# curl https://`hostname`/pulp/api/v3/repositories/rpm/rpm/9d805f90-c152-40e7-a2ee-a3734745d0c3/versions/1/ | jq
{
"pulp_href": "/pulp/api/v3/repositories/rpm/rpm/9d805f90-c152-40e7-a2ee-a3734745d0c3/versions/1/",
"pulp_created": "2020-06-11T18:04:09.435784Z",
"number": 1,
"base_version": null,
"content_summary": {
"added": {
"rpm.advisory": {
"count": 6,
"href": "/pulp/api/v3/content/rpm/advisories/?repository_version_added=/pulp/api/v3/repositories/rpm/rpm/9d805f90-c152-40e7-a2ee-a3734745d0c3/versions/1/"
},
SNIP
now lets check the migrated errata:
[root@devel2 ~]# curl --cert /etc/pki/katello/certs/pulp-client.crt --key /etc/pki/katello/private/pulp-client.key https://`hostname`/pulp/api/v3/pulp2content/ec697c30-c1e8-479a-b6b9-c28652343a86/ | jq
{
"pulp_href": "/pulp/api/v3/pulp2content/ec697c30-c1e8-479a-b6b9-c28652343a86/",
"pulp_created": "2020-06-11T18:04:07.072438Z",
"pulp2_id": "7c084d6e-073e-4310-94e3-5ab06b66ef1e",
"pulp2_content_type_id": "erratum",
"pulp2_last_updated": 1591898638,
"pulp2_storage_path": null,
"downloaded": false,
"pulp3_content": "/pulp/api/v3/content/rpm/advisories/b75d7ae7-f268-49d9-afaf-6e91bc7d8c7d/",
"pulp3_repository_version": "/pulp/api/v3/repositories/rpm/rpm/051d6557-35e5-4be0-8dda-ea8127bd99e9/versions/1/"
}
Notice that the pulp3_repository_version is "/pulp/api/v3/repositories/rpm/rpm/051d6557-35e5-4be0-8dda-ea8127bd99e9/versions/1/" which doesn't even exist! It should be the only other repository that exists (/pulp/api/v3/repositories/rpm/rpm/9d805f90-c152-40e7-a2ee-a3734745d0c3/versions/1/)
Set pulp3_repo relation for all the cases, including remigration.
As a side effect, also fixes the case when a repo name differs from the pulp2 one.
closes #6964 https://pulp.plan.io/issues/6964
closes #6640 https://pulp.plan.io/issues/6640
closes #6966 https://pulp.plan.io/issues/6966