Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Repository mirror #1568

Merged
merged 1 commit into from Feb 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES/5738.feature
@@ -0,0 +1 @@
Add mirror mode for sync endpoint.
2 changes: 1 addition & 1 deletion docs/_static/api.json

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions docs/workflows/create_sync_publish.rst
Expand Up @@ -65,6 +65,10 @@ Sync repository ``foo`` using remote ``bar``
.. literalinclude:: ../_scripts/sync.sh
:language: bash

You can specify ``mirror=True`` for a mirror mode. It means Pulp won't update
repository using previous repository version but create a new copy of remote
repository as a new repository version.

RepositoryVersion GET response (when sync task complete):

.. code:: json
Expand Down
6 changes: 4 additions & 2 deletions pulp_rpm/app/tasks/synchronizing.py
Expand Up @@ -97,13 +97,14 @@ def repodata_exists(remote, url):
return True


def synchronize(remote_pk, repository_pk):
def synchronize(remote_pk, repository_pk, mirror):
"""
Sync content from the remote repository.

Create a new version of the repository that is synchronized with the remote.

Args:
mirror (bool): Mirror mode
remote_pk (str): The remote PK.
repository_pk (str): The repository PK.

Expand Down Expand Up @@ -146,7 +147,8 @@ def synchronize(remote_pk, repository_pk):

first_stage = RpmFirstStage(remote, deferred_download, treeinfo=treeinfo)
dv = RpmDeclarativeVersion(first_stage=first_stage,
repository=repository)
repository=repository,
mirror=mirror)
dv.create()


Expand Down
2 changes: 2 additions & 0 deletions pulp_rpm/app/viewsets.py
Expand Up @@ -121,11 +121,13 @@ def sync(self, request, pk):
)
serializer.is_valid(raise_exception=True)
remote = serializer.validated_data.get('remote')
mirror = serializer.validated_data.get('mirror')

result = enqueue_with_reservation(
tasks.synchronize,
[repository, remote],
kwargs={
'mirror': mirror,
'remote_pk': remote.pk,
'repository_pk': repository.pk
}
Expand Down