-
Notifications
You must be signed in to change notification settings - Fork 303
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
Avoid emitting warnings/errors during normal operation #578
Comments
I dug into this a little bit, and it's because we allow our shared clients to be garbage collected by using weakrefs. If we held onto our shared_client objects and cleaned them up atexit instead, the warning appears to go away. It doesn't raise errors (for us or by default). The loop's exception handler is the (overrideable) callback for unhandled errors in asyncio that don't have a coroutine/future to attach errors to. It can be used to halt the loop if you want all errors to be fatal for some reason, but the default and most common behavior is to log and move on, which I think is why it's used here. The feature that's really missing is an "atexit, but for asyncio" which is called when the event loop is closed. This doesn't exist, and there's no reliable way to register things (especially coroutines) to call at shutdown of asyncio while the eventloop still exists. |
Wieeeee I'm excited that you have a quite clear idea about the situation, I don't yet get it though!
Hmm...
Hmmmmmm...
|
I share @consideRatio's concerns about patching Is it possible to come up with a test case we can add to https://github.com/jupyterhub/kubespawner/tree/main/tests so it's easy to reproduce? |
#579 includes tests, but it patches asyncio instead of aiohttp! It patches it to do something good instead of skipping cleanup, though. |
#579 seems like a good thing. I'll withdraw the monkeypatch from the z2jh PR (jupyterhub/zero-to-jupyterhub-k8s#2594) and adopt #579 with a release that incorporates it. |
Background
@athornton reports there are warnings/errors shown when using KubeSpawner that clutters logs. This issue is meant to help us dig into the details about that. My goal is to resolve it in a way within KubeSpawner that doesn't make us: risk suppressing a relevant warning/error, confuse an end user with irrelevant warnings/errors, maintain a fragile patch making changes to
aiohttp
.Technical details
We have switched the library we use to communicate with the k8s api-server to using
kubernetes_asyncio
fromkubernetes
. Whenkubernetes_asyncio
makes web requests, it uses aiohttp.kubespawner
useCoreV1Api
etc fromkubernetes_asycio
, via the getter functionshared_client
.RESTClientObject
fromaiohttp
ClientSession
instance fromaiohttp
.__del__
destructor that emits warnings and that raises errors (unsure about this).Open questions about the warnings/errors
Open technical questions
aiohttp
Related
aiohttp
provided by @athornton in Avoid emitting warnings/errors during normal operation #578.kubernetes_asyncio
instead ofkubernetes
and dedicated threads #563The text was updated successfully, but these errors were encountered: