Skip to content

Commit

Permalink
Activate streaming from object storage
Browse files Browse the repository at this point in the history
  • Loading branch information
mdellweg committed May 16, 2022
1 parent 66712c0 commit d768806
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 22 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Expand Up @@ -94,8 +94,10 @@ jobs:
- TEST: docs
- TEST: azure
- TEST: s3
- TEST: stream
outputs:
deprecations-pulp: ${{ steps.deprecations.outputs.deprecations-pulp }}
deprecations-stream: ${{ steps.deprecations.outputs.deprecations-stream }}
deprecations-azure: ${{ steps.deprecations.outputs.deprecations-azure }}
deprecations-s3: ${{ steps.deprecations.outputs.deprecations-s3 }}

Expand Down Expand Up @@ -345,13 +347,15 @@ jobs:
- name: Fail on deprecations
run: |
test -z "${{ needs.test.outputs.deprecations-pulp }}"
test -z "${{ needs.test.outputs.deprecations-stream }}"
test -z "${{ needs.test.outputs.deprecations-azure }}"
test -z "${{ needs.test.outputs.deprecations-s3 }}"
test -z "${{ needs.test.outputs.deprecations-upgrade }}"
- name: Print deprecations
if: failure()
run: |
echo "${{ needs.test.outputs.deprecations-pulp }}" | base64 -d
echo "${{ needs.test.outputs.deprecations-stream }}" | base64 -d
echo "${{ needs.test.outputs.deprecations-azure }}" | base64 -d
echo "${{ needs.test.outputs.deprecations-s3 }}" | base64 -d
echo "${{ needs.test.outputs.deprecations-upgrade }}" | base64 -d
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/nightly.yml
Expand Up @@ -26,6 +26,7 @@ jobs:
- TEST: docs
- TEST: azure
- TEST: s3
- TEST: stream
- TEST: generate-bindings

steps:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Expand Up @@ -84,6 +84,7 @@ jobs:
- TEST: docs
- TEST: azure
- TEST: s3
- TEST: stream
- TEST: generate-bindings

steps:
Expand Down
9 changes: 9 additions & 0 deletions .github/workflows/scripts/install.sh
Expand Up @@ -91,6 +91,15 @@ VARSYAML
if [ "$TEST" = "upgrade" ]; then
sed -i "/^pulp_container_tag:.*/s//pulp_container_tag: upgrade-https/" vars/main.yaml
fi
if [ "$TEST" == 'stream' ]; then
sed -i -e '/^services:/a \
- name: ci-sftp\
image: atmoz/sftp\
volumes:\
- ./ssh/id_ed25519.pub:/home/foo/.ssh/keys/id_ed25519.pub\
command: "foo::::storage"' vars/main.yaml
sed -i -e '$a stream_test: true' vars/main.yaml
fi

if [ "$TEST" = "s3" ]; then
export MINIO_ACCESS_KEY=AKIAIT2Z5TDYPX3ARJBA
Expand Down
1 change: 1 addition & 0 deletions CHANGES/943.feature
@@ -0,0 +1 @@
Enable support for the pulpcore setting ``REDIRECT_TO_OBJECT_STORAGE=False``.
41 changes: 20 additions & 21 deletions pulp_ansible/app/tasks/collections.py
@@ -1,27 +1,30 @@
import asyncio
from collections import defaultdict
from gettext import gettext as _
import hashlib
import json
import logging
import tarfile
import yaml
from collections import defaultdict
from gettext import gettext as _
from operator import attrgetter
from urllib.parse import urljoin
from uuid import uuid4

import yaml
from aiohttp.client_exceptions import ClientResponseError
from asgiref.sync import sync_to_async
from async_lru import alru_cache
from django.conf import settings
from django.db import transaction
from django.db.models import Q
from django.db.utils import IntegrityError
from django.urls import reverse
from django.utils.dateparse import parse_datetime
from galaxy_importer.collection import import_collection as process_collection
from galaxy_importer.collection import CollectionFilename
from galaxy_importer.collection import import_collection as process_collection
from galaxy_importer.collection import sync_collection
from galaxy_importer.exceptions import ImporterError
from git import GitCommandError, Repo
from pkg_resources import Requirement
from rest_framework.serializers import ValidationError

from pulpcore.plugin.models import (
Artifact,
ContentArtifact,
Expand All @@ -39,12 +42,13 @@
DeclarativeArtifact,
DeclarativeContent,
DeclarativeVersion,
QueryExistingArtifacts,
QueryExistingContents,
RemoteArtifactSaver,
ResolveContentFutures,
Stage,
QueryExistingArtifacts,
QueryExistingContents,
)
from rest_framework.serializers import ValidationError
from semantic_version import Version

from pulp_ansible.app.constants import PAGE_SIZE
Expand All @@ -58,22 +62,13 @@
CollectionVersionSignature,
Tag,
)
from pulp_ansible.app.serializers import CollectionVersionSerializer, CollectionRemoteSerializer
from pulp_ansible.app.serializers import CollectionRemoteSerializer, CollectionVersionSerializer
from pulp_ansible.app.tasks.utils import (
RequirementsFileEntry,
get_file_obj_from_tarball,
parse_metadata,
parse_collections_requirements_file,
RequirementsFileEntry,
parse_metadata,
)
from asgiref.sync import sync_to_async

from django.db.utils import IntegrityError
from galaxy_importer.collection import sync_collection
from git import GitCommandError, Repo


from uuid import uuid4


log = logging.getLogger(__name__)

Expand Down Expand Up @@ -310,6 +305,7 @@ def import_collection(
get_file_obj_from_tarball(tar, "FILES.json", temp_file.file.name)
)
url = _get_backend_storage_url(artifact_file)
artifact_file.seek(0)
importer_result = process_collection(
artifact_file, filename=filename, file_url=url, logger=user_facing_logger
)
Expand Down Expand Up @@ -397,7 +393,10 @@ def create_collection_from_importer(importer_result, metadata_only=False):

def _get_backend_storage_url(artifact_file):
"""Get artifact url from pulp backend storage."""
if settings.DEFAULT_FILE_STORAGE == "pulpcore.app.models.storage.FileSystem":
if (
settings.DEFAULT_FILE_STORAGE == "pulpcore.app.models.storage.FileSystem"
or not settings.REDIRECT_TO_OBJECT_STORAGE
):
url = None
elif settings.DEFAULT_FILE_STORAGE == "storages.backends.s3boto3.S3Boto3Storage":
parameters = {"ResponseContentDisposition": "attachment%3Bfilename=archive.tar.gz"}
Expand Down
2 changes: 1 addition & 1 deletion template_config.yml
Expand Up @@ -78,7 +78,7 @@ test_performance: false
test_released_plugin_with_next_pulpcore_release: false
test_reroute: true
test_s3: true
test_stream: false
test_stream: true
update_github: true
update_redmine: false
upgrade_range:
Expand Down

0 comments on commit d768806

Please sign in to comment.