Skip to content

Commit

Permalink
Add pulpcore 3.25 compatibility
Browse files Browse the repository at this point in the history
closes pulp#1277
  • Loading branch information
ipanova committed May 17, 2023
1 parent 37804f1 commit cb99c04
Show file tree
Hide file tree
Showing 9 changed files with 165 additions and 25 deletions.
6 changes: 0 additions & 6 deletions .github/workflows/scripts/script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -123,17 +123,11 @@ else
cmd_user_prefix bash -c "pytest -v -r sx --color=yes --pyargs pulp_container.tests.functional -m 'not parallel' --nightly"


cmd_user_prefix bash -c "pytest -v -r sx --color=yes --suppress-no-test-exit-code --pyargs pulpcore.tests.functional -m 'from_pulpcore_for_all_plugins and parallel' -n 8 --nightly"
cmd_user_prefix bash -c "pytest -v -r sx --color=yes --suppress-no-test-exit-code --pyargs pulpcore.tests.functional -m 'from_pulpcore_for_all_plugins and not parallel' --nightly"

else
cmd_user_prefix bash -c "pytest -v -r sx --color=yes --suppress-no-test-exit-code --pyargs pulp_container.tests.functional -m parallel -n 8"
cmd_user_prefix bash -c "pytest -v -r sx --color=yes --pyargs pulp_container.tests.functional -m 'not parallel'"


cmd_user_prefix bash -c "pytest -v -r sx --color=yes --suppress-no-test-exit-code --pyargs pulpcore.tests.functional -m 'from_pulpcore_for_all_plugins and parallel' -n 8"
cmd_user_prefix bash -c "pytest -v -r sx --color=yes --suppress-no-test-exit-code --pyargs pulpcore.tests.functional -m 'from_pulpcore_for_all_plugins and not parallel'"

fi

fi
Expand Down
1 change: 1 addition & 0 deletions CHANGES/1277.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Updated compatibility for pulpcore 3.25 and Django 4.2.
152 changes: 152 additions & 0 deletions pulp_container/app/migrations/0035_alter_blob_content_ptr_and_more.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
# Generated by Django 4.2.1 on 2023-05-17 09:51

from django.db import migrations, models
import django.db.models.deletion
import pulpcore.app.models.base


class Migration(migrations.Migration):

dependencies = [
("core", "0106_alter_artifactdistribution_distribution_ptr_and_more"),
("container", "0034_translate_signed_schema"),
]

operations = [
migrations.AlterField(
model_name="blob",
name="content_ptr",
field=models.OneToOneField(
auto_created=True,
on_delete=django.db.models.deletion.CASCADE,
parent_link=True,
primary_key=True,
serialize=False,
to="core.content",
),
),
migrations.AlterField(
model_name="containerdistribution",
name="distribution_ptr",
field=models.OneToOneField(
auto_created=True,
on_delete=django.db.models.deletion.CASCADE,
parent_link=True,
primary_key=True,
serialize=False,
to="core.distribution",
),
),
migrations.AlterField(
model_name="containernamespace",
name="pulp_id",
field=models.UUIDField(
default=pulpcore.app.models.base.pulp_uuid,
editable=False,
primary_key=True,
serialize=False,
),
),
migrations.AlterField(
model_name="containerpushrepository",
name="manifest_signing_service",
field=models.ForeignKey(
null=True,
on_delete=django.db.models.deletion.SET_NULL,
to="container.manifestsigningservice",
),
),
migrations.AlterField(
model_name="containerpushrepository",
name="repository_ptr",
field=models.OneToOneField(
auto_created=True,
on_delete=django.db.models.deletion.CASCADE,
parent_link=True,
primary_key=True,
serialize=False,
to="core.repository",
),
),
migrations.AlterField(
model_name="containerremote",
name="remote_ptr",
field=models.OneToOneField(
auto_created=True,
on_delete=django.db.models.deletion.CASCADE,
parent_link=True,
primary_key=True,
serialize=False,
to="core.remote",
),
),
migrations.AlterField(
model_name="containerrepository",
name="manifest_signing_service",
field=models.ForeignKey(
null=True,
on_delete=django.db.models.deletion.SET_NULL,
to="container.manifestsigningservice",
),
),
migrations.AlterField(
model_name="containerrepository",
name="repository_ptr",
field=models.OneToOneField(
auto_created=True,
on_delete=django.db.models.deletion.CASCADE,
parent_link=True,
primary_key=True,
serialize=False,
to="core.repository",
),
),
migrations.AlterField(
model_name="manifest",
name="blobs",
field=models.ManyToManyField(through="container.BlobManifest", to="container.blob"),
),
migrations.AlterField(
model_name="manifest",
name="content_ptr",
field=models.OneToOneField(
auto_created=True,
on_delete=django.db.models.deletion.CASCADE,
parent_link=True,
primary_key=True,
serialize=False,
to="core.content",
),
),
migrations.AlterField(
model_name="manifest",
name="listed_manifests",
field=models.ManyToManyField(
through="container.ManifestListManifest", to="container.manifest"
),
),
migrations.AlterField(
model_name="manifestsignature",
name="content_ptr",
field=models.OneToOneField(
auto_created=True,
on_delete=django.db.models.deletion.CASCADE,
parent_link=True,
primary_key=True,
serialize=False,
to="core.content",
),
),
migrations.AlterField(
model_name="tag",
name="content_ptr",
field=models.OneToOneField(
auto_created=True,
on_delete=django.db.models.deletion.CASCADE,
parent_link=True,
primary_key=True,
serialize=False,
to="core.content",
),
),
]
4 changes: 2 additions & 2 deletions pulp_container/app/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
Upload as CoreUpload,
)
from pulpcore.plugin.repo_version_utils import remove_duplicates, validate_repo_version
from pulpcore.plugin.util import verify_signature
from pulpcore.plugin.util import gpg_verify


from . import downloaders
Expand Down Expand Up @@ -458,7 +458,7 @@ def validate(self):
manifest_file.name, env_vars={"REFERENCE": "test", "SIG_PATH": sig_path}
)

verify_signature(signed["signature_path"], self.public_key)
gpg_verify(self.public_key, signed["signature_path"])


class ContainerRepository(
Expand Down
8 changes: 3 additions & 5 deletions pulp_container/app/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ async def get_tag(self, request):
accepted_media_types = get_accepted_media_types(request.headers)

try:
tag = await sync_to_async(Tag.objects.select_related("tagged_manifest").get)(
tag = await Tag.objects.select_related("tagged_manifest").aget(
pk__in=await sync_to_async(repository_version.get_content)(), name=tag_name
)
except ObjectDoesNotExist:
Expand Down Expand Up @@ -170,7 +170,7 @@ async def dispatch_tag(self, request, tag, response_headers):
"""
try:
artifact = await sync_to_async(tag.tagged_manifest._artifacts.get)()
artifact = await tag.tagged_manifest._artifacts.aget()
except ObjectDoesNotExist:
ca = await sync_to_async(lambda x: x[0])(tag.tagged_manifest.contentartifact_set.all())
return await self._stream_content_artifact(request, web.StreamResponse(), ca)
Expand Down Expand Up @@ -230,9 +230,7 @@ async def get_by_digest(self, request):
if digest == EMPTY_BLOB:
return await Registry._empty_blob()
try:
ca = await sync_to_async(
ContentArtifact.objects.select_related("artifact", "content").get
)(
ca = await ContentArtifact.objects.select_related("artifact", "content").aget(
content__in=await sync_to_async(repository_version.get_content)(),
relative_path=digest,
)
Expand Down
9 changes: 2 additions & 7 deletions pulp_container/app/tasks/sync_stages.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,7 @@ async def _check_for_existing_manifest(self, download_tag):
digest = response.headers.get("docker-content-digest")

if digest and (
manifest := await sync_to_async(
Manifest.objects.prefetch_related("contentartifact_set").filter(digest=digest).first
)()
):
manifest := await Manifest.objects.prefetch_related("contentartifact_set").filter(digest=digest).afirst():
saved_artifact, content_data, raw_data = await sync_to_async(
self._get_content_data_blocking
)(manifest)
Expand Down Expand Up @@ -478,9 +475,7 @@ async def create_listed_manifest(self, manifest_data):
)
manifest_url = urljoin(self.remote.url, relative_url)

if manifest := await sync_to_async(
Manifest.objects.prefetch_related("contentartifact_set").filter(digest=digest).first
)():
if manifest := await Manifest.objects.prefetch_related("contentartifact_set").filter(digest=digest).afirst():
saved_artifact, content_data, _ = await sync_to_async(self._get_content_data_blocking)(
manifest
)
Expand Down
6 changes: 3 additions & 3 deletions pulp_container/tests/unit/test_serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from django.test import TestCase
from django.conf import settings

from django_currentuser.middleware import _set_current_user
from pulpcore.plugin.util import set_current_user

from pulp_container.app.serializers import ContainerDistributionSerializer, TagOperationSerializer
from pulp_container.app.models import ContainerPushRepository, ContainerRepository
Expand All @@ -28,13 +28,13 @@ def setUp(self):
f"{V3_API_ROOT}repositories/container/container-push/{self.push_repository.pk}/"
)
self.user = get_user_model().objects.create(username="user1", is_staff=False)
_set_current_user(self.user)
set_current_user(self.user)

def tearDown(self):
"""Delete the user."""
super().tearDown()
self.user.delete()
_set_current_user(None)
set_current_user(None)

def test_valid_mirror_data(self):
"""Test that the ContainerDistributionSerializer accepts valid data."""
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ecdsa>=0.14,<=0.18.0
jsonschema>=4.4,<4.18
pulpcore>=3.23.0,<3.25
pulpcore>=3.25.0,<3.40
pyjwkest>=1.4,<=1.4.2
pyjwt[crypto]>=2.4,<2.8
2 changes: 1 addition & 1 deletion template_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ pypi_username: pulp
python_version: '3.8'
release_email: pulp-infra@redhat.com
release_user: pulpbot
run_pulpcore_tests_for_plugins: true
run_pulpcore_tests_for_plugins: false
single_commit_check: true
stalebot: true
stalebot_days_until_close: 30
Expand Down

0 comments on commit cb99c04

Please sign in to comment.