We have a try/except block on the resources around jsonpatch.apply_patch() call but they are only capturing the JsonPatchException, which seems not enough to handle all the exceptions raised by the jsonpatch.apply_patch().
That's hw it looks in our code right now
try:
node = Node(**jsonpatch.apply_patch(rpc_node.as_dict(),
jsonpatch.JsonPatch(patch)))
except jsonpatch.JsonPatchException as e:
LOG.exception(e)
raise wsme.exc.ClientSideError(_("Patching Error: %s") % e)
These are the exceptions not handled by us:
stack@stack-virtual-machine:~/devstack$ ironic node-update $NODE remove foo/pxe_preserve_ephemeral
member 'foo' not found in {'instance_uuid': u'b0b8b802-99b9-4329-b2e7-2d8e4af4ef3a', 'target_power_state': None, 'uuid': u'6fdbf5cd-36da-4c09-abaa-636705073440', 'driver_info': {u'pxe_deploy_ramdisk': u'c105a864-850e-4bea-8281-97cf826fdc53', u'pxe_instance_name': u'test', u'pxe_image_source': u'afeae16c-8217-42c3-b02b-e87273adb786', u'pxe_root_gb': u'5', u'ssh_username': u'root', u'ssh_key_filename': u'/home/stack/ssh_rsa', u'pxe_deploy_key': u'YUYQALNU552C6KIHPNK4GO64DMW76R2G', u'pxe_deploy_kernel': u'348fe5df-b273-4971-a9ea-80482d94b6a3', u'ssh_address': u'192.168.122.1', u'ssh_virt_type': u'virsh', u'pxe_ephemeral_gb': u'1'}, 'target_provision_state': None, 'last_error': None, 'created_at': datetime.datetime(2014, 1, 22, 11, 46, 33, tzinfo=<iso8601.iso8601.Utc object at 0x4a5a510>), 'extra': {}, 'driver': u'pxe_ssh', 'updated_at': datetime.datetime(2014, 1, 22, 14, 4, 9, tzinfo=<iso8601.iso8601.Utc object at 0x4a5a250>), 'chassis_id': None, 'id': 1, 'maintenance': False, 'provision_state': None, 'reservation': None, 'power_state': u'power off', 'properties': {}}
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/wsmeext/pecan.py", line 77, in callfunction
result = f(self, *args, **kwargs)
File "/opt/stack/ironic/ironic/api/controllers/v1/node.py", line 559, in patch
jsonpatch.JsonPatch(patch)))
File "/usr/local/lib/python2.7/dist-packages/jsonpatch.py", line 141, in apply_patch
return patch.apply(doc, in_place)
File "/usr/local/lib/python2.7/dist-packages/jsonpatch.py", line 344, in apply
obj = operation.apply(obj)
File "/usr/local/lib/python2.7/dist-packages/jsonpatch.py", line 393, in apply
subobj, part = self.pointer.to_last(obj)
File "/usr/local/lib/python2.7/dist-packages/jsonpointer.py", line 152, in to_last
doc = self.walk(doc, part)
File "/usr/local/lib/python2.7/dist-packages/jsonpointer.py", line 228, in walk
raise JsonPointerException("member '%s' not found in %s" % (part, doc))
JsonPointerException: member 'foo' not found in {'instance_uuid': u'b0b8b802-99b9-4329-b2e7-2d8e4af4ef3a', 'target_power_state': None, 'uuid': u'6fdbf5cd-36da-4c09-abaa-636705073440', 'driver_info': {u'pxe_deploy_ramdisk': u'c105a864-850e-4bea-8281-97cf826fdc53', u'pxe_instance_name': u'test', u'pxe_image_source': u'afeae16c-8217-42c3-b02b-e87273adb786', u'pxe_root_gb': u'5', u'ssh_username': u'root', u'ssh_key_filename': u'/home/stack/ssh_rsa', u'pxe_deploy_key': u'YUYQALNU552C6KIHPNK4GO64DMW76R2G', u'pxe_deploy_kernel': u'348fe5df-b273-4971-a9ea-80482d94b6a3', u'ssh_address': u'192.168.122.1', u'ssh_virt_type': u'virsh', u'pxe_ephemeral_gb': u'1'}, 'target_provision_state': None, 'last_error': None, 'created_at': datetime.datetime(2014, 1, 22, 11, 46, 33, tzinfo=<iso8601.iso8601.Utc object at 0x4a5a510>), 'extra': {}, 'driver': u'pxe_ssh', 'updated_at': datetime.datetime(2014, 1, 22, 14, 4, 9, tzinfo=<iso8601.iso8601.Utc object at 0x4a5a250>), 'chassis_id': None, 'id': 1, 'maintenance': False, 'provision_state': None, 'reservation': None, 'power_state': u'power off', 'properties': {}}
stack@stack-virtual-machine:~/devstack$ ironic node-update $NODE remove foo
u'foo'
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/wsmeext/pecan.py", line 77, in callfunction
result = f(self, *args, **kwargs)
File "/opt/stack/ironic/ironic/api/controllers/v1/node.py", line 559, in patch
jsonpatch.JsonPatch(patch)))
File "/usr/local/lib/python2.7/dist-packages/jsonpatch.py", line 141, in apply_patch
return patch.apply(doc, in_place)
File "/usr/local/lib/python2.7/dist-packages/jsonpatch.py", line 344, in apply
obj = operation.apply(obj)
File "/usr/local/lib/python2.7/dist-packages/jsonpatch.py", line 395, in apply
del subobj[part]
KeyError: u'foo'
stack@stack-virtual-machine:~/devstack$
Fix proposed to branch: master /review. openstack. org/68457
Review: https:/