From 1bf12322c0359a4ccc52599d074f87a59a63d7d1 Mon Sep 17 00:00:00 2001 From: Jacob Henner Date: Sun, 14 Feb 2021 18:49:43 -0500 Subject: [PATCH] Increase aiohttp read buffer to 2MiB (#138) The previous default (64KiB) would cause `ValueError: Line is too long` exceptions on watch events with large objects. Requires aiohttp >= 3.7.0 --- kubernetes_asyncio/client/rest.py | 9 ++++++++- requirements.txt | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/kubernetes_asyncio/client/rest.py b/kubernetes_asyncio/client/rest.py index 83a44992f..0fa723782 100644 --- a/kubernetes_asyncio/client/rest.py +++ b/kubernetes_asyncio/client/rest.py @@ -78,7 +78,14 @@ def __init__(self, configuration, pools_size=4, maxsize=None): # https pool manager self.pool_manager = aiohttp.ClientSession( - connector=connector + connector=connector, + # Watch events containing large resource objects can exceed + # aiohttp's default read buffer size. + # + # There is no hard-limit defined by k8s, but the etcd default + # maximum request size is 1.5MiB. + # https://github.com/kubernetes/kubernetes/issues/19781 + read_bufsize=2**21 ) async def close(self): diff --git a/requirements.txt b/requirements.txt index b70652ce0..aa824b7ab 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,4 +4,4 @@ python-dateutil>=2.5.3 # BSD setuptools>=21.0.0 # PSF/ZPL urllib3>=1.24.2 # MIT pyyaml>=3.12 # MIT -aiohttp>=2.3.10,<4.0.0 # # Apache-2.0 +aiohttp>=3.7.0,<4.0.0 # # Apache-2.0