kubeclient icon indicating copy to clipboard operation
kubeclient copied to clipboard

Document if kubeclient / restclient is threadsafe or not

Open grosser opened this issue 6 years ago • 4 comments

Would be nice to have a "Not threadsafe, use one kubeclient per Thread" or the opposite in the docs somewhere.

grosser avatar Sep 09 '19 15:09 grosser

I suspect it is but don't know for sure.

  • is rest-client thread-safe?
  • is http gem thread-safe?
  • I think the only Client mutation during use is lazy discovery. Is it safe?
  • is Config thread-safe?

cben avatar Sep 09 '19 16:09 cben

yeah, client mutation is not threadsafe, I already run into that one :D

grosser avatar Sep 09 '19 16:09 grosser

I think we want it to become thread-safe. That's the only sane contract for a high-level library...

Do you know details on problems you saw? Should discovery take a mutex, or would that risk one slow request blocking everything? Should we let multiple parallel discovery requests to "race", but make sure the results are "committed atomically"? (I'd rather not, premature buggization...)

cben avatar Dec 16 '19 10:12 cben

having an instance-mutex around discoveries should be cheap and make it threadsafe alternative would be to initialize it with 'threadsafe: true' and then just eager-discover

grosser avatar Dec 20 '19 03:12 grosser