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

Add compression_type option for publish #3367

Merged
merged 2 commits into from
Dec 13, 2023

Conversation

pedro-psb
Copy link
Member

With support for zstd compression.

closes #3316

@pedro-psb pedro-psb force-pushed the feature/add-compression-type branch 2 times, most recently from 7d9fc35 to 319c067 Compare December 12, 2023 20:44
ALLOWED_CHECKSUM_ERROR_MSG,
CHECKSUM_TYPES,
PACKAGES_DIRECTORY,
COMPRESSION_TYPES,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you mind alphabetizing the imports?

"""Sync and publish an RPM repository w/ zstd compression and verify it exists."""
# 1. Publish and distribute
publish_data = RpmRpmPublication(
repository=rpm_unsigned_repo_immediate.pulp_href, compression_type="zstd"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The compression_type value here isn't actually parameterized, it's only using zstd

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, my bad

)
for elem in metadata_elements:
elem_href = elem.find(xpath_location).get("href")
assert elem_href.endswith(".zst")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Likewise the test is only checking for a .zst extension regardless of the value of compression_type

requests.get(os.path.join(distribution.base_url, "repodata/repomd.xml")).text
)
xpath_data = "{{{}}}data".format(RPM_NAMESPACES["metadata/repo"])
xpath_location = "{{{}}}location".format(RPM_NAMESPACES["metadata/repo"])
Copy link
Contributor

@dralley dralley Dec 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can refactor this along with _get_updateinfo_xml_path into a shared helper function that returns the "data" value (primary, filelists, other, updateinfo, etc.) as dictionary keys and the href as dictionary values.

def get_repomd_metadata_urls(self, repomd_url: str):
    repomd_xml = requests.get(os.path.join(distribution.base_url, "repodata/repomd.xml")).text
    repomd = ElementTree.fromstring(repomd_xml)    
    xpath_data = "{{{}}}data".format(RPM_NAMESPACES["metadata/repo"])
    xpath_location = "{{{}}}location".format(RPM_NAMESPACES["metadata/repo"])
    hrefs = {}
    for elem in repomd.findall(xpath_data):
        md_type = elem.get("type")
        hrefs[md_type] = elem.find(xpath_location).get("href")
    return hrefs
# usage
for md_type, location in self.get_repomd_metadata_urls(url).items():
    if md_type in {"primary", "filelists", "other"}:
        assert location.endswith(".zst")
update_xml_url = self._get_updateinfo_xml_path(repomd)["updateinfo"]
# ...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for snippet

Add compression_type option for publishing with support for zstd.

closes pulp#3316
@pedro-psb pedro-psb force-pushed the feature/add-compression-type branch from 319c067 to 0d11485 Compare December 13, 2023 12:56
@github-actions github-actions bot added the multi-commit Added when a PR consists of more than one commit label Dec 13, 2023
>>> get_repomd_metadata(distribution.base_url)
{
"primary": "repodata/.../primary.xml.gz",
"filelists": "repodata/.../listfiles.xml.gz",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

listfiles.xml.gz -> filelists.xml.gz

Copy link
Contributor

@dralley dralley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved apart from a minor typo

- Use new "get_repomd_metadata_urls" helper function in the
"test_validate_no_checksum_tag" and remove the old specific helper
function.
- Typos

[noissue]
@pedro-psb pedro-psb force-pushed the feature/add-compression-type branch from 0d11485 to 46648a0 Compare December 13, 2023 18:41
@dralley dralley merged commit 46a76ea into pulp:main Dec 13, 2023
16 checks passed
@pedro-psb pedro-psb deleted the feature/add-compression-type branch December 13, 2023 19:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
multi-commit Added when a PR consists of more than one commit
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for publishing Zstd-compressed metadata
2 participants