openshift/openshift-restclient-python

AttributeError: module 'kubernetes.client.models' has no attribute 'V1Build'

Closed this issue · 1 comments

When calling create_namespaced_build_config_instantiate, there is raised the following exception when parsing response:

  | ---> Running application from Python script (app.py) ...
-- | --
  | Running DownShift version 0.0.1
  | 2018-07-26 10:57:42,365 [1] INFO     downshift: Checking build configs for image 'nbviewer' used in pod 'jupyterhub-nb-fpokorny'
  | 2018-07-26 10:57:42,383 [1] INFO     downshift: Triggering build 'nbviewer' for 'jupyterhub-nb-fpokorny'
  | 2018-07-26 10:57:42,410 [1] CRITICAL root: Traceback (most recent call last):
  | File "/opt/app-root/lib/python3.6/site-packages/openshift/client/api_client.py", line 16, in _ApiClient__deserialize
  | return super(ApiClient, self).__deserialize(data, klass)
  | File "/opt/app-root/lib/python3.6/site-packages/kubernetes/client/api_client.py", line 265, in __deserialize
  | klass = getattr(models, klass)
  | AttributeError: module 'kubernetes.client.models' has no attribute 'V1Build'
  | During handling of the above exception, another exception occurred:
  | Traceback (most recent call last):
  | File "/opt/app-root/lib/python3.6/site-packages/openshift/client/api_client.py", line 16, in _ApiClient__deserialize
  | return super(ApiClient, self).__deserialize(data, klass)
  | File "/opt/app-root/lib/python3.6/site-packages/kubernetes/client/api_client.py", line 265, in __deserialize
  | klass = getattr(models, klass)
  | AttributeError: module 'kubernetes.client.models' has no attribute 'V1BuildSpec'
  | During handling of the above exception, another exception occurred:
  | Traceback (most recent call last):
  | File "app.py", line 109, in <module>
  | sys.exit(main())
  | File "app.py", line 104, in main
  | _trigger_build_request(build_configs[0])
  | File "app.py", line 49, in _trigger_build_request
  | _PAYLOAD
  | File "/opt/app-root/lib/python3.6/site-packages/openshift/client/apis/build_openshift_io_v1_api.py", line 939, in create_namespaced_build_config_instantiate
  | (data) = self.create_namespaced_build_config_instantiate_with_http_info(name, namespace, body, **kwargs)
  | File "/opt/app-root/lib/python3.6/site-packages/openshift/client/apis/build_openshift_io_v1_api.py", line 1030, in create_namespaced_build_config_instantiate_with_http_info
  | collection_formats=collection_formats)
  | File "/opt/app-root/lib/python3.6/site-packages/kubernetes/client/api_client.py", line 321, in call_api
  | _return_http_data_only, collection_formats, _preload_content, _request_timeout)
  | File "/opt/app-root/lib/python3.6/site-packages/kubernetes/client/api_client.py", line 163, in __call_api
  | return_data = self.deserialize(response_data, response_type)
  | File "/opt/app-root/lib/python3.6/site-packages/kubernetes/client/api_client.py", line 236, in deserialize
  | return self.__deserialize(data, response_type)
  | File "/opt/app-root/lib/python3.6/site-packages/openshift/client/api_client.py", line 22, in _ApiClient__deserialize
  | return super(ApiClient, self).__deserialize_model(data, klass)
  | File "/opt/app-root/lib/python3.6/site-packages/kubernetes/client/api_client.py", line 620, in __deserialize_model
  | kwargs[attr] = self.__deserialize(value, attr_type)
  | File "/opt/app-root/lib/python3.6/site-packages/openshift/client/api_client.py", line 22, in _ApiClient__deserialize
  | return super(ApiClient, self).__deserialize_model(data, klass)
  | File "/opt/app-root/lib/python3.6/site-packages/kubernetes/client/api_client.py", line 622, in __deserialize_model
  | instance = klass(**kwargs)
  | File "/opt/app-root/lib/python3.6/site-packages/openshift/client/models/v1_build_spec.py", line 78, in __init__
  | self.node_selector = node_selector
  | File "/opt/app-root/lib/python3.6/site-packages/openshift/client/models/v1_build_spec.py", line 138, in node_selector
  | raise ValueError("Invalid value for `node_selector`, must not be `None`")
  | ValueError: Invalid value for `node_selector`, must not be `None`

kubernetes==6.0.0
openshift==0.6.2

We encountered this error here in fridex/downshift#3 (sources might be helpful).

Yeah. This, unfortunately, is not unique. If you have a look at the script we use to generate the openshift client (https://github.com/openshift/openshift-restclient-python/blob/master/scripts/update-client.sh#L97) you'll see a couple of the others that we have come across. This is a class of issue where the generated client is actually too strict when compared to the k8s/openshift api server, as a result of mistakes in the spec.

I would encourage you to use the dynamic client, mentioned here (https://github.com/openshift/openshift-restclient-python/#dynamic-client-usage) and see if that solves your problem. Since the dynamic client talks directly to the api server, I expect it will.

If you have any difficulty using the dynamic client for this purpose, I'm happy to help figure out what the code should look like, if you provide me an example of what you are doing