Skip to content

Commit 5013d16

Browse files
committed
Migrate to Django 5 storages
1 parent 8e03064 commit 5013d16

File tree

7 files changed

+72
-51
lines changed

7 files changed

+72
-51
lines changed

.ci/assets/ci_constraints.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Pulpcore versions without the openapi command do no longer work in the CI
2-
pulpcore>=3.21.30,!=3.23.*,!=3.24.*,!=3.25.*,!=3.26.*,!=3.27.*,!=3.29.*,!=3.30.*,!=3.31.*,!=3.32.*,!=3.33.*,!=3.34.*,!=3.35.*,!=3.36.*,!=3.37.*,!=3.38.*,!=3.40.*,!=3.41.*,!=3.42.*,!=3.43.*,!=3.44.*,!=3.45.*,!=3.46.*,!=3.47.*,!=3.48.*,!=3.50.*,!=3.51.*,!=3.52.*,!=3.53.*,!=3.54.*
2+
# Pulpcore versions without the django 5 storage compatibility will fail, >3.63,<3.70
3+
pulpcore>=3.21.30,!=3.23.*,!=3.24.*,!=3.25.*,!=3.26.*,!=3.27.*,!=3.29.*,!=3.30.*,!=3.31.*,!=3.32.*,!=3.33.*,!=3.34.*,!=3.35.*,!=3.36.*,!=3.37.*,!=3.38.*,!=3.40.*,!=3.41.*,!=3.42.*,!=3.43.*,!=3.44.*,!=3.45.*,!=3.46.*,!=3.47.*,!=3.48.*,!=3.50.*,!=3.51.*,!=3.52.*,!=3.53.*,!=3.54.*,!=3.64.*,!=3.65.*,!=3.66.*,!=3.67.*,!=3.68.*,!=3.69.*
34

45

56
tablib!=3.6.0

.ci/scripts/check_release.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,20 @@
11
#!/usr/bin/env python
2+
# /// script
3+
# requires-python = ">=3.13"
4+
# dependencies = [
5+
# "gitpython>=3.1.46,<3.2.0",
6+
# "packaging>=26.0,<26.1",
7+
# "pyyaml>=6.0.3,<6.1.0",
8+
# ]
9+
# ///
210

311
import argparse
412
import re
513
import os
614
import tomllib
7-
import yaml
815
from pathlib import Path
16+
17+
import yaml
918
from packaging.version import Version
1019
from git import Repo
1120

.github/workflows/ci.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,13 @@ jobs:
9494
run_docs: ${{ needs.check-changes.outputs.run_docs }}
9595

9696
lint:
97-
needs:
98-
- "check-changes"
99-
if: needs.check-changes.outputs.run_tests == '1'
10097
uses: "./.github/workflows/lint.yml"
10198

10299
build:
103-
needs: "lint"
100+
needs:
101+
- "check-changes"
102+
- "lint"
103+
if: needs.check-changes.outputs.run_tests == '1'
104104
uses: "./.github/workflows/build.yml"
105105

106106
test:

.github/workflows/scripts/install.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ if [ "$TEST" = "s3" ]; then
9595
sed -i -e '$a s3_test: true\
9696
minio_access_key: "'$MINIO_ACCESS_KEY'"\
9797
minio_secret_key: "'$MINIO_SECRET_KEY'"\
98-
pulp_scenario_settings: {"AWS_ACCESS_KEY_ID": "AKIAIT2Z5TDYPX3ARJBA", "AWS_DEFAULT_ACL": "@none None", "AWS_S3_ADDRESSING_STYLE": "path", "AWS_S3_ENDPOINT_URL": "http://minio:9000", "AWS_S3_REGION_NAME": "eu-central-1", "AWS_S3_SIGNATURE_VERSION": "s3v4", "AWS_SECRET_ACCESS_KEY": "fqRvjWaPU5o0fCqQuUWbj9Fainj2pVZtBCiDiieS", "AWS_STORAGE_BUCKET_NAME": "pulp3", "DEFAULT_FILE_STORAGE": "storages.backends.s3boto3.S3Boto3Storage", "MEDIA_ROOT": ""}\
98+
pulp_scenario_settings: {"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://minio:9000", "region_name": "eu-central-1", "secret_key": "fqRvjWaPU5o0fCqQuUWbj9Fainj2pVZtBCiDiieS", "signature_version": "s3v4"}}, "staticfiles": {"BACKEND": "django.contrib.staticfiles.storage.StaticFilesStorage"}}}\
9999
pulp_scenario_env: {}\
100100
' vars/main.yaml
101101
export PULP_API_ROOT="/rerouted/djnd/"
@@ -109,7 +109,7 @@ if [ "$TEST" = "azure" ]; then
109109
- ./azurite:/etc/pulp\
110110
command: "azurite-blob --skipApiVersionCheck --blobHost 0.0.0.0"' vars/main.yaml
111111
sed -i -e '$a azure_test: true\
112-
pulp_scenario_settings: {"AZURE_ACCOUNT_KEY": "Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==", "AZURE_ACCOUNT_NAME": "devstoreaccount1", "AZURE_CONNECTION_STRING": "DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://ci-azurite:10000/devstoreaccount1;", "AZURE_CONTAINER": "pulp-test", "AZURE_LOCATION": "pulp3", "AZURE_OVERWRITE_FILES": true, "AZURE_URL_EXPIRATION_SECS": 120, "DEFAULT_FILE_STORAGE": "storages.backends.azure_storage.AzureStorage", "MEDIA_ROOT": ""}\
112+
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"}}}\
113113
pulp_scenario_env: {}\
114114
' vars/main.yaml
115115
fi

pulp_python/app/models.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
from django.contrib.postgres.fields import ArrayField
55
from django.core.exceptions import ObjectDoesNotExist
66
from django.db import models
7-
from django.conf import settings
87
from pulpcore.plugin.models import (
98
Content,
109
Publication,
@@ -13,6 +12,7 @@
1312
Repository,
1413
)
1514
from pulpcore.plugin.responses import ArtifactResponse
15+
from pulpcore.plugin.util import get_domain
1616

1717
from pathlib import PurePath
1818
from .utils import (
@@ -77,7 +77,7 @@ def content_handler(self, path):
7777
elif len(path.parts) and path.parts[0] == "simple":
7878
# Temporary fix for PublishedMetadata not being properly served from remote storage
7979
# https://github.com/pulp/pulp_python/issues/413
80-
if settings.DEFAULT_FILE_STORAGE != "pulpcore.app.models.storage.FileSystem":
80+
if get_domain().storage_class != "pulpcore.app.models.storage.FileSystem":
8181
if self.publication or self.repository:
8282
try:
8383
publication = self.publication or Publication.objects.filter(

pulp_python/app/utils.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import tempfile
44
import json
55
from collections import defaultdict
6-
from django.core.files.storage import default_storage as storage
76
from django.conf import settings
87
from jinja2 import Template
98
from packaging.utils import canonicalize_name
@@ -144,8 +143,8 @@ def get_project_metadata_from_artifact(filename, artifact):
144143
# because pkginfo validates that the filename has a valid extension before
145144
# reading it
146145
with tempfile.NamedTemporaryFile('wb', dir=".", suffix=filename) as temp_file:
147-
artifact_file = storage.open(artifact.file.name)
148-
shutil.copyfileobj(artifact_file, temp_file)
146+
artifact.file.seek(0)
147+
shutil.copyfileobj(artifact.file, temp_file)
149148
temp_file.flush()
150149
metadata = DIST_TYPES[packagetype](temp_file.name)
151150
metadata.packagetype = packagetype

template_config.yml

Lines changed: 50 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,21 @@
22
# were not present before running plugin-template have been added with their default values.
33

44
# generated with plugin_template
5+
#
6+
# After editing this file please always reapply the plugin template before committing any changes.
57

6-
api_root: /pulp/
8+
---
9+
api_root: "/pulp/"
710
black: false
811
check_commit_message: true
912
check_gettext: true
1013
check_manifest: true
1114
check_stray_pulpcore_imports: true
12-
ci_base_image: ghcr.io/pulp/pulp-ci-centos9
15+
ci_base_image: "ghcr.io/pulp/pulp-ci-centos9"
1316
ci_env: {}
14-
ci_trigger: '{pull_request: {branches: [''*'']}}'
15-
cli_package: pulp-cli
16-
cli_repo: https://github.com/pulp/pulp-cli.git
17+
ci_trigger: "{pull_request: {branches: ['*']}}"
18+
cli_package: "pulp-cli"
19+
cli_repo: "https://github.com/pulp/pulp-cli.git"
1720
core_import_allowed: []
1821
deploy_client_to_pypi: true
1922
deploy_client_to_rubygems: true
@@ -23,54 +26,62 @@ docker_fixtures: false
2326
extra_files: []
2427
flake8: true
2528
flake8_ignore: []
26-
github_org: pulp
29+
github_org: "pulp"
2730
latest_release_branch: null
2831
lint_requirements: true
2932
os_required_packages: []
3033
parallel_test_workers: 8
31-
plugin_app_label: python
32-
plugin_default_branch: main
33-
plugin_name: pulp_python
34+
plugin_app_label: "python"
35+
plugin_default_branch: "main"
36+
plugin_name: "pulp_python"
3437
plugins:
35-
- app_label: python
36-
name: pulp_python
37-
post_job_template: null
38-
pre_job_template: null
38+
- app_label: "python"
39+
name: "pulp_python"
3940
pulp_env: {}
4041
pulp_env_azure: {}
4142
pulp_env_gcp: {}
4243
pulp_env_s3: {}
43-
pulp_scheme: https
44+
pulp_scheme: "https"
4445
pulp_settings:
45-
allowed_export_paths: /tmp
46-
allowed_import_paths: /tmp
46+
allowed_export_paths: "/tmp"
47+
allowed_import_paths: "/tmp"
4748
orphan_protection_time: 0
48-
pypi_api_hostname: https://pulp:443
49+
pypi_api_hostname: "https://pulp:443"
4950
pulp_settings_azure:
50-
AZURE_ACCOUNT_KEY: Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==
51-
AZURE_ACCOUNT_NAME: devstoreaccount1
52-
AZURE_CONNECTION_STRING: DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://ci-azurite:10000/devstoreaccount1;
53-
AZURE_CONTAINER: pulp-test
54-
AZURE_LOCATION: pulp3
55-
AZURE_OVERWRITE_FILES: true
56-
AZURE_URL_EXPIRATION_SECS: 120
57-
DEFAULT_FILE_STORAGE: storages.backends.azure_storage.AzureStorage
58-
MEDIA_ROOT: ''
51+
MEDIA_ROOT: ""
52+
STORAGES:
53+
default:
54+
BACKEND: "storages.backends.azure_storage.AzureStorage"
55+
OPTIONS:
56+
account_key: "Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw=="
57+
account_name: "devstoreaccount1"
58+
azure_container: "pulp-test"
59+
connection_string: "DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://ci-azurite:10000/devstoreaccount1;"
60+
expiration_secs: 120
61+
location: "pulp3"
62+
overwrite_files: true
63+
staticfiles:
64+
BACKEND: "django.contrib.staticfiles.storage.StaticFilesStorage"
5965
pulp_settings_gcp: null
6066
pulp_settings_s3:
61-
AWS_ACCESS_KEY_ID: AKIAIT2Z5TDYPX3ARJBA
62-
AWS_DEFAULT_ACL: '@none None'
63-
AWS_S3_ADDRESSING_STYLE: path
64-
AWS_S3_ENDPOINT_URL: http://minio:9000
65-
AWS_S3_REGION_NAME: eu-central-1
66-
AWS_S3_SIGNATURE_VERSION: s3v4
67-
AWS_SECRET_ACCESS_KEY: fqRvjWaPU5o0fCqQuUWbj9Fainj2pVZtBCiDiieS
68-
AWS_STORAGE_BUCKET_NAME: pulp3
69-
DEFAULT_FILE_STORAGE: storages.backends.s3boto3.S3Boto3Storage
70-
MEDIA_ROOT: ''
67+
MEDIA_ROOT: ""
68+
STORAGES:
69+
default:
70+
BACKEND: "storages.backends.s3boto3.S3Boto3Storage"
71+
OPTIONS:
72+
access_key: "AKIAIT2Z5TDYPX3ARJBA"
73+
addressing_style: "path"
74+
bucket_name: "pulp3"
75+
default_acl: "@none"
76+
endpoint_url: "http://minio:9000"
77+
region_name: "eu-central-1"
78+
secret_key: "fqRvjWaPU5o0fCqQuUWbj9Fainj2pVZtBCiDiieS"
79+
signature_version: "s3v4"
80+
staticfiles:
81+
BACKEND: "django.contrib.staticfiles.storage.StaticFilesStorage"
7182
pydocstyle: true
72-
release_email: pulp-infra@redhat.com
73-
release_user: pulpbot
83+
release_email: "pulp-infra@redhat.com"
84+
release_user: "pulpbot"
7485
stalebot: true
7586
stalebot_days_until_close: 30
7687
stalebot_days_until_stale: 90
@@ -86,4 +97,5 @@ test_performance: false
8697
test_reroute: true
8798
test_s3: true
8899
use_issue_template: true
100+
...
89101

0 commit comments

Comments
 (0)