-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add checkpoint support to Pulp core and file
Introduce a checkpoint field for Publication and Distribution models. Handle serving checkpoint Publications via checkpoint Distributions. Protect checkpoint Publications' RepositoryVersions from cleanup. Enable checkpoint support in pulp_file. closes #6244
- Loading branch information
1 parent
f72af09
commit 6f24ed7
Showing
20 changed files
with
760 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Added support to create and distribute checkpoint publications in Pulp. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Added support to create and distribute checkpoint publications in Pulp. | ||
Plugins can choose to enable this feature by exposing the checkpoint field in their inherited PublicationSerializer and DistributionSerializer. | ||
Checkpoint publications and distributions can be created by passing checkpoint=True when creating them. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Added support to create checkpoint file publications and distribute them through checkpoint file distributions. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# Checkpoint | ||
|
||
!!! warning | ||
This feature is provided as a tech preview and could change in backwards incompatible | ||
ways in the future. | ||
|
||
Pulp's checkpoint feature offers a robust way to manage and access historical versions of | ||
repositories. By integrating checkpoints into your plugins, you enable users to recreate | ||
environments from specific points in time, which is invaluable for identifying when changes or | ||
regressions were introduced. This feature supports reproducible deployments, helps track changes in | ||
package behavior, and facilitates a structured update workflow. | ||
|
||
!!! warning | ||
The checkpoint feature is only supported for plugins using publications. | ||
|
||
Plugin writers need to expose the `checkpoint` field on their distribution and publication | ||
serializers to allow users to create checkpoint publications and create checkpoint distributions to | ||
serve these publications. The `checkpoint` field is already present on the base distribution and | ||
publication models, so no new migration is needed. | ||
|
||
Example: enabling the checkpoint feature in the pulp_file plugin. | ||
```python | ||
class FileDistributionSerializer(DistributionSerializer): | ||
""" | ||
Serializer for File Distributions. | ||
""" | ||
publication = DetailRelatedField( | ||
required=False, | ||
help_text=_("Publication to be served"), | ||
view_name_pattern=r"publications(-.*/.*)?-detail", | ||
queryset=models.Publication.objects.exclude(complete=False), | ||
allow_null=True, | ||
) | ||
checkpoint = serializers.BooleanField(default=False) | ||
|
||
class Meta: | ||
fields = DistributionSerializer.Meta.fields + ("publication", "checkpoint") | ||
model = FileDistribution | ||
``` | ||
|
||
```python | ||
class FilePublicationSerializer(PublicationSerializer): | ||
""" | ||
Serializer for File Publications. | ||
""" | ||
distributions = DetailRelatedField( | ||
help_text=_("This publication is currently hosted as defined by these distributions."), | ||
source="distribution_set", | ||
view_name="filedistributions-detail", | ||
many=True, | ||
read_only=True, | ||
) | ||
manifest = serializers.CharField( | ||
help_text=_("Filename to use for manifest file containing metadata for all the files."), | ||
default="PULP_MANIFEST", | ||
required=False, | ||
allow_null=True, | ||
) | ||
checkpoint = serializers.BooleanField(default=False) | ||
|
||
class Meta: | ||
model = FilePublication | ||
fields = PublicationSerializer.Meta.fields + ("distributions", "manifest", "checkpoint") | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
# Create and Distribute Checkpoints | ||
|
||
!!! warning | ||
This feature requires plugin support to work correctly. | ||
|
||
!!! warning | ||
This feature is provided as a tech preview and could change in backwards incompatible | ||
ways in the future. | ||
|
||
## Overview | ||
|
||
Checkpoints in Pulp provide a way to access and manage historical versions of repositories. This | ||
feature allows users to view and install packages as they existed at specific points in time. By | ||
using checkpoints, you can recreate environments from any given date/time, which is particularly | ||
useful for tracking down when changes or regressions were introduced. | ||
|
||
Checkpoints support reproducible deployments, help identify changes in package behavior over time, | ||
and facilitate a structured update workflow. This ensures that a validated environment can be | ||
consistently replicated across different stages of development and production. | ||
|
||
For a similar concept, you can refer to [Debian's snapshot archive](https://snapshot.debian.org/), | ||
which offers access to old snapshots of the repositories based on timestamps. | ||
|
||
## Enabling Checkpoints | ||
|
||
Checkpoint is a plugin-dependent feature. It needs to be enabled in a plugin before you can start | ||
using it. | ||
|
||
## Creating Checkpoints | ||
|
||
The first step to start using checkpoint, is to create a checkpoint distribution which will be used | ||
to distribute checkpoint publications. A checkpoint distribution serves all the checkpoint | ||
publications of the related repository. | ||
|
||
```bash | ||
pulp file distribution create \ | ||
--name <distro_name> \ | ||
--repository <repo_name> \ | ||
--base-path <distro_base_path> \ | ||
--checkpoint | ||
``` | ||
|
||
The next step is to create checkpoint publications. Only publications marked as checkpoint will be | ||
served from the checkpoint distribution. Checkpoint publications can only be created using the | ||
repository's latest version. Repository versions of the distributed checkpoint publications will be | ||
protected from the `retain_repo_versions` cleanup. | ||
|
||
```bash | ||
pulp file publication create \ | ||
--repository <repo_name> \ | ||
--checkpoint | ||
``` | ||
|
||
## Accessing Checkpoints | ||
|
||
### Listing All Checkpoints | ||
You can access a listing of all the available repository's checkpoint publications by accessing the | ||
base path of any of the repository's checkpoint distributions. | ||
|
||
```bash | ||
http :24816/pulp/content/checkpoint/myfile | ||
``` | ||
|
||
```html | ||
<html> | ||
<head><title>Index of checkpoint/myfile/</title></head> | ||
<body bgcolor="white"> | ||
<h1>Index of checkpoint/myfile/</h1> | ||
<hr><pre><a href="../">../</a> | ||
<a href="20250130T203000Z/">20250130T203000Z/</a> 30-Jan-2025 20:30 | ||
<a href="20250130T205000Z/">20250130T205000Z/</a> 30-Jan-2025 20:50 | ||
</pre><hr></body> | ||
</html> | ||
``` | ||
|
||
### Accessing a Specific Checkpoint | ||
To access a specific checkpoint, suffix the checkpoint distribution's path with a timestamp in the format | ||
`yyyyMMddTHHmmssZ` (e.g. 20250130T205339Z), If a checkpoint was created at this time, it will be | ||
served. Otherwise, you will be redirected to the latest checkpoint created before this timestamp. | ||
Trying to access a checkpoint using a timestamp in the future or before the first checkpoint's | ||
timestamp, will result in a 404 response. | ||
|
||
Assuming the checkpoints from the above example, the below table show responses for sample requests | ||
<table> | ||
<tr> | ||
<th>Request path</th> | ||
<th>Response</th> | ||
</tr> | ||
<tr> | ||
<td>checkpoint/myfile/20250130T203000Z/</td> | ||
<td>200</td> | ||
</tr> | ||
<tr> | ||
<td>checkpoint/myfile/20250130T204000Z/</td> | ||
<td> | ||
301 <br> | ||
Location: checkpoint/myfile/20250130T203000Z/ | ||
</td> | ||
</tr> | ||
<tr> | ||
<td>checkpoint/myfile/20250130T206000Z/</td> | ||
<td> | ||
301 <br> | ||
Location: checkpoint/myfile/20250130T205000Z/ | ||
</td> | ||
</tr> | ||
<tr> | ||
<td>checkpoint/myfile/20250130T202000Z/</td> | ||
<td> | ||
404 | ||
</td> | ||
</tr> | ||
<tr> | ||
<td>checkpoint/myfile/29250130T203000Z/</td> | ||
<td> | ||
404 | ||
</td> | ||
</tr> | ||
</table> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
pulpcore/app/migrations/0128_distribution_checkpoint_publication_checkpoint.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Generated by Django 4.2.18 on 2025-01-30 19:14 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("core", "0127_remove_upstreampulp_pulp_label_select"), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name="distribution", | ||
name="checkpoint", | ||
field=models.BooleanField(default=False), | ||
), | ||
migrations.AddField( | ||
model_name="publication", | ||
name="checkpoint", | ||
field=models.BooleanField(default=False, editable=False), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.