Repository Versions » History » Sprint/Milestone 1
mhrivnak, 11/28/2017 06:57 AM
1 | 1 | mhrivnak | # Repository Versions |
---|---|---|---|
2 | |||
3 | For background on use cases and value, please see this thread: https://www.redhat.com/archives/pulp-dev/2017-May/msg00045.html |
||
4 | |||
5 | ## Publications and RepositoryVersions |
||
6 | |||
7 | As one addendum, it’s worth reminding ourselves how a managed Publication relates to a RepositoryVersion. In the time since the above email thread, we moved forward with the Publication and Distribution models being first-class. |
||
8 | |||
9 | A Publication is a set of artifacts and metadata that can be presented to a particular type of client for consumption. It is produced from the set of content that was present in a repository at the time of publication. |
||
10 | |||
11 | A RepositoryVersion is an immutable content set that represents the state of a repository’s content at a point in time. It can be used to create (or recreate) a Publication. It can be used to make two different types of publications from exactly the same content set. It can be used to answer the question: given a publication, what content was used to create it? What content is currently available to my production environment? What content was available to that environment last week when some event took place? Exactly what changed between two publishes, or since the most recent publish? |
||
12 | |||
13 | Neither takes the place of the other, and each provides the most value when both are in use. |
||
14 | |||
15 | ## Planning Details |
||
16 | |||
17 | Having updated the proof of concept to work with the latest Pulp 3 code base (as of late Nov 2017), and with all of the REST API improvements we have made, it became clear that the following changes would be necessary in the REST API and Plugin API to enable versioning of repositories. |
||
18 | |||
19 | The most problematic endpoint is /api/v3/repositorycontents/. It’s not entirely unreasonable to think that a client could add relationships by POSTing to this endpoint with a reference to a repository and another to a content unit, which would spawn a task that creates a new version along with the requested relationship. The side-effect of creating a version isn’t ideal, but it could be livable. |
||
20 | |||
21 | The real problem came with removing content from a repo via this endpoint. Calling DELETE on a relationship would not be allowed, because removal of a content unit from a repo requires creating a new repo version and updating the relationship to reference the new version as the one which removes the content. Allowing a client to directly create a new version, and then PUT/PATCH a specific relationship to reference that version, would be full of problems; the repo wouldn’t be locked, the content set in the version would be mutable (violating the value proposition of immutable content sets), and we’d be exposing the implementation details of how additions and removals are tracked (something that’s otherwise not necessary). |
||
22 | |||
23 | ## REST API |
||
24 | |||
25 | ### Changed Endpoints |
||
26 | |||
27 | /api/v3/repositories/{id}/publishers/file/{name}/publish/ |
||
28 | |||
29 | - Change: Takes an optional reference to a repo version. If none is provided, it defaults to the latest. |
||
30 | |||
31 | /api/v3/tasks/{id}/ |
||
32 | |||
33 | - Change: Includes a reference to a repo version as the created resource for any task that modifies the set of content in a repo. |
||
34 | |||
35 | ### Moved Endpoints |
||
36 | |||
37 | Current: |
||
38 | /api/v3/repositories/{id}/content/ |
||
39 | Becomes: |
||
40 | /api/v3/repositories/{id}/versions/{number}/content/ |
||
41 | |||
42 | ### Moved Attributes |
||
43 | |||
44 | Current: |
||
45 | “content_summary” at /api/v3/repositories/{id}/ |
||
46 | Becomes: |
||
47 | “content_summary” at /api/v3/repositories/{id}/versions/{number}/ |
||
48 | |||
49 | ### New Endpoints |
||
50 | |||
51 | /api/v3/repositories/{id}/versions/ |
||
52 | |||
53 | - Read: see a list of repo versions. |
||
54 | /api/v3/repositories/{id}/versions/{number}/ |
||
55 | - Read: see the details of a particular version |
||
56 | - Delete: delete a version, squashing its changes into the next one |
||
57 | /api/v3/repositories/{id}/versions/{number}/added/ |
||
58 | - Read: see the content added by the version |
||
59 | /api/v3/repositories/{id}/versions/{number}/removed/ |
||
60 | - Read: see the content removed by the version |
||
61 | |||
62 | ### Removed Endpoints |
||
63 | |||
64 | /api/v3/repositorycontents/ |
||
65 | |||
66 | - Replaced by /api/v3/repositories/{id}/versions/ |
||
67 | |||
68 | ## Plugin API |
||
69 | |||
70 | ### Sync |
||
71 | |||
72 | The task in core should retrieve the current version, create a new version, and hand each of them to the importer’s sync method. The current version is used to determine what content is currently in the repository, which is necessary to know during sync. The new version is used as the API for adding a removing content: |
||
73 | |||
74 | ~~~ |
||
75 | new_version.add_content(rpm1) |
||
76 | new_version.remove_content(rpm2) |
||
77 | ~~~ |
||
78 | |||
79 | ### Publish |
||
80 | |||
81 | The task in core should determine the version to use and pass it to the Publisher’s publish method. It should be determined either based on a reference provided by a client, or default to the latest. |
||
82 | |||
83 | ### Models |
||
84 | |||
85 | The RepositoryContent model should be removed from the plugin API, because it would no longer be intended for direct use by a plugin writer. |