Skip to content

Commit

Permalink
Merge pull request #656 from gerrod3/tls-false
Browse files Browse the repository at this point in the history
Fix sync with tls_validation=False

(cherry picked from commit 6644673)
  • Loading branch information
gerrod3 authored and patchback[bot] committed Apr 11, 2024
1 parent 9dfae90 commit c636d00
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
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)

0 comments on commit c636d00

Please sign in to comment.