Project

Profile

Help

Issue #6147

closed

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

Added by dalley almost 5 years ago. Updated over 4 years 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.

Actions #1

Updated by dalley almost 5 years ago

  • Description updated (diff)
Actions #2

Updated by daviddavis almost 5 years ago

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

Actions #3

Updated by dalley almost 5 years ago

  • Description updated (diff)
Actions #4

Updated by fao89 almost 5 years ago

  • Triaged changed from No to Yes
  • Sprint set to Sprint 66
Actions #5

Updated by fao89 almost 5 years ago

  • Status changed from NEW to ASSIGNED
  • Assignee set to fao89
Actions #6

Updated by fao89 almost 5 years ago

  • Status changed from ASSIGNED to POST
Actions #7

Updated by rchan over 4 years ago

  • Sprint changed from Sprint 66 to Sprint 67

Added by Fabricio Aguiar over 4 years ago

Revision d038c1fb | View on GitHub

Deleted versions update Repository.last_version

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

Actions #8

Updated by Anonymous over 4 years ago

  • Status changed from POST to MODIFIED

Added by daviddavis over 4 years ago

Revision f20b95f3 | View on GitHub

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

ref #6147

Actions #9

Updated by daviddavis over 4 years ago

  • Status changed from MODIFIED to CLOSED - CURRENTRELEASE
Actions #10

Updated by daviddavis over 4 years ago

  • Sprint/Milestone set to 3.2.0

Also available in: Atom PDF