Zach Marinov
11/22/2024, 4:38 PM195, in stream
raise client.rest.ApiException(
kubernetes.client.exceptions.ApiException: (410)
Reason: Expired: too old resource version: 1837988160 (1838538580)
Marvin
11/22/2024, 4:38 PM410 Expired
error when using Kubernetes with Prefect, which is related to a resource version being too old. This error typically occurs when the client-side watch mechanism loses sync with the Kubernetes API server, often due to long-running connections.
To resolve this issue, consider the following options:
1. Increase the Resync Period: You might be able to modify the resync period of the Kubernetes informer to prevent watches from timing out.
2. Automatically Handle Restarts: Implement logic to handle the reconnection automatically in your Kubernetes client or Prefect task. This can involve catching this specific exception and re-establishing the connection.
3. Check Network Policies: Ensure there are no network policies causing timeouts.
4. Prefect Version Settings: Depending upon your Prefect version, there might be configurations available. However, I couldn't find specific guidance in the Prefect documentation without exact queries.
If you could confirm your Prefect version (e.g., 2.x or 3.x), I'll be happy to dive deeper into the respective documentation for any potential settings or recommended practices!
Networking issues can sometimes be as pesky as Marvin having a bad day. 😏Nate
11/22/2024, 4:42 PMprefect-kubernetes
do you have?Zach Marinov
11/22/2024, 4:43 PMZach Marinov
11/22/2024, 4:43 PMNate
11/22/2024, 4:44 PMZach Marinov
11/22/2024, 4:46 PMZach Marinov
11/22/2024, 4:49 PMNate
11/22/2024, 4:51 PMZach Marinov
11/22/2024, 4:52 PMFile "/usr/local/lib/python3.11/site-packages/anyio/_backends/_asyncio.py", line 807, in run
result = context.run(func, *args)
^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/prefect_kubernetes/worker.py", line 1031, in _watch_job
for event in self._job_events(
File "/usr/local/lib/python3.11/site-packages/kubernetes/watch/watch.py", line 195, in stream
raise client.rest.ApiException(
kubernetes.client.exceptions.ApiException: (410)
Reason: Expired: too old resource version: 1837988160 (1838538580)
Nate
11/22/2024, 4:54 PMZach Marinov
11/22/2024, 4:55 PMKevin Grismore
11/22/2024, 4:56 PMKevin Grismore
11/22/2024, 4:57 PMZach Marinov
11/22/2024, 5:02 PMZach Marinov
11/22/2024, 5:04 PMZach Marinov
11/22/2024, 5:04 PM>>> from kubernetes_asyncio.client.exceptions import ApiException
>>> from kubernetes_asyncio.client.exceptions import ApiException as exception_asyncio
>>> from kubernetes.client.exceptions import ApiException as exception_sync
>>> exception_sync == exception_asyncio
False
>>> def foobar():
... raise exception_sync("test")
...
>>> foobar()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 2, in foobar
kubernetes.client.exceptions.ApiException: (test)
Reason: None
>>> try:
... foobar()
... except exception_asyncio:
... print('caught')
...
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
File "<stdin>", line 2, in foobar
kubernetes.client.exceptions.ApiException: (test)
Reason: None
>>> try:
... foobar()
... except exception_sync:
... print('caught')
...
caught
>>>
Nate
11/22/2024, 5:04 PMNate
11/22/2024, 5:04 PMKevin Grismore
11/22/2024, 5:05 PMZach Marinov
11/22/2024, 5:05 PMZach Marinov
11/22/2024, 5:05 PMZach Marinov
11/22/2024, 5:05 PMZach Marinov
11/22/2024, 5:06 PMZach Marinov
11/22/2024, 5:06 PMZach Marinov
11/22/2024, 5:55 PMNate
11/22/2024, 5:56 PMKevin Grismore
11/22/2024, 6:38 PMskrawczyk
01/03/2025, 5:55 PM2.19.3
workerskrawczyk
01/03/2025, 5:55 PMAn error occurred while monitoring flow run '5247ca1b-db07-45d6-b86b-3735746e5848'. The flow run will not be marked as failed, but an issue may have occurred.
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/prefect/workers/base.py", line 908, in _submit_run_and_capture_errors
result = await self.run(
File "/usr/local/lib/python3.10/site-packages/prefect_kubernetes/worker.py", line 602, in run
status_code = await run_sync_in_worker_thread(
File "/usr/local/lib/python3.10/site-packages/prefect/utilities/asyncutils.py", line 136, in run_sync_in_worker_thread
return await anyio.to_thread.run_sync(
File "/usr/local/lib/python3.10/site-packages/anyio/to_thread.py", line 33, in run_sync
return await get_asynclib().run_sync_in_worker_thread(
File "/usr/local/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 877, in run_sync_in_worker_thread
return await future
File "/usr/local/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 807, in run
result = context.run(func, *args)
File "/usr/local/lib/python3.10/site-packages/prefect_kubernetes/worker.py", line 1031, in _watch_job
for event in self._job_events(
File "/usr/local/lib/python3.10/site-packages/kubernetes/watch/watch.py", line 195, in stream
raise client.rest.ApiException(
kubernetes.client.exceptions.ApiException: (410)
Reason: Expired: too old resource version: 1651317987 (1651835806)
skrawczyk
01/03/2025, 5:55 PMDennis L
01/26/2025, 11:35 PMskrawczyk
01/30/2025, 1:29 AMthe prefect-kubernetes 0.4.6 package should have all of the current bug fixes and should be available on any image running prefect 2.20.11 or later, i.e. 2.20.11-pyhton3.10-kubernetes