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 repo after sync #1268

Merged
merged 9 commits into from
Jan 13, 2025
16 changes: 16 additions & 0 deletions lib/rmt/scc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,26 @@ def sync
update_repositories(scc_api_client.list_repositories)

Repository.remove_suse_repos_without_tokens!
remove_obsolete_repositories(scc_api_client.list_repositories)
digitaltom marked this conversation as resolved.
Show resolved Hide resolved

update_subscriptions(scc_api_client.list_subscriptions)
end

def remove_obsolete_repositories(repos_data)
@logger.info _('Removing obsolete repositories')
scc_repo_ids = repos_data.pluck(:id)


# Find repositories in RMT that no longer exist in SCC
# Only consider repositories that have a non-null scc_id
repos_to_remove = Repository.where.not(scc_id: nil)
digitaltom marked this conversation as resolved.
Show resolved Hide resolved
.where.not(scc_id: scc_repo_ids)
if repos_to_remove.any?
repos_to_remove.delete_all
digitaltom marked this conversation as resolved.
Show resolved Hide resolved
@logger.info("Successfully removed #{repos_to_remove.count} obsolete repositories")
digitaltom marked this conversation as resolved.
Show resolved Hide resolved
end
end

def export(path)
credentials_set? || (raise CredentialsError, 'SCC credentials not set.')

Expand Down
6 changes: 6 additions & 0 deletions package/obs/rmt-server.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
-------------------------------------------------------------------
Fri Jan 03 13:06:20 UTC 2025 - Parag Jain <parag.jain@suse.com>

- Version 2.21
digitaltom marked this conversation as resolved.
Show resolved Hide resolved
* Fix: Remove obsolete repositories from rmt during SCC sync (bsc#1232808)

-------------------------------------------------------------------
Mon Dec 23 08:03:56 UTC 2024 - Parag Jain <parag.jain@suse.com>

Expand Down
Loading