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

AppStreams reposync module #8421

Merged
merged 3 commits into from
Apr 18, 2024

Conversation

cbbayburt
Copy link
Contributor

@cbbayburt cbbayburt commented Mar 7, 2024

A Python module that imports AppStream module metadata from the downloaded .yaml file during repo-sync.

Documentation

Test coverage

  • Unit tests were added

Links

Fixes https://github.com/SUSE/spacewalk/issues/23770

Changelogs

Make sure the changelogs entries you are adding are compliant with https://github.com/uyuni-project/uyuni/wiki/Contributing#changelogs and https://github.com/uyuni-project/uyuni/wiki/Contributing#uyuni-projectuyuni-repository

If you don't need a changelog check, please mark this checkbox:

  • No changelog needed

If you uncheck the checkbox after the PR is created, you will need to re-run changelog_test (see below)

Re-run a test

If you need to re-run a test, please mark the related checkbox, it will be unchecked automatically once it has re-run:

  • Re-run test "changelog_test"
  • Re-run test "backend_unittests_pgsql"
  • Re-run test "java_pgsql_tests"
  • Re-run test "schema_migration_test_pgsql"
  • Re-run test "susemanager_unittests"
  • Re-run test "javascript_lint"
  • Re-run test "spacecmd_unittests"

Before you merge

Check How to branch and merge properly!

@cbbayburt cbbayburt force-pushed the appstreams-reposync branch 2 times, most recently from b1ba7a2 to 953e113 Compare April 5, 2024 11:40
@cbbayburt cbbayburt marked this pull request as ready for review April 5, 2024 11:42
@cbbayburt cbbayburt requested a review from a team as a code owner April 5, 2024 11:42
@cbbayburt cbbayburt requested a review from vzhestkov April 5, 2024 11:42
@cbbayburt cbbayburt marked this pull request as draft April 5, 2024 11:42
@cbbayburt cbbayburt removed the request for review from vzhestkov April 5, 2024 11:42
@cbbayburt cbbayburt changed the base branch from master to appstreams April 5, 2024 14:52
@cbbayburt cbbayburt force-pushed the appstreams-reposync branch 3 times, most recently from 95f5c1b to c2a2862 Compare April 10, 2024 13:26
@cbbayburt cbbayburt marked this pull request as ready for review April 10, 2024 16:45
@cbbayburt cbbayburt requested review from a team and agraul and removed request for a team April 10, 2024 16:45
Copy link
Member

@agraul agraul left a comment

Choose a reason for hiding this comment

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

I only looked at the Python code. I think there is a risk of an SQL injection, please check that again. I also left a few other comments. Many are nitpicks, feel free to ignore them.

Comment on lines 211 to 213
sql = "INSERT INTO suseAppstreamApi (rpm, module_id) VALUES "
sql += ",".join([f"('{api}', {module_id})" for api in apis])
sql += " ON CONFLICT DO NOTHING"
Copy link
Member

Choose a reason for hiding this comment

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

Is this safe against SQL injections? I think we're handling untrusted input here.

Comment on lines 288 to 289
# Remove the trailing ':' if epoch is present
epoch = match.group("epoch")[:-1] if match.group("epoch") else None
Copy link
Member

Choose a reason for hiding this comment

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

[nitpick] If you don't want to have to comment the code you can use rstrip instead. Either way is fine.

Suggested change
# Remove the trailing ':' if epoch is present
epoch = match.group("epoch")[:-1] if match.group("epoch") else None
epoch = match.group("epoch").rstrip(":") if match.group("epoch") else None

modulemd_importer = ModuleMdImporter(
self.channel["id"], modulemd_path
)
modulemd_importer.validate()
Copy link
Member

Choose a reason for hiding this comment

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

This can raise an exception, can you add code that handles it? The general exception handler logs with "Unexpected error", maybe we can use a concrete logging statement instead.

Comment on lines +1141 to +1159
return self.copy_metadata_file(
plug, modulesfile, "modules", relative_modules_dir
)
Copy link
Member

Choose a reason for hiding this comment

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

Why was this changed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Black insists on it (and all the others) 😞

Copy link
Member

Choose a reason for hiding this comment

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

Are you running black from the container? reposync.py was already reformatted with black, I wonder why yours has a different line length

Comment on lines 1402 to 1404
to_disassociate[(db_pack["checksum_type"], db_pack["checksum"])] = (
True
)
Copy link
Member

Choose a reason for hiding this comment

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

Same here, why the reformatting?


assert exc.value.domain == "modulemd-yaml-error-quark"

# pylint: disable=protected-access
Copy link
Member

Choose a reason for hiding this comment

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

[nitpick] This looks like something has the wrong visibility

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This case tests the protected _get_modules method. Black doesn't let this without the disable directive.

# pylint: enable=wrong-import-position


class TestModuleMdImporter:
Copy link
Member

Choose a reason for hiding this comment

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

[nitpick] There is no need for a class here.

@wweellddeerr wweellddeerr mentioned this pull request Apr 15, 2024
18 tasks
@cbbayburt cbbayburt force-pushed the appstreams-reposync branch 6 times, most recently from 33c4456 to 6762863 Compare April 16, 2024 15:19
@cbbayburt cbbayburt requested a review from agraul April 16, 2024 15:23
@cbbayburt cbbayburt merged commit 0a6faec into uyuni-project:appstreams Apr 18, 2024
8 of 9 checks passed
@cbbayburt cbbayburt deleted the appstreams-reposync branch April 18, 2024 13:51
@cbbayburt cbbayburt mentioned this pull request Apr 23, 2024
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants