kubernetes-client / python

Official Python client library for kubernetes
http://kubernetes.io/
Apache License 2.0
6.73k stars 3.26k forks source link

Error with api when set configuration assert_hostname as true #2253

Open Azteker opened 3 months ago

Azteker commented 3 months ago

When I set assert_hostname of client configuration as true,

configuration = client.Configuration()
configuration.assert_hostname = True

I got the following error

Traceback (most recent call last):                                                                                                                                                     
   File "/usr/src/app/my_portal/common/k8sapi.py", line 949, in get_cluster_usage                                                                                                   
     metrics_list = custom_objects_api.list_cluster_custom_object(group, version, resource)                                                                                             
   File "/usr/local/lib/python3.9/site-packages/kubernetes/client/api/custom_objects_api.py", line 2065, in list_cluster_custom_object                                                  
     return self.list_cluster_custom_object_with_http_info(group, version, plural, **kwargs)  # noqa: E501                                                                              
   File "/usr/local/lib/python3.9/site-packages/kubernetes/client/api/custom_objects_api.py", line 2196, in list_cluster_custom_object_with_http_info                                   │
     return self.api_client.call_api(                                                                                                                                                   
   File "/usr/local/lib/python3.9/site-packages/kubernetes/client/api_client.py", line 348, in call_api                                                                                 
     return self.__call_api(resource_path, method,                                                                                                                                      
   File "/usr/local/lib/python3.9/site-packages/kubernetes/client/api_client.py", line 180, in __call_api                                                                               
     response_data = self.request(                                                                                                                                                      
   File "/usr/local/lib/python3.9/site-packages/kubernetes/client/api_client.py", line 373, in request                                                                                  
     return self.rest_client.GET(url,                                                                                                                                                   
   File "/usr/local/lib/python3.9/site-packages/kubernetes/client/rest.py", line 241, in GET                                                                                            
     return self.request("GET", url,                                                                                                                                                    
   File "/usr/local/lib/python3.9/site-packages/kubernetes/client/rest.py", line 214, in request                                                                                        
     r = self.pool_manager.request(method, url,                                                                                                                                         
   File "/usr/local/lib/python3.9/site-packages/urllib3/request.py", line 77, in request                                                                                                
     return self.request_encode_url(                                                                                                                                                    
   File "/usr/local/lib/python3.9/site-packages/urllib3/request.py", line 99, in request_encode_url                                                                                     
     return self.urlopen(method, url, **extra_kw)                                                                                                                                       
  File "/usr/local/lib/python3.9/site-packages/urllib3/poolmanager.py", line 376, in urlopen                                                                                           
     response = conn.urlopen(method, u.request_uri, **kw)                                                                                                                               
   File "/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 715, in urlopen                                                                                        
     httplib_response = self._make_request(                                                                                                                                               
   File "/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 404, in _make_request                                                                                       
     self._validate_conn(conn)                                                                                                                                                             
   File "/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 1058, in _validate_conn                                                                                     
     conn.connect()                                                                                                                                                                        
   File "/usr/local/lib/python3.9/site-packages/urllib3/connection.py", line 472, in connect                                                                                                 
      _match_hostname(cert, self.assert_hostname or server_hostname)                                                                              
   File "/usr/local/lib/python3.9/site-packages/urllib3/connection.py", line 540, in _match_hostname                                                                                         
      stripped_hostname = asserted_hostname.strip("u[]")
AttributeError: 'bool' object has no attribute 'strip'                                                                                                   

As your spec assert_hostname should be a bool, but seems urllib3 expect assert_hostname to be a string instead of bool

k8s-triage-robot commented 1 week ago

The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

You can:

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale