-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Open
Labels
kind/bugCategorizes issue or PR as related to a bug.Categorizes issue or PR as related to a bug.lifecycle/staleDenotes an issue or PR has remained open with no activity and has become stale.Denotes an issue or PR has remained open with no activity and has become stale.
Description
What happened (please include outputs or screenshots):
Have the endpoint slice with no endpoints (just deleted the deployment):
kubectl get endpointslices.discovery.k8s.io
NAME ADDRESSTYPE PORTS ENDPOINTS AGE
ac-arpserver-svc-8vmcx IPv4 8080,8890,8888 + 1 more... 10.244.0.141,10.244.0.142,10.244.0.143 11d
ac-backend-svc-87m26 IPv4 8000 10.244.0.103,10.244.0.105,10.244.0.139 11d
ac-configsync-svc-4dcgp IPv4 <unset> <unset> 11d
ac-monitoring-svc-nlmgq IPv4 9007 10.244.0.113,10.244.0.111,10.244.0.112 11d
cm-nginx-svc-lnqjx IPv4 8080 10.244.0.167,10.244.0.168,10.244.0.169 25h
kubernetes IPv4 8443 192.168.49.2 14d
Try to get a endpoint slice:
from kubernetes import client, config
config.load_incluster_config()
ep = client.DiscoveryV1Api().list_namespaced_endpoint_slice(namespace = "default", watch = False).items
Got the error:
Traceback (most recent call last):
File "/root/bug.py", line 5, in <module>
ep = client.DiscoveryV1Api().list_namespaced_endpoint_slice(namespace = "default", watch = False).items
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/site-packages/kubernetes/client/api/discovery_v1_api.py", line 828, in list_namespaced_endpoint_slice
return self.list_namespaced_endpoint_slice_with_http_info(namespace, **kwargs) # noqa: E501
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/site-packages/kubernetes/client/api/discovery_v1_api.py", line 947, in list_namespaced_endpoint_slice_with_http_info
return self.api_client.call_api(
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/site-packages/kubernetes/client/api_client.py", line 348, in call_api
return self.__call_api(resource_path, method,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/site-packages/kubernetes/client/api_client.py", line 192, in __call_api
return_data = self.deserialize(response_data, response_type)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/site-packages/kubernetes/client/api_client.py", line 264, in deserialize
return self.__deserialize(data, response_type)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/site-packages/kubernetes/client/api_client.py", line 303, in __deserialize
return self.__deserialize_model(data, klass)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/site-packages/kubernetes/client/api_client.py", line 639, in __deserialize_model
kwargs[attr] = self.__deserialize(value, attr_type)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/site-packages/kubernetes/client/api_client.py", line 280, in __deserialize
return [self.__deserialize(sub_data, sub_kls)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/site-packages/kubernetes/client/api_client.py", line 303, in __deserialize
return self.__deserialize_model(data, klass)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/site-packages/kubernetes/client/api_client.py", line 641, in __deserialize_model
instance = klass(**kwargs)
^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/site-packages/kubernetes/client/models/v1_endpoint_slice.py", line 70, in __init__
self.endpoints = endpoints
^^^^^^^^^^^^^^
File "/usr/lib/python3.12/site-packages/kubernetes/client/models/v1_endpoint_slice.py", line 147, in endpoints
raise ValueError("Invalid value for `endpoints`, must not be `None`") # noqa: E501
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: Invalid value for `endpoints`, must not be `None`
What you expected to happen:
Expected to get something like this:
{
"addressType": "IPv4",
"endpoints": [],
"metadata": {
...
How to reproduce it (as minimally and precisely as possible):
Create a deployment, then a Service, then just kubectl delete -f deployment.yaml. Next try to run:
from kubernetes import client, config
config.load_incluster_config()
ep = client.DiscoveryV1Api().list_namespaced_endpoint_slice(namespace = "default", watch = False).items
Anything else we need to know?:
I fixed it by just commenting on the raise of the exception and passing [] to the endpoints in kubernetes/client/models/v1_endpoint_slice.py:
def endpoints(self, endpoints):
"""Sets the endpoints of this V1EndpointSlice.
endpoints is a list of unique endpoints in this slice. Each slice may include a maximum of 1000 endpoints. # noqa: E501
:param endpoints: The endpoints of this V1EndpointSlice. # noqa: E501
:type: list[V1Endpoint]
"""
if self.local_vars_configuration.client_side_validation and endpoints is None: # noqa: E501
#raise ValueError("Invalid value for `endpoints`, must not be `None`") # noqa: E501
endpoints = []
self._endpoints = endpoints
Environment:
- Kubernetes version (
kubectl version):
Client Version: v1.33.2
Kustomize Version: v5.6.0
Server Version: v1.33.1 - OS (e.g., MacOS 10.13.6):
Alpine Linux v3.22 - Python version (
python --version)
Python 3.12.11 - Python client version (
pip list | grep kubernetes)
kubernetes 32.0.1
Metadata
Metadata
Assignees
Labels
kind/bugCategorizes issue or PR as related to a bug.Categorizes issue or PR as related to a bug.lifecycle/staleDenotes an issue or PR has remained open with no activity and has become stale.Denotes an issue or PR has remained open with no activity and has become stale.