Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/scripts/before_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ if [ "$TEST" = "s3" ]; then
s3_test: true
rustfs_access_key: "${RUSTFS_ACCESS_KEY}"
rustfs_secret_key: "${RUSTFS_SECRET_KEY}"
pulp_scenario_settings: {"DISABLED_authentication_backends": "@merge django.contrib.auth.backends.RemoteUserBackend", "DISABLED_authentication_json_header": "HTTP_X_RH_IDENTITY", "DISABLED_authentication_json_header_jq_filter": ".identity.user.username", "DISABLED_authentication_json_header_openapi_security_scheme": {"description": "External OAuth integration", "flows": {"clientCredentials": {"scopes": {"api.console": "grant_access_to_pulp"}, "tokenUrl": "https://your-identity-provider/token/issuer"}}, "type": "oauth2"}, "DISABLED_rest_framework__default_authentication_classes": "@merge pulpcore.app.authentication.JSONHeaderRemoteAuthentication", "ENABLE_V4_API": true, "MEDIA_ROOT": "", "STORAGES": {"default": {"BACKEND": "storages.backends.s3boto3.S3Boto3Storage", "OPTIONS": {"access_key": "AKIAIT2Z5TDYPX3ARJBA", "addressing_style": "path", "bucket_name": "pulp3", "default_acl": "@none", "endpoint_url": "http://rustfs:9000", "region_name": "eu-central-1", "secret_key": "fqRvjWaPU5o0fCqQuUWbj9Fainj2pVZtBCiDiieS", "signature_version": "s3v4"}}, "staticfiles": {"BACKEND": "django.contrib.staticfiles.storage.StaticFilesStorage"}}, "api_root": "/rerouted/djnd/", "domain_enabled": true, "hide_guarded_distributions": true, "rest_framework__default_permission_classes": ["pulpcore.plugin.access_policy.AccessPolicyFromSettings"], "spectacular_settings__oas_version": "3.0.3"}
pulp_scenario_settings: {"DISABLED_authentication_backends": "@merge django.contrib.auth.backends.RemoteUserBackend", "DISABLED_authentication_json_header": "HTTP_X_RH_IDENTITY", "DISABLED_authentication_json_header_jq_filter": ".identity.user.username", "DISABLED_authentication_json_header_openapi_security_scheme": {"description": "External OAuth integration", "flows": {"clientCredentials": {"scopes": {"api.console": "grant_access_to_pulp"}, "tokenUrl": "https://your-identity-provider/token/issuer"}}, "type": "oauth2"}, "DISABLED_rest_framework__default_authentication_classes": "@merge pulpcore.app.authentication.JSONHeaderRemoteAuthentication", "ENABLE_V4_API": true, "MEDIA_ROOT": "", "STORAGES": {"default": {"BACKEND": "pulpcore.vendor.storages.backends.s3boto3.S3Boto3Storage", "OPTIONS": {"access_key": "AKIAIT2Z5TDYPX3ARJBA", "addressing_style": "path", "bucket_name": "pulp3", "default_acl": "@none", "endpoint_url": "http://rustfs:9000", "region_name": "eu-central-1", "secret_key": "fqRvjWaPU5o0fCqQuUWbj9Fainj2pVZtBCiDiieS", "signature_version": "s3v4"}}, "staticfiles": {"BACKEND": "django.contrib.staticfiles.storage.StaticFilesStorage"}}, "api_root": "/rerouted/djnd/", "domain_enabled": true, "hide_guarded_distributions": true, "rest_framework__default_permission_classes": ["pulpcore.plugin.access_policy.AccessPolicyFromSettings"], "spectacular_settings__oas_version": "3.0.3"}
# MinIO omits 100-continue on 0-byte PUTs; stock botocore hangs without this (boto/botocore#3123).
pulp_scenario_env: {"BOTO_EXPERIMENTAL__NO_EMPTY_CONTINUE": "true"}
VARSYAML
Expand All @@ -107,7 +107,7 @@ if [ "$TEST" = "azure" ]; then
image: "mcr.microsoft.com/azure-storage/azurite"
command: "azurite-blob --skipApiVersionCheck --blobHost 0.0.0.0"
azure_test: true
pulp_scenario_settings: {"MEDIA_ROOT": "", "STORAGES": {"default": {"BACKEND": "storages.backends.azure_storage.AzureStorage", "OPTIONS": {"account_key": "Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==", "account_name": "devstoreaccount1", "azure_container": "pulp-test", "connection_string": "DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://ci-azurite:10000/devstoreaccount1;", "expiration_secs": 120, "location": "pulp3", "overwrite_files": true}}, "staticfiles": {"BACKEND": "django.contrib.staticfiles.storage.StaticFilesStorage"}}, "api_root_rewrite_header": "X-API-Root", "content_origin": null, "domain_enabled": true, "rest_framework__default_authentication_classes": "@merge pulpcore.app.authentication.PulpRemoteUserAuthentication", "rest_framework__default_permission_classes": ["pulpcore.plugin.access_policy.DefaultAccessPolicy"], "task_diagnostics": ["memory"], "worker_type": "redis"}
pulp_scenario_settings: {"MEDIA_ROOT": "", "STORAGES": {"default": {"BACKEND": "pulpcore.vendor.storages.backends.azure_storage.AzureStorage", "OPTIONS": {"account_key": "Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==", "account_name": "devstoreaccount1", "azure_container": "pulp-test", "connection_string": "DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://ci-azurite:10000/devstoreaccount1;", "expiration_secs": 120, "location": "pulp3", "overwrite_files": true}}, "staticfiles": {"BACKEND": "django.contrib.staticfiles.storage.StaticFilesStorage"}}, "api_root_rewrite_header": "X-API-Root", "content_origin": null, "domain_enabled": true, "rest_framework__default_authentication_classes": "@merge pulpcore.app.authentication.PulpRemoteUserAuthentication", "rest_framework__default_permission_classes": ["pulpcore.plugin.access_policy.DefaultAccessPolicy"], "task_diagnostics": ["memory"], "worker_type": "redis"}
pulp_scenario_env: {}
VARSYAML
fi
Expand Down
1 change: 1 addition & 0 deletions CHANGES/7806.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed proxying large S3 and Azure artifacts without buffering their complete contents.
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ graft pulpcore/etc
graft pulp_certguard/tests/functional/artifacts
exclude .gitleaks.toml
include LICENSE
include pulpcore/vendor/storages/LICENSE
include pyproject.toml
include CHANGES.md
include COMMITMENT
Expand Down
18 changes: 14 additions & 4 deletions docs/admin/guides/configure-pulp/configure-storages.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Configure Storage Backend

Pulp uses [django-storages](https://django-storages.readthedocs.io) to support multiple storage backends.
Pulp bundles supported object-storage backends based on [django-storages](https://django-storages.readthedocs.io).
Use the `pulpcore.vendor.storages` import paths when selecting a backend in Django's `STORAGES` setting.
See the reference for the [`STORAGES` settings](site:pulpcore/docs/admin/reference/settings/#storages).

## Modifying the settings
Expand All @@ -9,6 +10,12 @@ The settings can be updated via the `settings.py` file or through environment va
and have support to dynaconf merge features.
The means to modify them will depend on your deployment option.

When upgrading a deployment with a custom `STORAGES` setting, change Pulp backend implementation
paths from `storages.backends.*` to `pulpcore.vendor.storages.backends.*`. Pulp selects the
implementation for each Domain storage type internally; `DOMAIN_STORAGE_BACKENDS` is not a
supported deployment setting. Domain API `storage_class` values remain the historical
`storages.backends.*` identifiers.

Learn more on the [Settings Introduction](site:pulpcore/docs/admin/guides/configure-pulp/).

## Local Filesystem (default)
Expand Down Expand Up @@ -63,7 +70,7 @@ In this example, the storage uses a bucket called `pulp3` that is hosted in regi
MEDIA_ROOT = ""
STORAGES = {
"default": {
"BACKEND": "storages.backends.s3.S3Storage",
"BACKEND": "pulpcore.vendor.storages.backends.s3.S3Storage",
"OPTIONS": {
"access_key": 'AKIAIT2Z5TDYPX3ARJBA',
"secret_key": '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',
Expand Down Expand Up @@ -102,6 +109,9 @@ You'll need:

When creating a `Domain` you can use the following payload:

The `storage_class` value is a historical API identifier. Keep using the `storages.backends.*`
value there; use the `pulpcore.vendor.storages.backends.*` path only in `STORAGES` settings.

```json
{
"name": "cloudfront_storage",
Expand Down Expand Up @@ -150,7 +160,7 @@ Comprehensive options for Amazon S3 can be found in

## S3 Compatible

The same `storages.backends.s3.S3Storage` backend can be used for S3 Compatible API services, such as [rustfs](https://rustfs.com/), [Ceph/RADOS](https://docs.ceph.com/en/reef/man/8/rados/) and [Backblaze B2](https://www.backblaze.com/cloud-storage).
The same S3 `storage_class` identifier can be used for S3 Compatible API services, such as [rustfs](https://rustfs.com/), [Ceph/RADOS](https://docs.ceph.com/en/reef/man/8/rados/) and [Backblaze B2](https://www.backblaze.com/cloud-storage).

The [django-storages](https://django-storages.readthedocs.io/en/latest/backends/s3_compatible/index.html) documentation
provides a reference for setting up some of these services.
Expand All @@ -175,7 +185,7 @@ In this example, the storage uses a container called `pulp3` with the `pulp-acco
MEDIA_ROOT = ""
STORAGES = {
"default": {
"BACKEND": "storages.backends.azure_storage.AzureStorage",
"BACKEND": "pulpcore.vendor.storages.backends.azure_storage.AzureStorage",
"OPTIONS": {
"account_name": 'pulp-account',
"azure_container": 'pulp3',
Expand Down
9 changes: 3 additions & 6 deletions docs/admin/reference/settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,7 @@ print(''.join(secrets.choice(chars) for i in range(50)))
!!! note "Added in `3.70`"
Starting in `3.70`, this should be used in the place of [`DEFAULT_FILE_STORAGE`](#default_file_storage).

Pulp uses [django-storages] to support multiple storage backends.
If no backend is configured, Pulp will by default use the local filesystem (`pulpcore.app.models.storage.FileSystem`).
Pulp supports multiple storage backends using a vendored fork of [django-storages].

The storage setting has the form:

Expand All @@ -119,8 +118,7 @@ STORAGES = {
To use another backend storage, you'll need to:

1. Set up your storage and gather required credentials and specific configs.
1. Ensure the `django-storage[s3|google|azure]` python package is installed.
This depends on the installation method.
1. Install Pulp with the provider extra required by your backend, such as `s3`, `google`, or `azure`.
1. Configure the default `BACKEND` storage class.
1. Configure available `OPTIONS` for that backend.

Expand All @@ -130,7 +128,7 @@ Learn more on the
Overview of the integration with Pulp:

- **Supported**: We support (test) Amazon S3 and Azure.
- **Untested**: Other backends provided by `django-storages` may work as well, but we provide no guarantee.
- **Untested**: Other backends may work, but we provide no guarantee.


## Pulp Settings
Expand Down Expand Up @@ -647,7 +645,6 @@ Defaults to `pulpcore.tasking.status`.
[djangosaml2]: https://djangosaml2.readthedocs.io
[Django secret key]: https://docs.djangoproject.com/en/4.2/ref/settings/#secret-key
[Django setting]: https://docs.djangoproject.com/en/4.2/ref/settings/
[django-storages]: https://django-storages.readthedocs.io/en/latest/index.html
[Django warning at the end of this section in their docs]: https://docs.djangoproject.com/en/4.2/howto/auth-remote-user/#configuration
[Enabling Debug Logging]: site:pulpcore/docs/admin/guides/troubleshooting/#enabling-debug-logging
[librdkafka configuration documentation]: https://github.com/confluentinc/librdkafka/blob/master/CONFIGURATION.md
Expand Down
68 changes: 0 additions & 68 deletions docs/dev/learn/domains/storage_backend_implementations.md

This file was deleted.

75 changes: 74 additions & 1 deletion pulp_file/tests/functional/api/test_download_policies.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,15 @@
from urllib.parse import urljoin

import pytest
import requests
from aiohttp.client_exceptions import ClientResponseError
from bs4 import BeautifulSoup

from pulpcore.client.pulp_file import FileFilePublication, FileRepositorySyncURL
from pulpcore.client.pulp_file import (
FileFilePublication,
FileRepositorySyncURL,
RepositoryAddRemoveContent,
)
from pulpcore.tests.functional.utils import download_file, get_files_in_manifest

OBJECT_STORAGES = (
Expand All @@ -37,6 +42,74 @@ def _do_range_request_download_and_assert(url, range_header, expected_bytes):
)


@pytest.mark.parametrize(
"storage_class",
(
pytest.param("pulpcore.vendor.storages.backends.s3.S3Storage", id="s3"),
pytest.param("pulpcore.vendor.storages.backends.s3boto3.S3Boto3Storage", id="s3boto3"),
pytest.param("pulpcore.vendor.storages.backends.azure_storage.AzureStorage", id="azure"),
),
)
def test_proxied_object_storage_artifact_streaming(
storage_class,
pulp_settings,
domain_factory,
random_artifact_factory,
file_bindings,
file_repository_factory,
file_publication_factory,
file_distribution_factory,
distribution_base_url,
gen_object_with_cleanup,
monitor_task,
):
"""Serve full and ranged object-storage content through Pulp without redirects."""

if pulp_settings.STORAGES["default"]["BACKEND"] != storage_class:
pytest.skip("The functional environment does not provide this object-storage configuration")

domain = domain_factory(storage_class=storage_class, redirect_to_object_storage=False)
artifact = random_artifact_factory(pulp_domain=domain.name, size=32)
content = gen_object_with_cleanup(
file_bindings.ContentFilesApi,
artifact=artifact.pulp_href,
relative_path=str(uuid.uuid4()),
pulp_domain=domain.name,
)
repository = file_repository_factory(pulp_domain=domain.name)
monitor_task(
file_bindings.RepositoriesFileApi.modify(
repository.pulp_href,
RepositoryAddRemoveContent(add_content_units=[content.pulp_href]),
).task
)
publication = file_publication_factory(
pulp_domain=domain.name,
repository=repository.pulp_href,
)
distribution = file_distribution_factory(
pulp_domain=domain.name,
publication=publication.pulp_href,
)
content_url = urljoin(distribution_base_url(distribution.base_url), content.relative_path)

full_response = requests.get(content_url, allow_redirects=False)
assert full_response.status_code == requests.codes.ok
assert not full_response.is_redirect
assert hashlib.sha256(full_response.content).hexdigest() == artifact.sha256
assert full_response.headers["Content-Length"] == str(len(full_response.content))
assert full_response.headers["Accept-Ranges"] == "bytes"

range_response = requests.get(
content_url, headers={"Range": "bytes=1-4"}, allow_redirects=False
)
assert range_response.status_code == requests.codes.partial_content
assert not range_response.is_redirect
assert range_response.content == full_response.content[1:5]
assert range_response.headers["Content-Length"] == "4"
assert range_response.headers["Content-Range"] == f"bytes 1-4/{len(full_response.content)}"


@pytest.mark.parallel
@pytest.mark.parametrize("download_policy", ["immediate", "on_demand", "streamed"])
def test_download_policy(
Expand Down
10 changes: 0 additions & 10 deletions pulpcore/app/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,6 @@
},
}

# Domain class paths are treated as legacy backend identifiers. Override a path
# here to change the implementation without rewriting stored Domain rows.
DOMAIN_STORAGE_BACKENDS = {
constants.STORAGE_BACKENDS.FILESYSTEM: "pulpcore.app.models.storage.FileSystem",
constants.STORAGE_BACKENDS.S3: "storages.backends.s3.S3Storage",
constants.STORAGE_BACKENDS.AZURE: "storages.backends.azure_storage.AzureStorage",
constants.STORAGE_BACKENDS.GCS: "storages.backends.gcloud.GoogleCloudStorage",
}

REDIRECT_TO_OBJECT_STORAGE = True

WORKING_DIRECTORY = DEPLOY_ROOT / "tmp"
Expand Down Expand Up @@ -127,7 +118,6 @@
OPTIONAL_APPS = [
"crispy_forms",
"django_extensions",
"storages",
]

for app in OPTIONAL_APPS:
Expand Down
Loading