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

Fixes #33893 - fix smart proxy sync with blank url #9775

Merged
merged 1 commit into from Nov 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/lib/actions/katello/capsule_content/refresh_repos.rb
Expand Up @@ -40,7 +40,7 @@ def invoke_external_task
pulp_repo = repo.backend_service(smart_proxy)
if !current_repos_on_capsule_ids.include?(repo.id)
pulp_repo.create_mirror_entities
elsif pulp_repo.mirror_needs_updates?
else
tasks += pulp_repo.refresh_mirror_entities
end
end
Expand Down
9 changes: 5 additions & 4 deletions app/lib/actions/pulp3/capsule_content/generate_metadata.rb
Expand Up @@ -17,13 +17,14 @@ def plan(repository, smart_proxy, options = {})

def invoke_external_task
repository = ::Katello::Repository.find(input[:repository_id])
backend = repository.backend_service(smart_proxy).with_mirror_adapter
#yum repositories use metadata mirroring always, so we should never
# regenerate metadata on proxies
if repository.yum?
# regenerate metadata on proxies. but if there is no publication,
# it means the repo was likely empty and syncing didn't generate one
if repository.yum? && backend.publication_href.present?
[]
else
smart_proxy = ::SmartProxy.unscoped.find(input[:smart_proxy_id])
repository.backend_service(smart_proxy).with_mirror_adapter.create_publication
backend.create_publication
end
end
end
Expand Down
4 changes: 0 additions & 4 deletions app/services/katello/pulp3/repository.rb
Expand Up @@ -183,10 +183,6 @@ def refresh_mirror_entities
RepositoryMirror.new(self).refresh_entities
end

def mirror_needs_updates?
RepositoryMirror.new(self).needs_updates?
end

def refresh_if_needed
tasks = []
tasks << update_remote #always update remote
Expand Down
2 changes: 1 addition & 1 deletion app/services/katello/pulp3/repository_mirror.rb
Expand Up @@ -79,7 +79,7 @@ def version_href
end

def publication_href
api.publications_api.list(:repository_version => version_href).results.first.pulp_href
api.publications_api.list(:repository_version => version_href).results.first&.pulp_href
end

def create_version(options = {})
Expand Down
2 changes: 0 additions & 2 deletions test/actions/pulp/repository/refresh_repos_test.rb
Expand Up @@ -41,7 +41,6 @@ def setup
planned_action = create_and_plan_action action_class, @smart_proxy, repository: repo
# repo already exist in capsule
::Katello::Pulp::SmartProxyRepository.any_instance.expects(:current_repositories).returns([repo])
pulp_repo.expects(:mirror_needs_updates?).returns(true)
pulp_repo.expects(:refresh_mirror_entities).once.returns([])
run_action planned_action
end
Expand Down Expand Up @@ -74,7 +73,6 @@ def setup
planned_action = create_and_plan_action action_class, @smart_proxy, repository: repo
# repo already exist in capsule
::Katello::Pulp3::SmartProxyRepository.any_instance.expects(:current_repositories).returns([repo])
pulp_repo.expects(:mirror_needs_updates?).returns(true)
pulp_repo.expects(:refresh_mirror_entities).once.returns([])
run_action planned_action
end
Expand Down