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

aiohttp: Response payload is not completed #235

Open
hrybun opened this issue Jan 19, 2023 · 6 comments
Open

aiohttp: Response payload is not completed #235

hrybun opened this issue Jan 19, 2023 · 6 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@hrybun
Copy link

hrybun commented Jan 19, 2023

After about 3 minutes I got an error: aiohttp.client_exceptions.ClientPayloadError: Response payload is not completed

Run:

async def get_events(v1, field_selector: str):
    w = watch.Watch()
    async with w.stream(
            v1.list_event_for_all_namespaces,
            field_selector=field_selector,

    ) as stream:
        return stream

async def show_events(events):
    async for event in events:
        evt, obj = event["type"], event["object"]
        print(
            "-" * 40,
            f"\nMETHOD: {evt}\n"
            f"KIND: {obj.kind}\n"
            f"NAME: {obj.metadata.name}\n"
            f"NAMESPACE: {obj.metadata.namespace}\n"
            f"MESSAGE: {obj.message}\n",
        )

async def watch_events() -> None:
    async with ApiClient() as api:
        v1 = client.CoreV1Api(api)
        res_events = await asyncio.gather(
            *[
                get_events(v1, f"involvedObject.kind={name}")
                for name in ["Cluster", "Node"]
            ]
        )
        await asyncio.gather(*[show_events(event) for event in res_events])

python: 3.7.2 and 3.9.12
kubernetes_asyncio: 18.20.0 and 24.2.2

@tomplus
Copy link
Owner

tomplus commented Jan 19, 2023

Thanks for reporting the issue. Could you send information about your cluster - K8s version, cloud provider?

@hrybun
Copy link
Author

hrybun commented Jan 19, 2023

Now using k8s version 1.19 soon will add newer versions. We are developing cloud, now it is in closed beta testing.

@vishnukv-facets
Copy link

I am also facing this issue, will this be fixed?

@tomplus
Copy link
Owner

tomplus commented May 3, 2023

Unfortunately I'm not able to recreate the issue. @vishnukv-facets could you share more details about your case - your cluster type, k8s version, what kind of interfaces you are watching etc. Thanks.

@tomplus tomplus added bug Something isn't working help wanted Extra attention is needed labels May 3, 2023
@vishnukv-facets
Copy link

vishnukv-facets commented May 4, 2023

I am using a 1.24.9 AKS cluster in azure , python - 3.9, kubernetes_asyncio latest pip package
Screenshot 2023-05-04 at 1 00 24 PM

async with watch.Watch().stream(v1.list_namespaced_secret, namespace="default") as stream:
  async for event in stream:

The above piece of code always throws the error
even if i add timeout_seconds it still throws the aiohttp.client_exceptions.ClientPayloadError: Response payload is not completed error

sometimes i get this error too
Screenshot 2023-05-04 at 1 07 49 PM

EDIT:
I am only getting these errors inside the container and not when running on my laptop
After running for sometime i also got the same error in my laptop as well ( python 3.9 , M1 MacOS )

@EricKolibacz
Copy link

EricKolibacz commented Sep 13, 2023

Had the same problem:

All Job's above 60 seconds failed in a watch coroutine

async with kubernetes_asyncio.watch.Watch() as w:
    async for event in w.stream(...)
        ...

with Response payload is not completed

Our setup: kubernetes v1.23.0 with an additional ha-proxy.

I found this issue in the aiohttp GitHub repo. One of the answers made me believe that we are facing the same issue with our kubernetes setup. The ha-proxy has its own timeout set (for us at 50 seconds). So all our jobs taking more than 50 seconds receive the error. (this is due to the fact that the proxy kills all requests which do not send any data for some time and since the watch coroutine can idle if no pod event is happening the proxy closes the connection).

Fixed it by using a while loop and periodically requesting the status of the pod. Not as elegant as using watch but it fixed the issue 🎉.

Alternatively, you probably could increase the timeout of the proxy (in the case for the ha proxy, configure it in the /etc/haproxy/haproxy.cfg file).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants