diff --git a/src/nublado2/resourcemgr.py b/src/nublado2/resourcemgr.py index c21a001..e9afcb7 100644 --- a/src/nublado2/resourcemgr.py +++ b/src/nublado2/resourcemgr.py @@ -111,10 +111,6 @@ async def _create_lab_environment_configmap( async def _create_kubernetes_resources( self, spawner: KubeSpawner, options: SelectedOptions ) -> None: - api_client = shared_client("ApiClient") - # This works around an infelicity in upstream Kubespawner's - # shared client implementation - api_client.api_client = api_client custom_api = shared_client("CustomObjectsApi") template_values = await self._build_template_values(spawner, options) @@ -154,7 +150,7 @@ async def _create_kubernetes_resources( ) else: await asyncio.wait_for( - create_from_dict(api_client, resource), + create_from_dict(spawner.api.api_client, resource), spawner.k8s_api_request_timeout, ) @@ -185,10 +181,6 @@ async def _create_kubernetes_resources( async def _build_dask_template(self, spawner: KubeSpawner) -> str: """Build a template for dask workers from the jupyter pod manifest.""" - api_client = shared_client("ApiClient") - # This works around an infelicity in upstream Kubespawner's - # shared client implementation - api_client.api_client = api_client dask_template = await spawner.get_pod_manifest() # Here we make a few mangles to the jupyter pod manifest @@ -210,7 +202,7 @@ async def _build_dask_template(self, spawner: KubeSpawner) -> str: # alone doesn't. dask_yaml_stream = StringIO() self.yaml.dump( - api_client.sanitize_for_serialization(dask_template), + spawner.api.api_client.sanitize_for_serialization(dask_template), dask_yaml_stream, ) return dask_yaml_stream.getvalue() diff --git a/tests/resourcemgr_test.py b/tests/resourcemgr_test.py index ae217ec..e2c0d47 100644 --- a/tests/resourcemgr_test.py +++ b/tests/resourcemgr_test.py @@ -147,6 +147,7 @@ async def test_create_kubernetes_resources( spawner.hub.base_url = "/nb/hub/" spawner.user = Mock(spec=User) spawner.user.name = "someuser" + spawner.api = kubernetes_api_mock auth_state = { "token": "user-token", "uid": 1234,