Skip to content

Commit 908d3bc

Browse files
authored
Merge pull request #895 from jobselko/patchback/backports/3.10/6644673ff04a3ad5775f2e4995edf18e054e0758/pr-656
[PR #656/6644673f backport][3.10] Fix sync with tls_validation=False
2 parents 598aa62 + 584822e commit 908d3bc

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

CHANGES/653.bugfix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fixed tls_validation not being disabled when set to false on the remote.

pulp_python/app/tasks/sync.py

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import logging
2+
from typing import Optional, Any, AsyncGenerator
23

4+
import aiohttp
35
from aiohttp import ClientResponseError, ClientError
46
from lxml.etree import LxmlError
57
from gettext import gettext as _
@@ -126,7 +128,7 @@ async def run(self):
126128
# Bandersnatch includes leading slash when forming API urls
127129
url = self.remote.url.rstrip("/")
128130
# local & global timeouts defaults to 10secs and 5 hours
129-
async with Master(url) as master:
131+
async with PulpMaster(url, tls=self.remote.tls_validation) as master:
130132
deferred_download = self.remote.policy != Remote.IMMEDIATE
131133
workers = self.remote.download_concurrency or self.remote.DEFAULT_DOWNLOAD_CONCURRENCY
132134
async with ProgressReport(
@@ -148,6 +150,25 @@ async def run(self):
148150
await pmirror.synchronize(packages_to_sync)
149151

150152

153+
class PulpMaster(Master):
154+
"""
155+
Pulp Master Class for Pulp specific overrides
156+
"""
157+
158+
def __init__(self, *args, tls=True, **kwargs):
159+
self.tls = tls
160+
super().__init__(*args, **kwargs)
161+
162+
async def get(
163+
self, path: str, required_serial: Optional[int], **kw: Any
164+
) -> AsyncGenerator[aiohttp.ClientResponse, None]:
165+
"""Support tls=false"""
166+
if not self.tls:
167+
kw["ssl"] = False
168+
async for r in super().get(path, required_serial, **kw):
169+
yield r
170+
171+
151172
class PulpMirror(Mirror):
152173
"""
153174
Pulp Mirror Class to perform syncing using Bandersnatch
@@ -257,4 +278,4 @@ def on_error(self, exception, **kwargs):
257278
TODO
258279
This should have some error checking
259280
"""
260-
pass
281+
logger.error("Sync encountered an error: ", exc_info=exception)

0 commit comments

Comments
 (0)