Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"No such file or directory: 'C'" in version 0.14.2 and above #365

Closed
dhorkel opened this issue Apr 29, 2024 · 2 comments · Fixed by #367
Closed

"No such file or directory: 'C'" in version 0.14.2 and above #365

dhorkel opened this issue Apr 29, 2024 · 2 comments · Fixed by #367
Labels
auth Authenticating with Kubernetes bug Something isn't working

Comments

@dhorkel
Copy link

dhorkel commented Apr 29, 2024

Which project are you reporting a bug for?

kr8s

What happened?

Nearly every function raises the following error when using version 0.14.2 and above. Does not happen with version 0.14.1:

>>> kr8s.get("pods")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\dhorkel\code\python_scratch\.venv\Lib\site-packages\kr8s\__init__.py", line 93, in get
    return _run_sync(partial(_get, _asyncio=False))(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\dhorkel\code\python_scratch\.venv\Lib\site-packages\kr8s\_io.py", line 75, in wrapped
    return portal.call(wrapped)
           ^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\dhorkel\code\python_scratch\.venv\Lib\site-packages\kr8s\_io.py", line 50, in call
    return self._portal.call(func, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\dhorkel\code\python_scratch\.venv\Lib\site-packages\anyio\from_thread.py", line 288, in call
    return cast(T_Retval, self.start_task_soon(func, *args).result())
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\dhorkel\AppData\Local\Programs\Python\Python311\Lib\concurrent\futures\_base.py", line 456, in result
    return self.__get_result()
           ^^^^^^^^^^^^^^^^^^^
  File "C:\Users\dhorkel\AppData\Local\Programs\Python\Python311\Lib\concurrent\futures\_base.py", line 401, in __get_result
    raise self._exception
  File "C:\Users\dhorkel\code\python_scratch\.venv\Lib\site-packages\anyio\from_thread.py", line 217, in _call_func
    retval = await retval_or_awaitable
             ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\dhorkel\code\python_scratch\.venv\Lib\site-packages\kr8s\asyncio\_helpers.py", line 64, in get
    api = await _api(_asyncio=_asyncio)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\dhorkel\code\python_scratch\.venv\Lib\site-packages\kr8s\asyncio\_api.py", line 76, in api
    return await _f(
           ^^^^^^^^^
  File "C:\Users\dhorkel\code\python_scratch\.venv\Lib\site-packages\kr8s\asyncio\_api.py", line 74, in _f
    return await _cls(**kwargs, bypass_factory=True)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\dhorkel\code\python_scratch\.venv\Lib\site-packages\kr8s\_api.py", line 71, in f
    await self.auth
    await self.reauthenticate()
  File "C:\Users\dhorkel\code\python_scratch\.venv\Lib\site-packages\kr8s\_auth.py", line 64, in reauthenticate
    await self._load_kubeconfig()
  File "C:\Users\dhorkel\code\python_scratch\.venv\Lib\site-packages\kr8s\_auth.py", line 97, in _load_kubeconfig
    self.kubeconfig = await KubeConfigSet(*self._kubeconfig_path.split(":"))
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\dhorkel\code\python_scratch\.venv\Lib\site-packages\kr8s\_config.py", line 27, in f
    await config
  File "C:\Users\dhorkel\code\python_scratch\.venv\Lib\site-packages\kr8s\_config.py", line 170, in f
    async with await anyio.open_file(self.path) as fh:
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\dhorkel\code\python_scratch\.venv\Lib\site-packages\anyio\_core\_fileio.py", line 185, in open_file
    fp = await to_thread.run_sync(
         ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\dhorkel\code\python_scratch\.venv\Lib\site-packages\anyio\to_thread.py", line 56, in run_sync
    return await get_async_backend().run_sync_in_worker_thread(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\dhorkel\code\python_scratch\.venv\Lib\site-packages\anyio\_backends\_asyncio.py", line 2134, in run_sync_in_worker_thread
    return await future
           ^^^^^^^^^^^^
  File "C:\Users\dhorkel\code\python_scratch\.venv\Lib\site-packages\anyio\_backends\_asyncio.py", line 851, in run
    result = context.run(func, *args)
             ^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: 'C'

Anything else?

I am using python 3.11.7 on Windows 11. Running kubectl version I get:

Client Version: v1.29.1
Kustomize Version: v5.0.4-0.20230601165947-6ce0bf390ce3
Server Version: v1.29.1-eks-b9c9ed7
@dhorkel dhorkel added the bug Something isn't working label Apr 29, 2024
@dhorkel
Copy link
Author

dhorkel commented Apr 29, 2024

Looking at it a little closer I think:

  File "C:\Users\dhorkel\code\python_scratch\.venv\Lib\site-packages\kr8s\_auth.py", line 97, in _load_kubeconfig
    self.kubeconfig = await KubeConfigSet(*self._kubeconfig_path.split(":"))

is splitting the windows filepath at the drive name

@jacobtomlinson jacobtomlinson added the auth Authenticating with Kubernetes label Apr 30, 2024
@jacobtomlinson
Copy link
Member

Thanks for raising this! I think you're right that the bug was introduced when the multi-path support was added.

In kr8s we don't officially support Windows, we could but that's a separate conversation. However this looks like a quick fix so I'll open a PR to disable multiple config support on Windows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auth Authenticating with Kubernetes bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants