ERROR:root:load cache error: __init__() got an unexpected keyword argument 'base_resource_lookup'
redespace opened this issue · 12 comments
When running the python script, I get this error in console. The application still works, but no idea how to hide/ignore this error.
Thank you
My code:
from getpass import getpass
import os
from kubernetes import client
from openshift.dynamic import DynamicClient
from openshift.helper.userpassauth import OCPLoginConfiguration
apihost = 'https://xxx.com'
username = os.getenv('OCPUSERNAME') if os.getenv('OCPUSERNAME') else input('OCP Username: ')
password = os.getenv('OCPPASSWORD') if os.getenv('OCPPASSWORD') else getpass(prompt='OCP Password: ')
secret_name = input('Enter the secret name you wish to update: ')
kubeConfig = OCPLoginConfiguration(ocp_username=username, ocp_password=password)
kubeConfig.host = apihost
kubeConfig.verify_ssl = False
# Retrieve the auth token
kubeConfig.get_token()
k8s_client = client.ApiClient(kubeConfig)
dyn_client = DynamicClient(k8s_client)
v1_secrets = dyn_client.resources.get(api_version='v1', kind='SecretList')
secret = v1_secrets.get(namespace='xxx', name=secret_name)
I have the same issue:
root: load cache error: ResourceList.__init__() got an unexpected keyword argument 'base_resource_lookup'
My setup:
❯ python --version
Python 3.10.0
❯ pip freeze
attrs==21.4.0
cachetools==5.1.0
certifi==2022.5.18.1
charset-normalizer==2.0.12
contextlib2==21.6.0
cx-Oracle==8.3.0
google-auth==2.6.6
idna==3.3
jsonschema==4.5.1
kubernetes==23.3.0
oauthlib==3.2.0
openshift==0.13.1
pyasn1==0.4.8
pyasn1-modules==0.2.8
pyrsistent==0.18.1
python-dateutil==2.8.2
python-string-utils==1.0.0
PyYAML==6.0
requests==2.27.1
requests-oauthlib==1.3.1
rsa==4.8
schema==0.7.5
six==1.16.0
urllib3==1.26.9
websocket-client==1.3.2
Adding on to this with the same issue
ERROR:root:load cache error: __init__() got an unexpected keyword argument 'base_resource_lookup'
(venv) $ python --version
Python 3.8.10
(venv) $ pip freeze
altgraph==0.17.2
atlassian-python-api==3.25.0
cachetools==5.2.0
certifi==2022.5.18.1
charset-normalizer==2.0.12
Deprecated==1.2.13
gitdb==4.0.9
GitPython==3.1.27
google-auth==2.7.0
hvac==0.11.2
idna==3.3
Jinja2==3.1.2
kubernetes==23.6.0
MarkupSafe==2.1.1
oauthlib==3.2.0
openshift==0.13.1
pyasn1==0.4.8
pyasn1-modules==0.2.8
pyinstaller==5.1
pyinstaller-hooks-contrib==2022.6
python-dateutil==2.8.2
python-dotenv==0.20.0
python-string-utils==1.0.0
PyYAML==6.0
requests==2.27.1
requests-oauthlib==1.3.1
rsa==4.8
six==1.16.0
smmap==5.0.0
urllib3==1.26.9
websocket-client==1.3.2
wrapt==1.14.1
No exceptions are thrown except this one error message. The script still works, but it would be preferable to not have any unexplained errors appear.
Same issue here:
sh-5.1$ python --version
Python 3.8.13
sh-5.1$ pip freeze
cachetools==5.0.0
certifi==2021.10.8
charset-normalizer==2.0.12
gevent==21.12.0
google-auth==2.6.6
greenlet==1.1.2
grequests==0.6.0
idna==3.3
kubernetes==23.6.0
oauthlib==3.2.0
openshift==0.13.1
pyasn1==0.4.8
pyasn1-modules==0.2.8
python-dateutil==2.8.2
python-string-utils==1.0.0
PyYAML==6.0
requests==2.27.1
requests-oauthlib==1.3.1
Same here,
the code call CacheDecoder
from Kubernetes module that call
kubernetes/dynamic/discovery.py
elif _type == 'ResourceList':
return ResourceList(self.client, **obj)
and Kubernetes ResourceList
class do not accept base_resource_lookup
kubernetes/dynamic/resource.py
def __init__(self, client, group='', api_version='v1', base_kind='', kind=None):
self.client = client
self.group = group
self.api_version = api_version
self.kind = kind or '{}List'.format(base_kind)
self.base_kind = base_kind
self.__base_resource = None
def base_resource(self):
if self.__base_resource:
return self.__base_resource
elif self.base_kind:
self.__base_resource = self.client.resources.get(group=self.group, api_version=self.api_version, kind=self.base_kind)
return self.__base_resource
return None
openshift-restclient-python can handle base_resource_lookup
in ResourceList
class.
class ResourceList(Resource):
""" Represents a list of API objects """
def __init__(self, client, group='', api_version='v1', base_kind='', kind=None, base_resource_lookup=None):
self.client = client
self.group = group
self.api_version = api_version
self.kind = kind or '{}List'.format(base_kind)
self.base_kind = base_kind
self.base_resource_lookup = base_resource_lookup
self.__base_resource = None
def base_resource(self):
if self.__base_resource:
return self.__base_resource
elif self.base_resource_lookup:
self.__base_resource = self.client.resources.get(**self.base_resource_lookup)
return self.__base_resource
return None
PR to kubernetes-client was submitted by @akalenyu kubernetes-client/python#1858
I am running into this issue also. Beside that when the issue occurs it seems that the root logger is instantiated, which causes everything to be logged twice. As a quick and dirty workaround I instantiated and configured the root logger to write everything to /dev/null:
logging.basicConfig(filename='/dev/null', filemode='w', format='%(name)s - %(levelname)s - %(message)s')
Issues go stale after 90d of inactivity.
Mark the issue as fresh by commenting /remove-lifecycle stale
.
Stale issues rot after an additional 30d of inactivity and eventually close.
Exclude this issue from closing by commenting /lifecycle frozen
.
If this issue is safe to close now please do so with /close
.
/lifecycle stale
/remove-lifecycle stale
kubernetes-client/python#1858 should handle this
Issues go stale after 90d of inactivity.
Mark the issue as fresh by commenting /remove-lifecycle stale
.
Stale issues rot after an additional 30d of inactivity and eventually close.
Exclude this issue from closing by commenting /lifecycle frozen
.
If this issue is safe to close now please do so with /close
.
/lifecycle stale
Stale issues rot after 30d of inactivity.
Mark the issue as fresh by commenting /remove-lifecycle rotten
.
Rotten issues close after an additional 30d of inactivity.
Exclude this issue from closing by commenting /lifecycle frozen
.
If this issue is safe to close now please do so with /close
.
/lifecycle rotten
/remove-lifecycle stale
Rotten issues close after 30d of inactivity.
Reopen the issue by commenting /reopen
.
Mark the issue as fresh by commenting /remove-lifecycle rotten
.
Exclude this issue from closing again by commenting /lifecycle frozen
.
/close
@openshift-bot: Closing this issue.
In response to this:
Rotten issues close after 30d of inactivity.
Reopen the issue by commenting
/reopen
.
Mark the issue as fresh by commenting/remove-lifecycle rotten
.
Exclude this issue from closing again by commenting/lifecycle frozen
./close
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.