Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when trying to create a Deployment or a Pod #105

Open
sdmorel opened this issue Apr 15, 2021 · 2 comments
Open

Error when trying to create a Deployment or a Pod #105

sdmorel opened this issue Apr 15, 2021 · 2 comments

Comments

@sdmorel
Copy link

sdmorel commented Apr 15, 2021

Hello,

I'm testing this plugin and I got the Resource Model working just fine.
But when I try to use one of the workflow steps to create a Deployment or a Pod I get the following error:

[Kubernetes-Create-Deployment] step started, config: {image=registry.example.com/busybox:1.33.0, debug=true, container_name=busybox, verify_ssl=false, replicas=1, name=busybox-deployment, namespace=rundeck-dev, api_version=apps/v1, labels=app=busybox}
[Kubernetes-Create-Deployment] executing: [python, -u, /home/rundeck/libext/cache/kubernetes-plugin-2.0.3/deployment-create.py]
DEBUG: kubernetes-model-source: Log level configured for DEBUG
DEBUG: kubernetes-model-source: Creating job from data:
DEBUG: kubernetes-model-source: {'api_version': 'apps/v1', 'name': 'busybox-deployment', 'container_name': 'busybox', 'image': 'registry.example.com/busybox:1.33.0', 'ports': None, 'replicas': '1', 'namespace': 'rundeck-dev', 'labels': 'app=busybox'}
DEBUG: kubernetes-plugin: config file
DEBUG: kubernetes-plugin: None
DEBUG: kubernetes-plugin: -------------------
DEBUG: kubernetes-plugin: getting from default config file
Traceback (most recent call last):
  File "/home/rundeck/libext/cache/kubernetes-plugin-2.0.3/deployment-create.py", line 128, in <module>
    main()
  File "/home/rundeck/libext/cache/kubernetes-plugin-2.0.3/deployment-create.py", line 123, in main
    deployment = create_deployment_object(data)
  File "/home/rundeck/libext/cache/kubernetes-plugin-2.0.3/deployment-create.py", line 19, in create_deployment_object
    template_spec = common.create_pod_template_spec(data=data)
  File "/home/rundeck/libext/cache/kubernetes-plugin-2.0.3/common.py", line 264, in create_pod_template_spec
    for port in data["ports"].split(','):
AttributeError: 'NoneType' object has no attribute 'split'
[Kubernetes-Create-Deployment]: result code: 1

And the deployment is not created in Kubernetes. This happens for any Pod with the ports field empty.

But when I deploy nginx with the port filed filled in, the following error occurs, but for some reason the deployment is created in Kubernetes.

[Kubernetes-Create-Deployment] step started, config: {image=registry.example.com/nginx:1.19.10-alpine, debug=true, container_name=nginx, verify_ssl=false, replicas=1, name=nginx-deployment, namespace=rundeck-dev, api_version=apps/v1, ports=80, labels=app=nginx}
[Kubernetes-Create-Deployment] executing: [python, -u, /home/rundeck/libext/cache/kubernetes-plugin-2.0.3/deployment-create.py]
DEBUG: kubernetes-model-source: Log level configured for DEBUG
DEBUG: kubernetes-model-source: Creating job from data:
DEBUG: kubernetes-model-source: {'api_version': 'apps/v1', 'name': 'nginx-deployment', 'container_name': 'nginx', 'image': 'registry.example.com/nginx:1.19.10-alpine', 'ports': '80', 'replicas': '1', 'namespace': 'rundeck-dev', 'labels': 'app=nginx'}
DEBUG: kubernetes-plugin: config file
DEBUG: kubernetes-plugin: None
DEBUG: kubernetes-plugin: -------------------
DEBUG: kubernetes-plugin: getting from default config file
Traceback (most recent call last):
  File "/home/rundeck/libext/cache/kubernetes-plugin-2.0.3/deployment-create.py", line 128, in <module>
    main()
  File "/home/rundeck/libext/cache/kubernetes-plugin-2.0.3/deployment-create.py", line 124, in main
    create_deployment(apiV1, deployment, data)
  File "/home/rundeck/libext/cache/kubernetes-plugin-2.0.3/deployment-create.py", line 60, in create_deployment
    print(common.parseJson(api_response.status))
  File "/home/rundeck/libext/cache/kubernetes-plugin-2.0.3/common.py", line 258, in parseJson
    return json.dumps(obj, cls=ObjectEncoder)
  File "/usr/lib/python3.6/json/__init__.py", line 238, in dumps
    **kw).encode(obj)
  File "/usr/lib/python3.6/json/encoder.py", line 199, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "/usr/lib/python3.6/json/encoder.py", line 257, in iterencode
    return _iterencode(o, 0)
  File "/home/rundeck/libext/cache/kubernetes-plugin-2.0.3/common.py", line 254, in default
    return {k.lstrip('_'): v for k, v in vars(obj).items()}
TypeError: vars() argument must have __dict__ attribute
[Kubernetes-Create-Deployment]: result code: 1

Using the Kubernetes/Generic/Create workflow step returns the same error in the Nginx deployment case. Again, in this case the deployment is created in Kubernetes.

DEBUG: kubernetes-model-source: Log level configured for DEBUG
Traceback (most recent call last):
  File "/home/rundeck/libext/cache/kubernetes-plugin-2.0.3/create-from-yaml.py", line 139, in <module>
    main()
  File "/home/rundeck/libext/cache/kubernetes-plugin-2.0.3/create-from-yaml.py", line 40, in main
    print(common.parseJson(resp.status))
  File "/home/rundeck/libext/cache/kubernetes-plugin-2.0.3/common.py", line 258, in parseJson
    return json.dumps(obj, cls=ObjectEncoder)
  File "/usr/lib/python3.6/json/__init__.py", line 238, in dumps
    **kw).encode(obj)
  File "/usr/lib/python3.6/json/encoder.py", line 199, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "/usr/lib/python3.6/json/encoder.py", line 257, in iterencode
    return _iterencode(o, 0)
  File "/home/rundeck/libext/cache/kubernetes-plugin-2.0.3/common.py", line 254, in default
    return {k.lstrip('_'): v for k, v in vars(obj).items()}
TypeError: vars() argument must have __dict__ attribute
Failed: NonZeroResultCode: Script result code was: 1

The Kubernetes cluster is v1.14.5, the Rundeck instance has Python 3.6.9 and kubernetes==12.0.1 installed.

@blbradley
Copy link

I'm experiencing TypeError: vars() argument must have __dict__ attribute, did you ever figure this out?

@kdebisschop
Copy link

The OP was using kubernetes==12.0.1 but the plugin requires 11.0.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants