-
Notifications
You must be signed in to change notification settings - Fork 921
Fixed semaphore leak in kubernetes client #7678
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
Conversation
Signed-off-by: Aylei <rayingecho@gmail.com>
Signed-off-by: Aylei <rayingecho@gmail.com>
|
/quicktest-core |
cblmemo
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for identifying and fixing this @aylei ! LGTM.
sky/adaptors/kubernetes.py
Outdated
| real_client = self._client | ||
| elif isinstance(self._client, kubernetes.watch.Watch): | ||
| # For watcher, stop the watch before cleanup. | ||
| kubernetes.watch.Watch().stop() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we call this on the self._client? It's surprising to me that this works when we call it on a newly instantiated Watch object. Why is that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, after looking at the kubernetes client code, I'm pretty sure this line does nothing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we may need to do something to make sure that the Watch.stream iterator cleans up its connection, but I guess that doing that here doesn't make much sense. The way .stop() works, it seems like it will not actually take effect until we call next() on the iterator and it actually terminates (StopIteration)
sky/adaptors/kubernetes.py
Outdated
| if isinstance(obj, ClientWrapper): | ||
| return obj |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How would this happen? I feel like we should either ignore this case or throw an exception.
sky/adaptors/kubernetes.py
Outdated
| """Delegate to the underlying client""" | ||
| return getattr(self._client, name) | ||
|
|
||
| def __del__(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would love to try and find a way to avoid relying on __del__ for this - I think it's better than the current state, but if we can manage the lifecycle more explicitly that seems good. E.g. some alternative to the lru_cache that will call close or __exit__
|
I pushed some changes to the PR. @cblmemo could you take another look? |
|
/quicktest-core |
close #7638
Tested (run the relevant ones):
bash format.sh/smoke-test(CI) orpytest tests/test_smoke.py(local)/smoke-test -k test_name(CI) orpytest tests/test_smoke.py::test_name(local)/quicktest-core(CI) orpytest tests/smoke_tests/test_backward_compat.py(local)