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

create_namespaced_deployment_config requires V1DeploymentConfigStatus.available_replicas on OCP 3.4 #138

Closed
btjd opened this issue Jan 16, 2018 · 2 comments

Comments

@btjd
Copy link

btjd commented Jan 16, 2018

NOTE: The deployment still goes through despite the python error that's trown. The same workd on OCP 3.5+

[root@localhost ~]# oc version
oc v3.4.1.44.38
kubernetes v1.4.0+776c994
features: Basic-Auth GSSAPI Kerberos SPNEGO
Server https://x.x.x.x:8443
openshift v3.4.1.44.38
kubernetes v1.4.0+776c994
[root@localhost ~]# pip show openshift
Name: openshift
Version: 0.4.0

Summary: OpenShift python client
Home-page: https://github.com/openshift/openshift-restclient-python
Author: OpenShift
Author-email: UNKNOWN
License: Apache License Version 2.0
Location: /usr/lib/python2.7/site-packages/openshift-0.4.0-py2.7.egg
Requires: dictdiffer, jinja2, kubernetes, python-string-utils, ruamel.yaml, six
[root@localhost ~]# python
Python 2.7.5 (default, May 3 2017, 07:55:04)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-14)] on linux2
Type "help", "copyright", "credits" or "license" for more information.

from openshift import client, config
from pprint import pprint
import json
config.load_kube_config()
api_instance = client.OapiApi()
namespace = 'badre'
pretty = 'pretty_example'
with open('processed_deploymentconfig.json') as jd:
... body = json.load(jd)
...
pprint(body)
{u'apiVersion': u'v1',
u'kind': u'DeploymentConfig',
u'metadata': {u'labels': {u'app': u'fio'}, u'name': u'fio-4caky8mwlx'},
u'spec': {u'replicas': 1,
u'selector': {u'app': u'fio', u'deploymentconfig': u'fio'},
u'strategy': {u'type': u'Rolling'},
u'template': {u'metadata': {u'labels': {u'app': u'fio',
u'deploymentconfig': u'fio',
u'name': u'fio'}},
u'spec': {u'containers': [{u'image': u' ',
u'imagePullPolicy': u'Always',
u'name': u'fio',
u'resources': {},
u'terminationMessagePath': u'/dev/termination-log',
u'volumeMounts': [{u'mountPath': u'/usr/share/fio',
u'name': u'fio-data'}]}],
u'volumes': [{u'name': u'fio-data',
u'persistentVolumeClaim': {u'claimName': u'fio-4caky8mwlx'}}]}},
u'test': False,
u'triggers': [{u'imageChangeParams': {u'automatic': True,
u'containerNames': [u'fio'],
u'from': {u'kind': u'ImageStreamTag',
u'name': u'fio:latest'}},
u'type': u'ImageChange'}]}}
api_response = api_instance.create_namespaced_deployment_config(namespace, body, pretty=pretty)
Traceback (most recent call last):
File "", line 1, in
File "/usr/lib/python2.7/site-packages/openshift-0.4.0-py2.7.egg/openshift/client/apis/oapi_api.py", line 2752, in create_namespaced_deployment_config
(data) = self.create_namespaced_deployment_config_with_http_info(namespace, body, **kwargs)
File "/usr/lib/python2.7/site-packages/openshift-0.4.0-py2.7.egg/openshift/client/apis/oapi_api.py", line 2837, in create_namespaced_deployment_config_with_http_info
collection_formats=collection_formats)
File "/usr/lib/python2.7/site-packages/kubernetes-4.0.0-py2.7.egg/kubernetes/client/api_client.py", line 321, in call_api
_return_http_data_only, collection_formats, _preload_content, _request_timeout)
File "/usr/lib/python2.7/site-packages/kubernetes-4.0.0-py2.7.egg/kubernetes/client/api_client.py", line 163, in __call_api
return_data = self.deserialize(response_data, response_type)
File "/usr/lib/python2.7/site-packages/kubernetes-4.0.0-py2.7.egg/kubernetes/client/api_client.py", line 236, in deserialize
return self.__deserialize(data, response_type)
File "/usr/lib/python2.7/site-packages/openshift-0.4.0-py2.7.egg/openshift/client/api_client.py", line 17, in _ApiClient__deserialize
return super(ApiClient, self).__deserialize_model(data, klass)
File "/usr/lib/python2.7/site-packages/kubernetes-4.0.0-py2.7.egg/kubernetes/client/api_client.py", line 620, in __deserialize_model
kwargs[attr] = self.__deserialize(value, attr_type)
File "/usr/lib/python2.7/site-packages/openshift-0.4.0-py2.7.egg/openshift/client/api_client.py", line 17, in _ApiClient__deserialize
return super(ApiClient, self).__deserialize_model(data, klass)
File "/usr/lib/python2.7/site-packages/kubernetes-4.0.0-py2.7.egg/kubernetes/client/api_client.py", line 622, in __deserialize_model
instance = klass(**kwargs)
File "/usr/lib/python2.7/site-packages/openshift-0.4.0-py2.7.egg/openshift/client/models/v1_deployment_config_status.py", line 73, in init
self.available_replicas = available_replicas
File "/usr/lib/python2.7/site-packages/openshift-0.4.0-py2.7.egg/openshift/client/models/v1_deployment_config_status.py", line 107, in available_replicas
raise ValueError("Invalid value for available_replicas, must not be None")
ValueError: Invalid value for available_replicas, must not be None

available_replicas is a key of the V1DeploymentConfigStatus which is the body for the 'status' key in the V1DeploymentConfig object. That status key however is supposed to be optional

@fabianvf fabianvf added the bug label Jan 16, 2018
@ceridwen
Copy link
Contributor

This is the same underlying issue as #139 and kubernetes-client/python#394, an API call that returns null and then crashes because of new validation code in 4.0 client.

@djzager
Copy link
Member

djzager commented Jun 11, 2018

Fixed by (#167) you will need to use the Dynamic Client (https://github.com/openshift/openshift-restclient-python#dynamic-client-usage) to get the fix.

@djzager djzager closed this as completed Jun 11, 2018
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

4 participants