Skip to content

Using usedforsecurity in dynamic/discovery.py makes kubernetes-client work only in python >= 3.9 #1944

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

Closed
m-wcislo opened this issue Nov 4, 2022 · 3 comments · Fixed by #1955
Assignees
Labels
kind/bug Categorizes issue or PR as related to a bug.

Comments

@m-wcislo
Copy link

m-wcislo commented Nov 4, 2022

What happened (please include outputs or screenshots):
As discovered in devopsspiral/KubeLibrary#118 latest changes to the dynamic/discovery.py depend on python3.9 where usedforsecurity was introduced:

[ ERROR ] Error in file '/opt/robotframework/tests/k8s/smoke.robot' on line 3: Initializing library 'KubeLibrary' with arguments [ incluster=True ] failed: TypeError: openssl_md5() takes at most 1 argument (2 given)
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/KubeLibrary/KubeLibrary.py", line 96, in __init__
    self.reload_config(kube_config=kube_config, context=context, api_url=api_url, bearer_token=bearer_token,
  File "/usr/local/lib/python3.8/site-packages/KubeLibrary/KubeLibrary.py", line 267, in reload_config
    self._add_api('dynamic', DynamicClient)
  File "/usr/local/lib/python3.8/site-packages/KubeLibrary/KubeLibrary.py", line 270, in _add_api
    self.__dict__[reference] = class_name(self.api_client)
  File "/usr/local/lib/python3.8/site-packages/kubernetes/dynamic/client.py", line 84, in __init__
    self.__discoverer = discoverer(self, cache_file)
  File "/usr/local/lib/python3.8/site-packages/kubernetes/dynamic/discovery.py", line 224, in __init__
    Discoverer.__init__(self, client, cache_file)
  File "/usr/local/lib/python3.8/site-packages/kubernetes/dynamic/discovery.py", line 48, in __init__
    default_cachefile_name = 'osrcp-{0}.json'.format(hashlib.md5(default_cache_id, usedforsecurity=False).hexdigest())
TypeError: openssl_md5() takes at most 1 argument (2 given)

What you expected to happen:
Support for python>=3.7 (still in life)

Environment:

  • Python version (python --version)
    Python 3.8
  • Python client version (pip list | grep kubernetes)
    kubernetes-25.3.0 vs kubernetes-24.2.0
@m-wcislo m-wcislo added the kind/bug Categorizes issue or PR as related to a bug. label Nov 4, 2022
@yliaog
Copy link
Contributor

yliaog commented Nov 7, 2022

/assign @fabianvf could you please take a look?

@yliaog
Copy link
Contributor

yliaog commented Nov 7, 2022

/assign @fabianvf

@FernandezMathieu
Copy link

We're facing the same issue here, please anybody can fix ?

fabianvf added a commit to fabianvf/python that referenced this issue Nov 22, 2022
Fixes kubernetes-client#1944

This was only added in Python 3.9, will fall back to the old behavior if
`usedforsecurity` is not available.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants