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

[PR #656/6644673f backport][3.11] Fix sync with tls_validation=False #660

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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES/653.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed tls_validation not being disabled when set to false on the remote.
25 changes: 23 additions & 2 deletions pulp_python/app/tasks/sync.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import logging
import tempfile
from typing import Optional, Any, AsyncGenerator

import aiohttp
from aiohttp import ClientResponseError, ClientError
from lxml.etree import LxmlError
from gettext import gettext as _
Expand Down Expand Up @@ -128,7 +130,7 @@ async def run(self):
# Bandersnatch includes leading slash when forming API urls
url = self.remote.url.rstrip("/")
# local & global timeouts defaults to 10secs and 5 hours
async with Master(url) as master:
async with PulpMaster(url, tls=self.remote.tls_validation) as master:
deferred_download = self.remote.policy != Remote.IMMEDIATE
workers = self.remote.download_concurrency or self.remote.DEFAULT_DOWNLOAD_CONCURRENCY
async with ProgressReport(
Expand All @@ -150,6 +152,25 @@ async def run(self):
await pmirror.synchronize(packages_to_sync)


class PulpMaster(Master):
"""
Pulp Master Class for Pulp specific overrides
"""

def __init__(self, *args, tls=True, **kwargs):
self.tls = tls
super().__init__(*args, **kwargs)

async def get(
self, path: str, required_serial: Optional[int], **kw: Any
) -> AsyncGenerator[aiohttp.ClientResponse, None]:
"""Support tls=false"""
if not self.tls:
kw["ssl"] = False
async for r in super().get(path, required_serial, **kw):
yield r


class PulpMirror(Mirror):
"""
Pulp Mirror Class to perform syncing using Bandersnatch
Expand Down Expand Up @@ -259,4 +280,4 @@ def on_error(self, exception, **kwargs):
TODO
This should have some error checking
"""
pass
logger.error("Sync encountered an error: ", exc_info=exception)
Loading