Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Incompatibility issue with nsenter python library #471

Closed
@huang195

Description

@huang195

I have a piece of code that makes use of both the kubernetes python client and nsenter. This code used to work when the kubernetes python client was at version 3. However, starting at version 4, it no longer works, and I was getting the following error from nsenter:

  File "/usr/local/lib/python2.7/dist-packages/nsenter/__init__.py", line 109, in __enter__
    raise OSError(e, errno.errorcode[e])
OSError: [Errno 22] EINVAL

After a bit of digging, it seems the problem is due to setns (what nsenter eventually calls) does not allow the caller (my program) to be multi-threaded (see here: http://man7.org/linux/man-pages/man2/setns.2.html). Coincidentally, starting in version 4 of the kubernetes python client code, multiprocessing.pool was introduced to handle asynchronous requests (see here: https://github.com/kubernetes-client/python/blob/release-4.0/kubernetes/client/api_client.py#L19). I was able to confirm this is the culprit - after disabling the use of multiprocessing.pool (luckily, its use was completely confined to api_client.py, and changing only a few lines of code sufficed), my code worked the same way as v3 of kubernetes python client.

My question is if it is possible to add a constructor flag to enable/disable the use of multiprocessing.pool for handling async requests. It seems like a small change that I can take a stab at it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    lifecycle/rottenDenotes an issue or PR that has aged beyond stale and will be auto-closed.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions