11import logging
2+ from typing import Optional , Any , AsyncGenerator
23
4+ import aiohttp
35from aiohttp import ClientResponseError , ClientError
46from lxml .etree import LxmlError
57from 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+
151172class 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