-
Notifications
You must be signed in to change notification settings - Fork 145
Closed
Description
Thinking this might be an issue with overeager snake_casing or something, the request body that is generated has match_labels and match_expressions instead of matchLabels and matchExpressions.
I looked into the argspec for the resource and it had 'property_path': ['spec', 'selector', 'match_labels'] in it, I'm not totally sure if I'm right but I think that is probably where the error is. If I manually tweak the request body to camelCase the selectors everything seems to work fine.
self = <openshift.helper.ansible.KubernetesAnsibleModuleHelper object at 0x7fdad6581c50>, namespace = 'test-e8e00fd1', k8s_obj = None
body = {'kind': 'ReplicaSet', 'metadata': {'name': 'create-2794f0', 'namespace': 'test-e8e00fd1'}, 'spec': {'replicas': 3, 's...'create-2794f0'}}, 'spec': {'containers': [{'image': 'openshift/origin-ruby-sample:v1.0', 'name': 'create-2794f0'}]}}}}
def create_object(self, namespace=None, k8s_obj=None, body=None):
"""
Send a POST request to the API. Pass either k8s_obj or body.
:param namespace: namespace value or None
:param k8s_obj: optional k8s object model
:param body: optional JSON dict
:return: new object returned from the API
"""
self.logger.debug('Starting create object')
w, stream = self._create_stream(namespace)
return_obj = None
name = None
if k8s_obj:
name = k8s_obj.metadata.name
elif body:
name = body.get('metadata', {}).get('name', None)
try:
create_method = self.lookup_method('create', namespace)
if namespace:
if k8s_obj:
create_method(namespace, k8s_obj)
else:
create_method(namespace, body=body)
else:
if k8s_obj:
create_method(k8s_obj)
else:
create_method(body=body)
except ApiException as exc:
msg = json.loads(exc.body).get('message', exc.reason) if exc.body.startswith('{') else exc.body
> raise self.get_exception_class()(msg, status=exc.status)
E openshift.helper.exceptions.KubernetesException: {"message": "ReplicaSet.extensions \"create-2794f0\" is invalid: spec.selector: Invalid value: {}: empty selector is not valid for deployment.", "status": 422}
Metadata
Metadata
Assignees
Labels
No labels