Project

Profile

Help

Issue #6147

Repository.latest_version() doesn't take into account deleted repository versions

Added by dalley 10 months ago. Updated 9 months ago.

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

Description

The serializer does the correct thing, because the serializer does not use Repository.latest_version()

(pulp) [vagrant@pulp3-source-fedora31 pulp_rpm]$ http :24817${TARGET_REPO}versions/
HTTP/1.1 200 OK
Allow: GET, HEAD, OPTIONS
Connection: close
Content-Length: 283
Content-Type: application/json
Date: Wed, 12 Feb 2020 18:40:06 GMT
Server: gunicorn/20.0.4
Vary: Accept, Cookie
X-Frame-Options: SAMEORIGIN

{
    "count": 1,
    "next": null,
    "previous": null,
    "results": [
        {
            "base_version": null,
            "content_summary": {
                "added": {},
                "present": {},
                "removed": {}
            },
            "number": 0,
            "pulp_created": "2020-02-11T21:52:54.154568Z",
            "pulp_href": "/pulp/api/v3/repositories/rpm/rpm/8df090fe-a51e-4d23-acc4-e140e6294e02/versions/0/"
        }
    ]
}

(pulp) [vagrant@pulp3-source-fedora31 pulp_rpm]$ http :24817${TARGET_REPO}
HTTP/1.1 200 OK
Allow: GET, PUT, PATCH, DELETE, HEAD, OPTIONS
Connection: close
Content-Length: 377
Content-Type: application/json
Date: Wed, 12 Feb 2020 18:40:17 GMT
Server: gunicorn/20.0.4
Vary: Accept, Cookie
X-Frame-Options: SAMEORIGIN

{
    "description": null,
    "latest_version_href": "/pulp/api/v3/repositories/rpm/rpm/8df090fe-a51e-4d23-acc4-e140e6294e02/versions/0/",
    "name": "targetrepo",
    "pulp_created": "2020-02-11T21:52:54.152669Z",
    "pulp_href": "/pulp/api/v3/repositories/rpm/rpm/8df090fe-a51e-4d23-acc4-e140e6294e02/",
    "versions_href": "/pulp/api/v3/repositories/rpm/rpm/8df090fe-a51e-4d23-acc4-e140e6294e02/versions/"
}

However, underneath the hood, Pulp and plugin writers might have a problem, because if the "latest version" was deleted, Repository.latest_version() will return "None" instead of the one prior to the deleted one.


In [1]: RpmRepository.objects.all()[1].latest_version()    

In [2]: RepositoryVersion.objects.filter(repository=RpmRepository.objects.all()[1])                                    
Out[2]: <QuerySet [<Repository: targetrepo; Version: 0>]>

In [3]: RpmRepository.objects.all()[1].last_version        
Out[3]: 1

So what the JSON API returns and what the internal APIs return do not match up.

Anything that uses the internal APIs to find the latest version, like copy (what I'm working on) or probably distributions (though I haven't tested it) will run into this issue.

Associated revisions

Revision d038c1fb View on GitHub
Added by Fabricio Aguiar 9 months ago

Deleted versions update Repository.last_version

https://pulp.plan.io/issues/6147 closes #6147

Revision f20b95f3 View on GitHub
Added by daviddavis 9 months ago

Update changelog message and make it misc since it doesn't impact users

ref #6147

History

#1 Updated by dalley 10 months ago

  • Description updated (diff)

#2 Updated by daviddavis 10 months ago

+1 we need to fix this. Think it would be nice to add a unit test here too.

#3 Updated by dalley 10 months ago

  • Description updated (diff)

#4 Updated by fao89 10 months ago

  • Triaged changed from No to Yes
  • Sprint set to Sprint 66

#5 Updated by fao89 9 months ago

  • Status changed from NEW to ASSIGNED
  • Assignee set to fao89

#6 Updated by fao89 9 months ago

  • Status changed from ASSIGNED to POST

#7 Updated by rchan 9 months ago

  • Sprint changed from Sprint 66 to Sprint 67

#8 Updated by Anonymous 9 months ago

  • Status changed from POST to MODIFIED

#9 Updated by daviddavis 9 months ago

  • Status changed from MODIFIED to CLOSED - CURRENTRELEASE

#10 Updated by daviddavis 9 months ago

  • Sprint/Milestone set to 3.2.0

Please register to edit this issue

Also available in: Atom PDF