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

1.2.1 cherrypicks #433

Merged
merged 8 commits into from
Sep 23, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGES/7454.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Removes the ``test_file_decriptors`` test which was not actually testing Pulp code and was failing
intermittently.
1 change: 1 addition & 0 deletions CHANGES/7515.doc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added docs for using FileSystemExporter.
1 change: 1 addition & 0 deletions CHANGES/7522.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed exception when hitting ``/pulp/api/v3/exporters/file/filesystem/<uuid>/exports/``.
3 changes: 3 additions & 0 deletions docs/_scripts/docs_check_upload_publish.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,6 @@ source add_remove.sh
source publication.sh
source distribution.sh
source download_after_upload.sh

source exporter.sh
source export.sh
9 changes: 1 addition & 8 deletions docs/_scripts/export.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
#!/usr/bin/env bash
export EXPORTER_NAME=$(head /dev/urandom | tr -dc a-z | head -c5)
export DEST_DIR="/data"

echo "Created a new file system exporter $EXPORTER_NAME."
export EXPORTER_HREF=$(http POST $BASE_ADDR/pulp/api/v3/exporters/file/filesystem/ \
name=$EXPORTER_NAME path=$DEST_DIR | jq -r '.pulp_href')

export TASK_URL=$(http POST $BASE_ADDR$EXPORTER_HREF'exports/' publication=$PUBLICATION_HREF
export TASK_URL=$(http POST $BASE_ADDR$EXPORTER_HREF'exports/' publication=$PUBLICATION_HREF \
| jq -r '.task')

# Poll the task (here we use a function defined in docs/_scripts/base.sh)
Expand Down
7 changes: 7 additions & 0 deletions docs/_scripts/exporter.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash
export EXPORTER_NAME=$(head /dev/urandom | tr -dc a-z | head -c5)
export DEST_DIR=$(mktemp -d -t export-XXXXXXXX)

echo "Created a new file system exporter $EXPORTER_NAME."
export EXPORTER_HREF=$(http POST $BASE_ADDR/pulp/api/v3/exporters/file/filesystem/ \
name=$EXPORTER_NAME path=$DEST_DIR | jq -r '.pulp_href')
27 changes: 27 additions & 0 deletions docs/workflows/export.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Export
======

Filesystem
----------

This section describes how to export file content to the filesystem. Exporting content to the
filesystem is useful if you want to serve content with your own web server and not use Pulp's
Content App, or if you want to transfer your content to another location (via rsync, etc).

If DEFAULT_FILE_STORAGE is filesystem, the FilesystemExporter will create hard links. Otherwise, it
will fetch and write the content to the filesystem.

This example assumes you have a Publication and that publication's href is stored as
$PUBLICATION_HREF.

First, create a FilesystemExporter and give it the desired path. Your ALLOWED_EXPORT_PATHS setting must
include this path.

.. literalinclude:: ../_scripts/exporter.sh
:language: bash

Next you can use this exporter to create a filesystem export that will export your Publication's
content to the filesystem.

.. literalinclude:: ../_scripts/export.sh
:language: bash
1 change: 1 addition & 0 deletions docs/workflows/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,4 @@ library with:
sync
upload
publish-host
export
1 change: 0 additions & 1 deletion pulp_file/app/viewsets.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,6 @@ class FileFilesystemExportViewSet(ExportViewSet):
"""

parent_viewset = FileFilesystemExporterViewSet
parent_lookup_kwargs = {"filesystem_exporter_pk": "filesystem_exporter__pk"}

@extend_schema(
request=PublicationExportSerializer,
Expand Down
40 changes: 1 addition & 39 deletions pulp_file/tests/functional/api/test_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
"""Tests that sync file plugin repositories."""
import unittest

from pulp_smash import cli, config
from pulp_smash.pulp3.constants import MEDIA_PATH
from pulp_smash import config
from pulp_smash.pulp3.utils import gen_repo, get_added_content_summary, get_content_summary

from pulp_file.tests.functional.constants import (
Expand Down Expand Up @@ -85,43 +84,6 @@ def test_sync(self):
self.assertEqual(latest_version_href, repo.latest_version_href)
self.assertDictEqual(get_content_summary(repo.to_dict()), FILE_FIXTURE_SUMMARY)

def test_file_decriptors(self):
"""Test whether file descriptors are closed properly.

This test targets the following issue:

`Pulp #4073 <https://pulp.plan.io/issues/4073>`_

Do the following:

1. Check if 'lsof' is installed. If it is not, skip this test.
2. Create and sync a repo.
3. Run the 'lsof' command to verify that files in the
path ``/var/lib/pulp/`` are closed after the sync.
4. Assert that issued command returns `0` opened files.
"""
cli_client = cli.Client(self.cfg, cli.echo_handler)

# check if 'lsof' is available
if cli_client.run(("which", "lsof")).returncode != 0:
raise unittest.SkipTest("lsof package is not present")

repo_api = RepositoriesFileApi(self.client)
repo = repo_api.create(gen_repo())
self.addCleanup(repo_api.delete, repo.pulp_href)

remote_api = RemotesFileApi(self.client)
remote = remote_api.create(gen_file_remote())
self.addCleanup(remote_api.delete, remote.pulp_href)

repository_sync_data = RepositorySyncURL(remote=remote.pulp_href)
sync_response = repo_api.sync(repo.pulp_href, repository_sync_data)
monitor_task(sync_response.task)

cmd = "lsof -t +D {}".format(MEDIA_PATH).split()
response = cli_client.run(cmd).stdout
self.assertEqual(len(response), 0, response)


class SyncInvalidTestCase(unittest.TestCase):
"""Sync a repository with a given url on the remote."""
Expand Down