Project

Profile

Help

Issue #6147

Updated by dalley about 4 years ago

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.

Back