diff --git a/kubespawner/spawner.py b/kubespawner/spawner.py index e2f099ad..3d34ed38 100644 --- a/kubespawner/spawner.py +++ b/kubespawner/spawner.py @@ -2185,10 +2185,6 @@ async def poll(self): just Falsy, to determine that the pod is still running. """ - reflector = await self._start_watching_pods() - if not reflector.first_load_future.done(): - await reflector.first_load_future - ref_key = f"{self.namespace}/{self.pod_name}" pod = self.pod_reflector.pods.get(ref_key, None) if pod is not None: @@ -2358,6 +2354,10 @@ async def _start_reflector( if previous_reflector and not replace: # fast path + if not previous_reflector.first_load_future.done(): + # make sure it's loaded, so subsequent calls to start_reflector + # don't finish before the first + await previous_reflector.first_load_future return previous_reflector if self.enable_user_namespaces: @@ -2406,6 +2406,9 @@ async def catch_reflector_start(func): # we replaced the reflector, stop the old one asyncio.ensure_future(previous_reflector.stop()) + # wait for first load + await current_reflector.first_load_future + # return the current reflector return current_reflector