Project

Profile

Help

Issue #6147

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

Added by dalley about 2 months ago. Updated about 1 month ago.

Status:
CLOSED - CURRENTRELEASE
Priority:
Normal
Category:
-
Sprint/Milestone:
Start date:
Due date:
Severity:
2. Medium
Version:
Platform Release:
Blocks Release:
OS:
Backwards Incompatible:
No
Triaged:
Yes
Groomed:
No
Sprint Candidate:
No
Tags:
QA Contact:
Complexity:
Smash Test:
Verified:
No
Verification Required:
No
Sprint:
Sprint 67

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 about 1 month ago

Deleted versions update Repository.last_version

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

Revision f20b95f3 View on GitHub
Added by daviddavis about 1 month ago

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

ref #6147

History

#1 Updated by dalley about 2 months ago

  • Description updated (diff)

#2 Updated by daviddavis about 2 months ago

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

#3 Updated by dalley about 2 months ago

  • Description updated (diff)

#4 Updated by fabricio.aguiar about 2 months ago

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

#5 Updated by fabricio.aguiar about 2 months ago

  • Status changed from NEW to ASSIGNED
  • Assignee set to fabricio.aguiar

#6 Updated by fabricio.aguiar about 1 month ago

  • Status changed from ASSIGNED to POST

#7 Updated by rchan about 1 month ago

  • Sprint changed from Sprint 66 to Sprint 67

#8 Updated by Anonymous about 1 month ago

  • Status changed from POST to MODIFIED

#9 Updated by daviddavis about 1 month ago

  • Status changed from MODIFIED to CLOSED - CURRENTRELEASE

#10 Updated by daviddavis about 1 month ago

  • Sprint/Milestone set to 3.2.0

Please register to edit this issue

Also available in: Atom PDF