CermakM / argo-client-python

Python client for Argo Workflows | Mirrored to https://github.com/argoproj-labs/argo-client-python
https://github.com/argoproj/argo
Apache License 2.0
31 stars 8 forks source link

Cannot create_namespaced_workflow #11

Closed chaliy closed 4 years ago

chaliy commented 4 years ago

Code is just a replica of hello-world.yaml

body = {    
        'apiVersion': 'argoproj.io/v1alpha1',
        'kind': 'Workflow',
        'metadata': {
            'generateName': 'wf-hw-',
        },
        'spec': {
            'entrypoint': 'whalesay',
            'templates': [
            {
                'name': 'whalesay',
                'container': {
                    'image': 'docker/whalesay:latest',
                    'command': ['cowsay'],
                    'args': ['hello world']
                }
            }]
        }
    }

    try:
        api_response = v1alpha1_api.create_namespaced_workflow('super-namespace', body)
        pprint(api_response)
    except ApiException as e:
        logger.error(f'Exception when calling argo/V1alpha1Api->create_namespaced_workflow: {e}')

Error response is:

Traceback (most recent call last):
  File "./broker/dev.py", line 5, in <module>
    'foo': 'bar'
  File "/.../broker/argo_client/__init__.py", line 88, in create_hw_instance_workflow
    api_response = v1alpha1_api.create_namespaced_workflow('super-namespace', body)
  File "/..../virtualenvs/broker-4arCEMtC/lib/python3.7/site-packages/argo/workflows/client/api/v1alpha1_api.py", line 57, in create_namespaced_workflow
    (data) = self.create_namespaced_workflow_with_http_info(namespace, body, **kwargs)  # noqa: E501
  File "/..../virtualenvs/broker-4arCEMtC/lib/python3.7/site-packages/argo/workflows/client/api/v1alpha1_api.py", line 138, in create_namespaced_workflow_with_http_info
    collection_formats=collection_formats)
  File "/..../virtualenvs/broker-4arCEMtC/lib/python3.7/site-packages/argo/workflows/client/api_client.py", line 330, in call_api
    _preload_content, _request_timeout)
  File "/..../virtualenvs/broker-4arCEMtC/lib/python3.7/site-packages/argo/workflows/client/api_client.py", line 169, in __call_api
    return_data = self.deserialize(response_data, response_type)
  File "/..../virtualenvs/broker-4arCEMtC/lib/python3.7/site-packages/argo/workflows/client/api_client.py", line 241, in deserialize
    return self.__deserialize(data, response_type)
  File "/..../virtualenvs/broker-4arCEMtC/lib/python3.7/site-packages/argo/workflows/client/api_client.py", line 280, in __deserialize
    return self.__deserialize_model(data, klass)
  File "/..../virtualenvs/broker-4arCEMtC/lib/python3.7/site-packages/argo/workflows/client/api_client.py", line 624, in __deserialize_model
    kwargs[attr] = self.__deserialize(value, attr_type)
  File "/..../virtualenvs/broker-4arCEMtC/lib/python3.7/site-packages/argo/workflows/client/api_client.py", line 280, in __deserialize
    return self.__deserialize_model(data, klass)
  File "/..../virtualenvs/broker-4arCEMtC/lib/python3.7/site-packages/argo/workflows/client/api_client.py", line 624, in __deserialize_model
    kwargs[attr] = self.__deserialize(value, attr_type)
  File "/..../virtualenvs/broker-4arCEMtC/lib/python3.7/site-packages/argo/workflows/client/api_client.py", line 258, in __deserialize
    for sub_data in data]
  File "/..../virtualenvs/broker-4arCEMtC/lib/python3.7/site-packages/argo/workflows/client/api_client.py", line 258, in <listcomp>
    for sub_data in data]
  File "/..../virtualenvs/broker-4arCEMtC/lib/python3.7/site-packages/argo/workflows/client/api_client.py", line 280, in __deserialize
    return self.__deserialize_model(data, klass)
  File "/..../virtualenvs/broker-4arCEMtC/lib/python3.7/site-packages/argo/workflows/client/api_client.py", line 624, in __deserialize_model
    kwargs[attr] = self.__deserialize(value, attr_type)
  File "/..../virtualenvs/broker-4arCEMtC/lib/python3.7/site-packages/argo/workflows/client/api_client.py", line 280, in __deserialize
    return self.__deserialize_model(data, klass)
  File "/..../virtualenvs/broker-4arCEMtC/lib/python3.7/site-packages/argo/workflows/client/api_client.py", line 626, in __deserialize_model
    instance = klass(**kwargs)
  File "/..../virtualenvs/broker-4arCEMtC/lib/python3.7/site-packages/kubernetes/client/models/v1_container.py", line 125, in __init__
    self.name = name
  File "/..../virtualenvs/broker-4arCEMtC/lib/python3.7/site-packages/kubernetes/client/models/v1_container.py", line 356, in name
    raise ValueError("Invalid value for `name`, must not be `None`")
ValueError: Invalid value for `name`, must not be `None`

Response by APIs:

{
    "apiVersion": "argoproj.io/v1alpha1",
    "kind": "Workflow",
    "metadata": {
        "creationTimestamp": "2019-12-24T12:43:17Z",
        "generateName": "hw-",
        "generation": 1,
        "name": "hw-9dgn5",
        "namespace": "super-namespace",
        "resourceVersion": "27916",
        "selfLink": "/apis/argoproj.io/v1alpha1/namespaces/super-namespace/workflows/hw-9dgn5",
        "uid": "f584617a-264a-11ea-a724-025000000001"
    },
    "spec": {
        "entrypoint": "whalesay",
        "templates": [
            {
                "container": {
                    "args": [
                        "hello world"
                    ],
                    "command": [
                        "cowsay"
                    ],
                    "image": "docker/whalesay:latest"
                },
                "name": "whalesay"
            }
        ]
    }
}

It seems like it returns response, but then cannot deserialize. Any idea?

yxue-kabam commented 4 years ago

not an author but I ran into the same problem before. The idea that you must have something set for name attr of `V1Container, even if it's an empty str:

V1Container(
    name='',
    image='alpine:latest',
    command=['sh', '-c'],
    args=['echo intentional failure; exit 1'])
CermakM commented 4 years ago

@chaliy @yxue-kabam is right, the name of V1Container is a required attribute as per the kubernetes OpenAPI specification.

See https://raw.githubusercontent.com/kubernetes/kubernetes/master/api/openapi-spec/swagger.json

CermakM commented 4 years ago

Closing the issue. Please, reopen the issue if the problem persists.