This repository has been archived by the owner on Jan 9, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do not pre-migrate schema1 docker tags when there are 2 tags with sam…
…e name witin a repo. closes #6234 https://pulp.plan.io/issues/6234 (cherry picked from commit 76423ee)
- Loading branch information
Showing
5 changed files
with
41 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Do not pre-migrate schema1 docker tags when there are 2 tags with same name witin a repo. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from . import pulp2_models | ||
|
||
|
||
def find_tags(): | ||
""" | ||
Find tags that have same name within the repo. | ||
Return only one tag out of 2 tags with the same name. | ||
Prefer schema2 over schema1. | ||
""" | ||
|
||
# sort the schema version in desc mode. | ||
sort_stage = {'$sort': {'schema_version': -1}} | ||
# group tags by name and repo_id; take just first result out of the 2 tags with the same name | ||
group_stage1 = {'$group': {'_id': {'name': '$name', 'repo_id': '$repo_id'}, | ||
'tags_id': {'$first': '$_id'}}} | ||
group_stage2 = {'$group': {'_id': None, 'tags_ids': {'$addToSet': '$tags_id'}}} | ||
result = pulp2_models.Tag.objects.aggregate([sort_stage, group_stage1, group_stage2]) | ||
if result._has_next(): | ||
return result.next()['tags_ids'] | ||
return [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters