Python client version: 4.0.0a1
Server version: 1.8.0
On an endpoints request, Kubernetes 1.8 will return "subsets": null in the case of an empty subsets list. This leads to an error on deserialization:
File "/usr/local/lib/python3.6/dist-packages/kubernetes/watch/watch.py", line 119, in stream yield self.unmarshal_event(line, return_type) File "/usr/local/lib/python3.6/dist-packages/kubernetes/watch/watch.py", line 83, in unmarshal_event
js['object'] = self._api_client.deserialize(obj, return_type) File "/usr/local/lib/python3.6/dist-packages/kubernetes/client/api_client.py", line 236, in deserialize return self.__deserialize(data, response_type)
File "/usr/local/lib/python3.6/dist-packages/kubernetes/client/api_client.py", line 276, in __deserialize
return self.__deserialize_model(data, klass)
File "/usr/local/lib/python3.6/dist-packages/kubernetes/client/api_client.py", line 622, in __deserialize_model
instance = klass(**kwargs)
File "/usr/local/lib/python3.6/dist-packages/kubernetes/client/models/v1_endpoints.py", line 64, in __init__
self.subsets = subsets
File "/usr/local/lib/python3.6/dist-packages/kubernetes/client/models/v1_endpoints.py", line 156, in subsets
raise ValueError("Invalid value for `subsets`, must not be `None`")
ValueError: Invalid value for `subsets`, must not be `None`
See related Kubernetes issue: https://github.com/kubernetes/kubernetes/issues/44593
However, that issue was eventually resolved by declaring that as clients should treat nulls and empty lists as interchangeable unless specified otherwise:
https://github.com/kubernetes/kubernetes/pull/45294
The Python client should remove the none-checks, or possibly translate them to empty lists (though if they decided against that on the server-side, it sounds risky).
Same problem with CRD requests:
File "/usr/local/lib/python3.6/site-packages/kubernetes/client/models/v1beta1_custom_resource_definition_status.py", line 53, in __init__
self.conditions = conditions
File "/usr/local/lib/python3.6/site-packages/kubernetes/client/models/v1beta1_custom_resource_definition_status.py", line 101, in conditions
raise ValueError("Invalid value for `conditions`, must not be `None`")
ValueError: Invalid value for `conditions`, must not be `None`
@yliaog ping? This is going to become a larger problem as more people start to use Kubernetes 1.8.
cc @mbohlool for his comments
That is an interesting problem and I keep going back and forth between main repo or swagger-codegen as the place to fix this. Problem is do we assume a required array can be empty or not. Seems that kubernetes API server think that is OK but swagger-codegen assume the other one.
I would say the best fix should be in kubernetes main repo, e.g. if an array can be empty, it should not be required. I suggest you file an issue in the main repo and see if we can get a fix there in 1.10.
As a temporary fix, we can patch the spec in the kubernetes-client/gen repo.
Just to piggy back off this issue. I'm seeing a similar error with the list_event_for_all_namespaces endpoint.
"ValueError: Invalid value for involved_object, must not be None"
python client: 4.0.0
K8s API Version: 1.6.4
I did not see this issue when were using the 2.2.0 of the python client.
For anyone looking for an easy workaround. You can easily monkey patch the class giving you errors:
```python
from kubernetes.client.models.v1_endpoints import V1Endpoints
def set_subsets(self, subsets):
if subsets is None:
subsets = []
self._subsets = subsets
setattr(V1Endpoints, 'subsets', property(fget=V1Endpoints.subsets.fget, fset=set_subsets))
Running into this problem regularly with respect to CRDs.
Client Version: version.Info{Major:"1", Minor:"11", GitVersion:"v1.11.0", GitCommit:"91e7b4fd31fcd3d5f436da26c980becec37ceefe", GitTreeState:"clean", BuildDate:"2018-06-27T20:17:28Z", GoVersion:"go1.10.2", Compiler:"gc", Platform:"windows/amd64"}
Server Version: version.Info{Major:"1", Minor:"10", GitVersion:"v1.10.0", GitCommit:"fc32d2f3698e36b93322a3465f63a14e9f0eaead", GitTreeState:"clean", BuildDate:"2018-03-26T16:44:10Z", GoVersion:"go1.9.3", Compiler:"gc", Platform:"linux/amd64"}
same issue and workaround didnt work for me....
Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.
If this issue is safe to close now please do so with /close.
Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale
Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.
If this issue is safe to close now please do so with /close.
Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle rotten
Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.
Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/close
@fejta-bot: Closing this issue.
In response to this:
Rotten issues close after 30d of inactivity.
Reopen the issue with/reopen.
Mark the issue as fresh with/remove-lifecycle rotten.Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/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.
/reopen
@ashpreetbedi: You can't reopen an issue/PR unless you authored it or you are a collaborator.
In response to this:
/reopen
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.
@mbohlool this issue is there when creating CRDs as well. How can we get this fixed?
Most helpful comment
For anyone looking for an easy workaround. You can easily monkey patch the class giving you errors:
```python
from kubernetes.client.models.v1_endpoints import V1Endpoints
def set_subsets(self, subsets):
if subsets is None:
subsets = []
self._subsets = subsets
setattr(V1Endpoints, 'subsets', property(fget=V1Endpoints.subsets.fget, fset=set_subsets))