kelproject / pykube

Python client library for Kubernetes
Apache License 2.0
349 stars 183 forks source link

ObjectManager, providing resource.objects(), is not thread-safe #138

Open miracle2k opened 7 years ago

miracle2k commented 7 years ago

The code in question is here:

https://github.com/kelproject/pykube/blob/e8a46298a592ad9037587afb707ac75b3114eff9/pykube/objects.py#L14-L23

The problem is that the code is expecting __get__ and __call__ to be executed in order. In https://github.com/miracle2k/k8s-snapshots we inadvertently ended up with a situation where that is not the case. Because we are watching two resources, in two separate threads, what happens during setup is that the methods are called in this order:

In case it helps, a minimal example to reproduce this (Python 3.6) is here:

https://github.com/miracle2k/k8s-snapshots/tree/pykube-bug