vapor-ware / kubetest

Kubernetes integration testing in Python via pytest
https://kubetest.readthedocs.io/en/latest/
GNU General Public License v3.0
207 stars 56 forks source link

Fails with missing AppsV1beta1Api attribute when using new kubernetes python client #217

Open mmslkr opened 3 years ago

mmslkr commented 3 years ago

kubetest fails with AttributeError: module 'kubernetes.client' has no attribute 'AppsV1beta1Api' while using kubernetes client beginning with 18.17.0a1 when APIs got removed (see https://github.com/kubernetes-client/python/blob/release-18.0/CHANGELOG.md#v18170a1)

The following deprecated APIs can no longer be served: All resources under apps/v1beta1 and apps/v1beta2 - use apps/v1 instead daemonsets, deployments, replicasets resources under extensions/v1beta1 - use apps/v1 instead networkpolicies resources under extensions/v1beta1 - use networking.k8s.io/v1 instead podsecuritypolicies resources under extensions/v1beta1 - use policy/v1beta1 instead (#85903, @liggitt) [SIG API Machinery, Apps, Cluster Lifecycle, Instrumentation and Testing]

Steps to reproduce:

python3 -m virtualenv venv_kubetest_issue
source venv_kubetest_issue/bin/activate
pip install kubernetes==18.17.0a1
pip install kubetest
$ pip list | grep kube
kubernetes         18.17.0a1
kubetest           0.9.5
$ pytest
Traceback (most recent call last):
  File "/home/lkr/venv_kubetest_issue/bin/pytest", line 8, in <module>
    sys.exit(console_main())
  File "/home/lkr/venv_kubetest_issue/lib/python3.8/site-packages/_pytest/config/__init__.py", line 185, in console_main
    code = main()
  File "/home/lkr/venv_kubetest_issue/lib/python3.8/site-packages/_pytest/config/__init__.py", line 143, in main
    config = _prepareconfig(args, plugins)
  File "/home/lkr/venv_kubetest_issue/lib/python3.8/site-packages/_pytest/config/__init__.py", line 318, in _prepareconfig
    config = pluginmanager.hook.pytest_cmdline_parse(
  File "/home/lkr/venv_kubetest_issue/lib/python3.8/site-packages/pluggy/hooks.py", line 286, in __call__
    return self._hookexec(self, self.get_hookimpls(), kwargs)
  File "/home/lkr/venv_kubetest_issue/lib/python3.8/site-packages/pluggy/manager.py", line 93, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "/home/lkr/venv_kubetest_issue/lib/python3.8/site-packages/pluggy/manager.py", line 84, in <lambda>
    self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
  File "/home/lkr/venv_kubetest_issue/lib/python3.8/site-packages/pluggy/callers.py", line 203, in _multicall
    gen.send(outcome)
  File "/home/lkr/venv_kubetest_issue/lib/python3.8/site-packages/_pytest/helpconfig.py", line 100, in pytest_cmdline_parse
    config: Config = outcome.get_result()
  File "/home/lkr/venv_kubetest_issue/lib/python3.8/site-packages/pluggy/callers.py", line 80, in get_result
    raise ex[1].with_traceback(ex[2])
  File "/home/lkr/venv_kubetest_issue/lib/python3.8/site-packages/pluggy/callers.py", line 187, in _multicall
    res = hook_impl.function(*args)
  File "/home/lkr/venv_kubetest_issue/lib/python3.8/site-packages/_pytest/config/__init__.py", line 1003, in pytest_cmdline_parse
    self.parse(args)
  File "/home/lkr/venv_kubetest_issue/lib/python3.8/site-packages/_pytest/config/__init__.py", line 1283, in parse
    self._preparse(args, addopts=addopts)
  File "/home/lkr/venv_kubetest_issue/lib/python3.8/site-packages/_pytest/config/__init__.py", line 1172, in _preparse
    self.pluginmanager.load_setuptools_entrypoints("pytest11")
  File "/home/lkr/venv_kubetest_issue/lib/python3.8/site-packages/pluggy/manager.py", line 299, in load_setuptools_entrypoints
    plugin = ep.load()
  File "/usr/lib/python3.8/importlib/metadata.py", line 77, in load
    module = import_module(match.group('module'))
  File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "/home/lkr/venv_kubetest_issue/lib/python3.8/site-packages/_pytest/assertion/rewrite.py", line 170, in exec_module
    exec(co, module.__dict__)
  File "/home/lkr/venv_kubetest_issue/lib/python3.8/site-packages/kubetest/plugin.py", line 17, in <module>
    from kubetest import errors, markers
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "/home/lkr/venv_kubetest_issue/lib/python3.8/site-packages/_pytest/assertion/rewrite.py", line 170, in exec_module
    exec(co, module.__dict__)
  File "/home/lkr/venv_kubetest_issue/lib/python3.8/site-packages/kubetest/markers.py", line 9, in <module>
    from kubetest import manager
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "/home/lkr/venv_kubetest_issue/lib/python3.8/site-packages/_pytest/assertion/rewrite.py", line 170, in exec_module
    exec(co, module.__dict__)
  File "/home/lkr/venv_kubetest_issue/lib/python3.8/site-packages/kubetest/manager.py", line 8, in <module>
    from kubetest import client, objects, utils
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "/home/lkr/venv_kubetest_issue/lib/python3.8/site-packages/_pytest/assertion/rewrite.py", line 170, in exec_module
    exec(co, module.__dict__)
  File "/home/lkr/venv_kubetest_issue/lib/python3.8/site-packages/kubetest/client.py", line 13, in <module>
    from kubetest import objects, utils
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "/home/lkr/venv_kubetest_issue/lib/python3.8/site-packages/_pytest/assertion/rewrite.py", line 170, in exec_module
    exec(co, module.__dict__)
  File "/home/lkr/venv_kubetest_issue/lib/python3.8/site-packages/kubetest/objects/__init__.py", line 9, in <module>
    from .daemonset import DaemonSet
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "/home/lkr/venv_kubetest_issue/lib/python3.8/site-packages/_pytest/assertion/rewrite.py", line 170, in exec_module
    exec(co, module.__dict__)
  File "/home/lkr/venv_kubetest_issue/lib/python3.8/site-packages/kubetest/objects/daemonset.py", line 17, in <module>
    class DaemonSet(ApiObject):
  File "/home/lkr/venv_kubetest_issue/lib/python3.8/site-packages/kubetest/objects/daemonset.py", line 35, in DaemonSet
    "apps/v1beta1": client.AppsV1beta1Api,
AttributeError: module 'kubernetes.client' has no attribute 'AppsV1beta1Api'

Workaround right now is to use kubernetes==17.17.0

johnnyrun commented 3 years ago

same problem here. Thanks for sharing

BartWeyder commented 3 years ago

Same problem, thanks for workaround

Leletir commented 3 years ago

I have the same problem with kubernetes==18.20.0