This repository has been archived by the owner on Oct 28, 2019. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
https://pulp.plan.io/issues/4406 re #4406
- Loading branch information
Matthias Dellweg
committed
Mar 19, 2019
1 parent
25bb749
commit 7463677
Showing
5 changed files
with
112 additions
and
16 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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
.. _stages-docs: | ||
.. _stages-api-docs: | ||
|
||
pulpcore.plugin.stages | ||
====================== | ||
|
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
67 changes: 67 additions & 0 deletions
67
docs/plugin-writer/concepts/sync_pipeline/sync_pipeline.rst
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,67 @@ | ||
.. _stages-concept-docs: | ||
|
||
Synchronizing Repositories with the async-Pipeline | ||
================================================== | ||
|
||
To accomplish the steps outlined in :ref:`sync-docs` in an efficient way, pulp provides a high | ||
level api to construct a pipeline of stages. Those stages work in parallel like an assembly line | ||
using pythons `async` feature in combination with the `asyncio` library. Each stage takes | ||
designated content units from an incoming queue of type :class:`asyncio.Queue` and performes an | ||
individual task on them before passing them to the outgoing queue that is connected to the next | ||
stage. | ||
|
||
The anathomy of a stage is that it inherits :class:`pulpcore.plugin.stages.Stage` and overwrites | ||
its asynchronous callback :meth:`run`. | ||
In :meth:`run` it can retrieve incoming declarative content individually via the asynchronous | ||
iterator :meth:`self.items` or in batches via :meth:`self.batches`. | ||
It can pass on declarative content with :meth:`self.put`. | ||
|
||
The sync pipeline is headed by a `first_stage`, that is supposed to download upstream metadata | ||
and iterate over all upstream content references. For each such reference, it creates a | ||
:class:`pulpcore.plugin.stages.DeclarativeContent` that contains a prefilled but unsaved instance | ||
of a subclass of :class:`pulpcore.plugin.content.Content`, as well as a list of | ||
:class:`pulpcore.plugin.stages.DeclarativeArtifact`. The latter combine an unsaved instance of | ||
:class:`pulpcore.plugin.content.Artifact` with a url to retrieve it. | ||
The :class:`pulpcore.plugin.stages.DeclarativeContent` objects, that describe, what a content will | ||
look like when properly downloaded and saved to the database, are passed one by one to the next | ||
pipeline stage. | ||
The responsibility of providing this `first_stage` lies completely in the plugins domain, since | ||
this is the part of the pipeline specific to the repository type. | ||
|
||
The pulp plugin api provides the following stages which also comprise the default pipeline in the | ||
following order: | ||
|
||
1. :class:`pulpcore.plugin.stages.QueryExistingContents` | ||
2. :class:`pulpcore.plugin.stages.QueryExistingArtifacts` | ||
3. :class:`pulpcore.plugin.stages.ArtifactDownloader` | ||
4. :class:`pulpcore.plugin.stages.ArtifactSaver` | ||
5. :class:`pulpcore.plugin.stages.ContentSaver` | ||
6. :class:`pulpcore.plugin.stages.RemoveDuplicates` | ||
7. :class:`pulpcore.plugin.stages.ArtifactSaver` | ||
8. :class:`pulpcore.plugin.stages.ResolveContentFutures` | ||
|
||
Lazy synchronizing | ||
------------------ | ||
|
||
See :ref:`lazy-support`. | ||
|
||
.. _multi-level-discovery: | ||
|
||
Multiple level discovery | ||
------------------------ | ||
|
||
Plugins like `pulp_deb` and `pulp_docker` use content artifacts to enumerate more content. | ||
To support this pattern, the declarative content allows to be associated with a | ||
:class:`asyncio.Future`, that is resolved when the content reaches the | ||
:class:`pulpcore.plugin.stages.ResolveContentFutures` stage. | ||
By awaiting this Future, one can implement an informational back loop into earlier stages. | ||
.. warning:: | ||
|
||
In order to prevent deadlocks, be sure that you mark the declarative content with | ||
`does_batch=False`, and that you do not drop it without resolving the future. | ||
|
||
.. hint:: | ||
|
||
If you need downloaded artifacts of this content for further discovery, make sure to | ||
provide `deferred_download=False` to the | ||
:class:`pulpcore.plugin.stages.DeclarativeArtifact`. |
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