Skip to content

Failed to create namespaced custom object with new Kubenertes Client 11.0.0 #1112

Closed
@jinchihe

Description

@jinchihe

What happened (please include outputs or screenshots):

Failed to create namespaced custom object with new Kubenertes Client 11.0.0

/usr/local/lib/python3.5/dist-packages/kubernetes/client/api/custom_objects_api.py:183: in create_namespaced_custom_object
   (data) = self.create_namespaced_custom_object_with_http_info(group, version, namespace, plural, body, **kwargs)  # noqa: E501
/usr/local/lib/python3.5/dist-packages/kubernetes/client/api/custom_objects_api.py:289: in create_namespaced_custom_object_with_http_info
   collection_formats=collection_formats)
/usr/local/lib/python3.5/dist-packages/kubernetes/client/api_client.py:345: in call_api
   _preload_content, _request_timeout)
/usr/local/lib/python3.5/dist-packages/kubernetes/client/api_client.py:166: in __call_api
   body = self.sanitize_for_serialization(body)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <kubernetes.client.api_client.ApiClient object at 0x7f81a5f375f8>
obj = {'api_version': 'kubeflow.org/v1',
'kind': 'TFJob',
'metadata': {'annotations': None,
             'cluster_name': ...                                   'volumes': None}}}},
         'ttl_seconds_after_finished': None},
'status': None}
   def sanitize_for_serialization(self, obj):
       """Builds a JSON POST object.

       If obj is None, return None.
       If obj is str, int, long, float, bool, return directly.
       If obj is datetime.datetime, datetime.date
           convert to string in iso8601 format.
       If obj is list, sanitize each element in the list.
       If obj is dict, return the dict.
       If obj is OpenAPI model, return the properties dict.

       :param obj: The data to serialize.
       :return: The serialized form of data.
       """
       if obj is None:
           return None
       elif isinstance(obj, self.PRIMITIVE_TYPES):
           return obj
       elif isinstance(obj, list):
           return [self.sanitize_for_serialization(sub_obj)
                   for sub_obj in obj]
       elif isinstance(obj, tuple):
           return tuple(self.sanitize_for_serialization(sub_obj)
                        for sub_obj in obj)
       elif isinstance(obj, (datetime.datetime, datetime.date)):
           return obj.isoformat()

       if isinstance(obj, dict):
           obj_dict = obj
       else:
           # Convert model obj to dict except
           # attributes `openapi_types`, `attribute_map`
           # and attributes which value is not None.
           # Convert attribute name to json key in
           # model definition for request.
           obj_dict = {obj.attribute_map[attr]: getattr(obj, attr)
>                       for attr, _ in six.iteritems(obj.openapi_types)
                       if getattr(obj, attr) is not None}
E           AttributeError: 'V1TFJob' object has no attribute 'openapi_types'
/usr/local/lib/python3.5/dist-packages/kubernetes/client/api_client.py:230: AttributeError

What you expected to happen:

How to reproduce it (as minimally and precisely as possible):

Anything else we need to know?:

Environment:

  • Kubernetes version (kubectl version): 11.0.0
  • OS (e.g., MacOS 10.13.6):
  • Python version (python --version)
  • Python client version (pip list | grep kubernetes)

Metadata

Metadata

Assignees

Labels

kind/bugCategorizes issue or PR as related to a bug.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions