JsonPatchType duplicates functionality of WSME readonly & mandatory attributes

Bug #1284781 reported by aeva black
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Ironic
Fix Released
Medium
Miles Gould

Bug Description

ironic.api.controllers.v1.types:JsonPatchType() duplicates the "readonly" and "mandatory" functionality added in recent WSME releases and should be cleaned up.

aeva black (tenbrae)
Changed in ironic:
status: New → Triaged
importance: Undecided → Medium
Haomeng,Wang (whaom)
Changed in ironic:
assignee: nobody → Haomeng,Wang (whaom)
Revision history for this message
Haomeng,Wang (whaom) wrote :

@Deva, I understand we should remove the mandatory fields definition from API Object, because it is defined in Object JsonPatchType class mandatory_attrs method already, right?

eg:

port.address is mandatory field, defined in both code:

https://github.com/openstack/ironic/blob/master/ironic/api/controllers/v1/port.py#L80
https://github.com/openstack/ironic/blob/master/ironic/api/controllers/v1/port.py#L45

So we can remove the definition from line #L80.

Haomeng,Wang (whaom)
Changed in ironic:
status: Triaged → In Progress
Revision history for this message
Haomeng,Wang (whaom) wrote :

Typo, should remove the definition from line L45 and the validation mandatory_attrs logic L128-L134.

Haomeng,Wang (whaom)
Changed in ironic:
assignee: Haomeng,Wang (whaom) → nobody
aeva black (tenbrae)
Changed in ironic:
status: In Progress → Triaged
Changed in ironic:
assignee: nobody → Pablo Fernando Cargnelutti (pablo-fernando-cargnelutti)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to ironic (master)

Fix proposed to branch: master
Review: https://review.openstack.org/87755

Changed in ironic:
status: Triaged → In Progress
Revision history for this message
Dmitry Tantsur (divius) wrote :

Hi Pablo! Thank you for your contribution, as code review is abandoned, I unset you from assignee. Feel free to reassign, if you decide to return to your patch.

Changed in ironic:
status: In Progress → Triaged
assignee: Pablo Fernando Cargnelutti (pablo-fernando-cargnelutti) → nobody
tags: added: low-hanging-fruit
aeva black (tenbrae)
tags: added: api
Changed in ironic:
assignee: nobody → Shraddha Pandhe (shraddha-pandhe)
Revision history for this message
John Stafford (john-stafford) wrote :

Is this bug still being worked?

Revision history for this message
Serge Kovaleff (serge-kovaleff) wrote :

Is it alive?

Miles Gould (mgould)
Changed in ironic:
assignee: Shraddha Pandhe (shraddha-pandhe) → miles@assyrian.org.uk (miles-8)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

Fix proposed to branch: master
Review: https://review.openstack.org/240202

Changed in ironic:
status: Triaged → In Progress
Revision history for this message
Miles Gould (mgould) wrote :

Are we sure the semantics of JsonPatchType and wsme.wsattr.mandatory are the same? The field '/chassis_uuid' is mandatory for patching, but there's an explicit test that it's possible to create a Node without specifying a chassis_uuid:

https://github.com/openstack/ironic/blob/master/ironic/api/controllers/v1/node.py#L130
https://github.com/openstack/ironic/blob/master/ironic/tests/unit/api/v1/test_nodes.py#L1531

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to ironic (master)

Reviewed: https://review.openstack.org/240202
Committed: https://git.openstack.org/cgit/openstack/ironic/commit/?id=34b3589ea3c9e87b8ba370f122a37ac4eb2d9afd
Submitter: Jenkins
Branch: master

commit 34b3589ea3c9e87b8ba370f122a37ac4eb2d9afd
Author: Miles Gould <email address hidden>
Date: Wed Oct 28 17:59:42 2015 +0000

    Get mandatory patch attrs from WSME properties

    Attributes which are mandatory (ie, required for object creation) should
    not be removable. However, some attributes (such as Node.chassis_uuid)
    are not required for object creation, but should not be removable if
    they are set. This commit does the following:

     - rename JsonPatchType.mandatory_attrs to non_removable_attrs to better
       describe its meaning,
     - change its return type to set-of-strings for faster lookup
     - ensure all mandatory attributes on the type being patched are
       included in the set of non-removable attributes,
     - add a new field, JsonPatchType._extra_non_removable_attrs, which
       should be a set of attributes that are not required for creation but
       should not be removed if set.

    Since the object to be patched does not exist at patch-validation time,
    we leave the validation logic in methods of JsonPatchType and
    subclasses. This means introspecting the types to be patched.

    Closes-Bug: #1284781

    Change-Id: I2bb7fed2c776c8d63535c5ee19cdc218e57806e3

Changed in ironic:
status: In Progress → Fix Committed
Changed in ironic:
status: Fix Committed → Fix Released
Revision history for this message
Doug Hellmann (doug-hellmann) wrote : Fix included in openstack/ironic 4.3.0

This issue was fixed in the openstack/ironic 4.3.0 release.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.