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

Synchronizing rpm repositories using channel lookup #9052

Conversation

waterflow80
Copy link
Collaborator

@waterflow80 waterflow80 commented Jul 14, 2024

What does this PR change?

Added the --channel argument, which enables the sync of the repos (currently rpms) using the channel label.
The channel's and the corresponding repositories' information is fetched from the database.

GUI diff

No difference.

  • DONE

Documentation

  • No documentation needed: only internal and user invisible changes

  • DONE

Test coverage

  • No tests: In progress

  • DONE

Links

Issue(s): #
Port(s): # add downstream PR(s), if any

  • DONE

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!

Comment on lines 101 to 106
rpm_repository = RPMRepo(args.name, args.cache, args.url, arch)
packages = rpm_repository.get_packages_metadata() # packages is a generator
failed = 0
for i, batch in enumerate(batched(packages, args.batch_size)):
failed += import_package_batch(batch, i)
logging.debug("Completed import with %d failed packages", failed)
Copy link
Contributor

Choose a reason for hiding this comment

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

You can probably move this into a function to share it with the channel case.

for repo in target_repos:
if repo.repo_type == "yum":
rpm_repository = RPMRepo(
repo.repo_label, args.cache, repo.source_url, arch
Copy link
Contributor

Choose a reason for hiding this comment

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

Use the channel arch instead of arch here: the architecture for a channel is provided by the database.

# No url specified
if args.channel:
channel_id = args.channel
target_repos = db_utils.get_repositories_by_channel_id(channel_id)
Copy link
Contributor

Choose a reason for hiding this comment

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

No one knows the channel ID, you cannot ask that as a command line parameter. What users will pass here is the channel label.

@@ -78,18 +80,55 @@ def main():
type=str,
)

parser.add_argument(
"--channel",
help="The channel id of which you want to synchronize repositories",
Copy link
Contributor

Choose a reason for hiding this comment

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

Not the channel id, but the channel label

Comment on lines 15 to 21
select s.id, s.source_url, s.metadata_signed, s.label as repo_label, cst.label as repo_type_label
from rhnContentSource s,
rhnChannelContentSource cs,
rhnContentSourceType cst
where s.id = cs.source_id
and cst.id = s.type_id
and cs.channel_id = :channel_id"""
Copy link
Contributor

Choose a reason for hiding this comment

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

You could join with the rhnChannel table and get the repositories by channel label. In which case you would need to copy the channel architecture in each RepoDTO

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

Copy link
Contributor

This PR is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 10 days.

@github-actions github-actions bot added the Stale label Sep 14, 2024
@waterflow80
Copy link
Collaborator Author

The Code of this PR is included here, we no longer need this.

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