Description
What happened (please include outputs or screenshots):
I have noticed, that every model class can accept local_vars_configuration
parameter during creation, otherwise it create default one, i.e.:
def __init__(self, api_version=None, items=None, kind=None, metadata=None, local_vars_configuration=None): # noqa: E501
"""V1PodList - a model defined in OpenAPI""" # noqa: E501
if local_vars_configuration is None:
local_vars_configuration = Configuration()
self.local_vars_configuration = local_vars_configuration
…
This lead to the title of this bug, where there is no way (or I cannot find one) for configuring an api call, to, for instance, turn off client side validation. In other words, there is no way to actually query K8s API with client side validation turned off.
I'm experimenting with the Kubernetes feature gate, and turned off selfLink propagation, which leads to an issue with the kubernetes itself, although IMO it just uncover how python client was designed.
My minimal example:
from kubernetes import client
from kubernetes.client import api_client
from kubernetes.client import configuration
conf = configuration.Configuration()
conf.client_side_validation = False
v1 = client.CoreV1Api(api_client=api_client.ApiClient(configuration=conf))
v1.list_pod_for_all_namespaces()
which just fetch the list of pods, and ends up wit the traceback:
Traceback (most recent call last):
File "/home/ubuntu/official.py", line 11, in <module>
v1.list_pod_for_all_namespaces()
File "/usr/local/lib/python3.6/dist-packages/kubernetes/client/api/core_v1_api.py", line 16864, in list_pod_for_all_namespaces
return self.list_pod_for_all_namespaces_with_http_info(**kwargs) # noqa: E501
File "/usr/local/lib/python3.6/dist-packages/kubernetes/client/api/core_v1_api.py", line 16981, in list_pod_for_all_namespaces_with_http_info
collection_formats=collection_formats)
File "/usr/local/lib/python3.6/dist-packages/kubernetes/client/api_client.py", line 353, in call_api
_preload_content, _request_timeout, _host)
File "/usr/local/lib/python3.6/dist-packages/kubernetes/client/api_client.py", line 192, in __call_api
return_data = self.deserialize(response_data, response_type)
File "/usr/local/lib/python3.6/dist-packages/kubernetes/client/api_client.py", line 264, in deserialize
return self.__deserialize(data, response_type)
File "/usr/local/lib/python3.6/dist-packages/kubernetes/client/api_client.py", line 303, in __deserialize
return self.__deserialize_model(data, klass)
File "/usr/local/lib/python3.6/dist-packages/kubernetes/client/api_client.py", line 641, in __deserialize_model
instance = klass(**kwargs)
File "/usr/local/lib/python3.6/dist-packages/kubernetes/client/models/v1_pod_list.py", line 63, in __init__
self.items = items
File "/usr/local/lib/python3.6/dist-packages/kubernetes/client/models/v1_pod_list.py", line 113, in items
raise ValueError("Invalid value for `items`, must not be `None`") # noqa: E501
ValueError: Invalid value for `items`, must not be `None`
What you expected to happen:
I'd expect, that configuration passed to the API object will be used in models as well. Otherwise there is no sense at all to configure anything connected with models itself, since default configuration would be used (not even preconfigured one, so set_default
/get_default_copy
methods of Configuration class could be used).
How to reproduce it (as minimally and precisely as possible):
- run Kuberenetes <1.20 with
--feature-gates=RemoveSelfLink=true
- use minimal example from above
Anything else we need to know?:
Environment:
- Kubernetes version (
kubectl version
): 1.19.6 - OS (e.g., MacOS 10.13.6): Ubintu 18.04 LTS
- Python version (
python --version
) 3.6.9 - Python client version (
pip list | grep kubernetes
) 12.0.1