Open fbaier-fn opened 2 years ago
Thank you for opening your first issue in this project! Engagement like this is essential for open source projects! :hugs:
If you haven't done so already, check out Jupyter's Code of Conduct. Also, please try to follow the issue template as it helps other other community members to contribute more effectively.
You can meet the other Jovyans by joining our Discourse forum. There is also an intro thread there where you can stop by and say Hi! :wave:
Welcome to the Jupyter community! :tada:
+1
This just broke all our tests when upgrading.
Bug description
The mock mode comes in very handy for a variety of tests and used to be easily enabled by setting
_mock
toTrue
. This behavior broke and we see a lot of errors suddenly in our tests relating the kubeconfig such as:Something about mock test behavior changed from
2.0.1
to3.0.0
so that we see the issues withkubernetes_asyncio
not able to find the kube-config file. After looking further into this I think this roots in the change that in2.0.1
we were not loading the config if in mock mode versus starting with3.0.0
we do.Particular https://github.com/jupyterhub/kubespawner/blob/main/kubespawner/spawner.py#L195-L200 should just happen when we are not in mock mode - but there it happens regardless. Can we move this in a
if not _mock:
block. Wdyt?Relating PRs jupyterhub/kubespawner#563 jupyterhub/kubespawner#576
Expected behaviour
Kubespawner in mock mode should not try to load kube-config file.
Actual behaviour
Even in mock mode the config is attempted to be loaded and fails, breaking mock tests. I think this just hasn't been noted because tests we run here are done after we do set up k3s that does create a kube-config file with the proper context vs. in mocks we don't actually bring up a k3s cluster nor should we rely on that step run as a dependency imo.
How to reproduce
Try to run mocks without k3s being setup, particular https://github.com/jupyterhub/kubespawner/blob/main/.github/workflows/test.yaml#L77 with https://github.com/jupyterhub/action-k3s-helm/blob/main/action.yml#L118-L126