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

Remove legacy checksum, sqlite_metadata, and gpgcheck options #3879

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
11 changes: 0 additions & 11 deletions docs/user/tutorials/create_sync_publish.md
Original file line number Diff line number Diff line change
Expand Up @@ -248,12 +248,6 @@ run a full sync.

A publication can only be created once a sync task completes. The following optional parameters are available:

- metadata_checksum_type (deprecated): affects all the repodata, including primary.xml, repomd.xml, etc.
If not specified, the default SHA256 algorithm will be used.
- package_checksum_type (deprecated): affects package checksum type in all repo metadata files.
If not specified, the default SHA256 algorithm will be used.
Because of on_demand sync, it is possible that the requested checksum is not available.
In such case the one from the remote repo will be used.
- checksum_type: Sets the checksum type to be used by the repository metadata, including primary.xml, repomd.xml, etc.
If not specified, the default SHA256 algorithm will be used. Because of on_demand sync, it is possible that the
requested checksum is not available. In such case the available checksum supplied by the remote repo will be used.
Expand Down Expand Up @@ -299,11 +293,6 @@ A publication can only be created once a sync task completes. The following opti
"repository_version": "/pulp/api/v3/repositories/rpm/rpm/678798cd-9e08-4c9d-9feb-7dc88412b101/versions/1/",
"repository": "/pulp/api/v3/repositories/rpm/rpm/678798cd-9e08-4c9d-9feb-7dc88412b101/",
"checksum_type": "sha256",
"metadata_checksum_type": "sha256",
"package_checksum_type": "sha256",
"gpgcheck": null,
"repo_gpgcheck": null,
"sqlite_metadata": false,
"repo_config": {
"gpgcheck": 1,
"repo-gpgcheck": 1
Expand Down
191 changes: 10 additions & 181 deletions pulp_rpm/app/serializers/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,53 +99,12 @@ class RpmRepositorySerializer(RepositorySerializer):
required=False,
allow_null=True,
)
metadata_checksum_type = serializers.ChoiceField(
help_text=_("DEPRECATED: use CHECKSUM_TYPE instead."),
choices=CHECKSUM_CHOICES,
required=False,
allow_null=True,
)
package_checksum_type = serializers.ChoiceField(
help_text=_("DEPRECATED: use CHECKSUM_TYPE instead."),
choices=CHECKSUM_CHOICES,
required=False,
allow_null=True,
)
compression_type = serializers.ChoiceField(
help_text=_("The compression type to use for metadata files."),
choices=COMPRESSION_CHOICES,
required=False,
allow_null=True,
)
gpgcheck = serializers.IntegerField(
max_value=1,
min_value=0,
required=False,
allow_null=True,
help_text=_(
"DEPRECATED: An option specifying whether a client should perform "
"a GPG signature check on packages."
),
)
repo_gpgcheck = serializers.IntegerField(
max_value=1,
min_value=0,
required=False,
allow_null=True,
help_text=_(
"DEPRECATED: An option specifying whether a client should perform "
"a GPG signature check on the repodata."
),
)
sqlite_metadata = serializers.BooleanField(
default=False,
required=False,
help_text=_(
"REMOVED: An option specifying whether Pulp should generate SQLite metadata. "
"Not operation since pulp_rpm 3.25.0 release"
),
read_only=True,
)
repo_config = serializers.JSONField(
required=False,
help_text=_("A JSON document describing config.repo file"),
Expand All @@ -168,39 +127,16 @@ def to_representation(self, instance):

def validate(self, data):
"""Validate data."""
for field in ("checksum_type", "metadata_checksum_type", "package_checksum_type"):
if field in data and data[field]:
if data[field] not in settings.ALLOWED_CONTENT_CHECKSUMS:
raise serializers.ValidationError({field: _(ALLOWED_CHECKSUM_ERROR_MSG)})
if checksum_type := data.get("checksum_type"):
if checksum_type not in settings.ALLOWED_CONTENT_CHECKSUMS:
raise serializers.ValidationError({field: _(ALLOWED_CHECKSUM_ERROR_MSG)})

if data[field] not in ALLOWED_PUBLISH_CHECKSUMS:
raise serializers.ValidationError(
{field: _(ALLOWED_PUBLISH_CHECKSUM_ERROR_MSG)}
)

if data.get("package_checksum_type") or data.get("metadata_checksum_type"):
logging.getLogger("pulp_rpm.deprecation").info(
"Support for '*_checksum_type' options will be removed from a future release "
"of pulp_rpm."
)
if data.get("checksum_type"):
if checksum_type not in ALLOWED_PUBLISH_CHECKSUMS:
raise serializers.ValidationError(
_(
"Cannot use '*_checksum_type' options and 'checksum_type' options "
"simultaneously. The 'package_checksum_type' and 'metadata_checksum_type' "
"options are deprecated, please use 'checksum_type' only."
)
{field: _(ALLOWED_PUBLISH_CHECKSUM_ERROR_MSG)}
)

validated_data = super().validate(data)
if (data.get("gpgcheck") or data.get("repo_gpgcheck")) and data.get("repo_config"):
raise serializers.ValidationError(
_(
"Cannot use gpg options and 'repo_config' options simultaneously. "
"The 'gpgcheck' and 'repo_gpgcheck' options are deprecated, please use "
"'repo_config' only."
)
)
return validated_data

def create(self, validated_data):
Expand All @@ -213,24 +149,7 @@ def create(self, validated_data):
Returns:
repo: the created repo
"""
# gpg options are deprecated in favour of repo_config
# acting as shim layer between old and new api
gpgcheck = validated_data.pop("gpgcheck", None)
repo_gpgcheck = validated_data.pop("repo_gpgcheck", None)
gpgcheck_options = {}
if gpgcheck is not None:
gpgcheck_options["gpgcheck"] = gpgcheck
if repo_gpgcheck is not None:
gpgcheck_options["repo_gpgcheck"] = repo_gpgcheck
if gpgcheck_options.keys():
logging.getLogger("pulp_rpm.deprecation").info(
"Support for gpg options will be removed from a future release of pulp_rpm."
)
repo_config = (
gpgcheck_options if gpgcheck_options else validated_data.get("repo_config", {})
)
repo = super().create(validated_data)
repo.repo_config = repo_config
return repo

def update(self, instance, validated_data):
Expand All @@ -243,23 +162,6 @@ def update(self, instance, validated_data):
Returns:
repo: the updated repo
"""
# gpg options are deprecated in favour of repo_config
# acting as shim layer between old and new api
gpgcheck = validated_data.pop("gpgcheck", None)
repo_gpgcheck = validated_data.pop("repo_gpgcheck", None)
gpgcheck_options = {}
if gpgcheck is not None:
gpgcheck_options["gpgcheck"] = gpgcheck
if repo_gpgcheck is not None:
gpgcheck_options["repo_gpgcheck"] = repo_gpgcheck
if gpgcheck_options.keys():
logging.getLogger("pulp_rpm.deprecation").info(
"Support for gpg options will be removed from a future release of pulp_rpm."
)
repo_config = (
gpgcheck_options if gpgcheck_options else validated_data.get("repo_config", {})
)
instance.repo_config = repo_config
instance = super().update(instance, validated_data)
return instance

Expand All @@ -271,11 +173,6 @@ class Meta:
"package_signing_fingerprint",
"retain_package_versions",
"checksum_type",
"metadata_checksum_type",
"package_checksum_type",
"gpgcheck",
"repo_gpgcheck",
"sqlite_metadata",
"repo_config",
"compression_type",
)
Expand Down Expand Up @@ -374,17 +271,6 @@ class RpmPublicationSerializer(PublicationSerializer):
"""
A Serializer for RpmPublication.
"""

metadata_checksum_type = serializers.ChoiceField(
help_text=_("DEPRECATED: The checksum type for metadata."),
choices=CHECKSUM_CHOICES,
required=False,
)
package_checksum_type = serializers.ChoiceField(
help_text=_("DEPRECATED: The checksum type for packages."),
choices=CHECKSUM_CHOICES,
required=False,
)
checksum_type = serializers.ChoiceField(
help_text=_("The preferred checksum type used during repo publishes."),
choices=CHECKSUM_CHOICES,
Expand All @@ -395,85 +281,28 @@ class RpmPublicationSerializer(PublicationSerializer):
choices=COMPRESSION_CHOICES,
required=False,
)
gpgcheck = serializers.IntegerField(
max_value=1,
min_value=0,
required=False,
allow_null=True,
help_text=_(
"DEPRECATED: An option specifying whether a client should perform "
"a GPG signature check on packages."
),
)
repo_gpgcheck = serializers.IntegerField(
max_value=1,
min_value=0,
required=False,
allow_null=True,
help_text=_(
"DEPRECATED: An option specifying whether a client should perform "
"a GPG signature check on the repodata."
),
)
sqlite_metadata = serializers.BooleanField(
default=False,
required=False,
help_text=_(
"REMOVED: An option specifying whether Pulp should generate SQLite metadata. "
"Not operation since pulp_rpm 3.25.0 release"
),
read_only=True,
)
repo_config = serializers.JSONField(
required=False,
help_text=_("A JSON document describing config.repo file"),
)

def validate(self, data):
"""Validate data."""
for field in ("checksum_type", "metadata_checksum_type", "package_checksum_type"):
if field in data and data[field]:
if data[field] not in settings.ALLOWED_CONTENT_CHECKSUMS:
raise serializers.ValidationError({field: _(ALLOWED_CHECKSUM_ERROR_MSG)})

if data[field] not in ALLOWED_PUBLISH_CHECKSUMS:
raise serializers.ValidationError(
{field: _(ALLOWED_PUBLISH_CHECKSUM_ERROR_MSG)}
)
if checksum_type := data.get("checksum_type"):
if checksum_type not in settings.ALLOWED_CONTENT_CHECKSUMS:
raise serializers.ValidationError({field: _(ALLOWED_CHECKSUM_ERROR_MSG)})

if data.get("package_checksum_type") or data.get("metadata_checksum_type"):
logging.getLogger("pulp_rpm.deprecation").info(
"Support for '*_checksum_type' options will be removed from a future release "
"of pulp_rpm."
)
if data.get("checksum_type"):
if checksum_type not in ALLOWED_PUBLISH_CHECKSUMS:
raise serializers.ValidationError(
_(
"Cannot use '*_checksum_type' options and 'checksum_type' options "
"simultaneously. The 'package_checksum_type' and 'metadata_checksum_type' "
"options are deprecated, please use 'checksum_type' only."
)
{field: _(ALLOWED_PUBLISH_CHECKSUM_ERROR_MSG)}
)

validated_data = super().validate(data)
if (data.get("gpgcheck") or data.get("repo_gpgcheck")) and data.get("repo_config"):
raise serializers.ValidationError(
_(
"Cannot use gpg options and 'repo_config' options simultaneously. "
"The 'gpgcheck' and 'repo_gpgcheck' options are deprecated, please use "
"'repo_config' only."
)
)
return validated_data

class Meta:
fields = PublicationSerializer.Meta.fields + (
"checksum_type",
"metadata_checksum_type",
"package_checksum_type",
"gpgcheck",
"repo_gpgcheck",
"sqlite_metadata",
"repo_config",
"compression_type",
)
Expand Down
8 changes: 0 additions & 8 deletions pulp_rpm/app/viewsets/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -539,15 +539,7 @@ def create(self, request):
repository = RpmRepository.objects.get(pk=repository_version.repository.pk)

checksum_type = serializer.validated_data.get("checksum_type", repository.checksum_type)
metadata_checksum_type = serializer.validated_data.get(
"metadata_checksum_type", repository.metadata_checksum_type
)
package_checksum_type = serializer.validated_data.get(
"package_checksum_type", repository.package_checksum_type
)
checksum_types = dict(
metadata=metadata_checksum_type,
package=package_checksum_type,
general=checksum_type,
)
# gpg options are deprecated in favour of repo_config
Expand Down
10 changes: 4 additions & 6 deletions pulp_rpm/tests/functional/api/test_publish.py
Original file line number Diff line number Diff line change
Expand Up @@ -523,8 +523,7 @@ def get_checksum_types(

def _get_checksum_types(**kwargs):
fixture_url = kwargs.get("fixture_url", RPM_UNSIGNED_FIXTURE_URL)
package_checksum_type = kwargs.get("package_checksum_type")
metadata_checksum_type = kwargs.get("metadata_checksum_type")
configured_checksum_type = kwargs.get("checksum_type")
policy = kwargs.get("policy", "immediate")

# 1. create repo and remote
Expand All @@ -533,8 +532,7 @@ def _get_checksum_types(**kwargs):
# 2. Publish and distribute
publish_data = RpmRpmPublication(
repository=repo.pulp_href,
package_checksum_type=package_checksum_type,
metadata_checksum_type=metadata_checksum_type,
checksum_type=configured_checksum_type,
)
publish_response = rpm_publication_api.create(publish_data)
created_resources = monitor_task(publish_response.task).created_resources
Expand Down Expand Up @@ -593,7 +591,7 @@ def test_publish_with_disallowed_checksum_type(rpm_unsigned_repo_on_demand, rpm_
)

publish_data = RpmRpmPublication(
repository=rpm_unsigned_repo_on_demand.pulp_href, package_checksum_type="sha384"
repository=rpm_unsigned_repo_on_demand.pulp_href, checksum_type="sha384"
)
with pytest.raises(ApiException) as ctx:
rpm_publication_api.create(publish_data)
Expand All @@ -612,7 +610,7 @@ def test_publish_with_unsupported_checksum_type(rpm_unsigned_repo_on_demand, rpm
(even though it is in ALLOWED_CONTENT_CHECKSUMS)
"""
publish_data = RpmRpmPublication(
repository=rpm_unsigned_repo_on_demand.pulp_href, package_checksum_type="sha1"
repository=rpm_unsigned_repo_on_demand.pulp_href, checksum_type="sha1"
)
with pytest.raises(ApiException) as ctx:
rpm_publication_api.create(publish_data)
Expand Down
Loading