node.instance_uuid can not be replaced by JSON PATCH "add" operator

Bug #1310843 reported by aeva black
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Ironic
Fix Released
Low
Afonne-CID

Bug Description

The RFC for a JSON PATCH operation specifies that the "add" operator should also replace existing values. This works for most of Ironic's API. However, it is prevented from working on the node.instance_uuid property by this section in db.sqlalchemy.api

https://github.com/openstack/ironic/blob/master/ironic/db/sqlalchemy/api.py#L373

    def update_node(self, node_id, values):
...
            # Prevent instance_uuid overwriting
            if values.get("instance_uuid") and ref.instance_uuid:
                raise exception.NodeAssociated(node=node_id,
                                instance=ref.instance_uuid)

The reason for this is clear: prevent a race whereby two nova-compute agents might try to associate the same node to different Nova instances, by serializing this process at Ironic's database (on a per-node level, not globally).

However, this is not obvious from the API itself, or from our API documentation.

We should document that the node.instance_uuid property does not adhere to the JSON PATCH RFC spec.

aeva black (tenbrae)
Changed in ironic:
importance: Undecided → Low
status: New → Triaged
Anusha (anusha-iiitm)
Changed in ironic:
assignee: nobody → Anusha (anusha-iiitm)
Anusha (anusha-iiitm)
Changed in ironic:
assignee: Anusha (anusha-iiitm) → nobody
Polly Zhou (polly-zhou)
Changed in ironic:
assignee: nobody → Polly Zhou (polly-zhou)
Polly Zhou (polly-zhou)
Changed in ironic:
assignee: Polly Zhou (polly-zhou) → nobody
Dmitry Tantsur (divius)
tags: added: documentation low-hanging-fruit
Revision history for this message
Meer Hashaam Khan (hashaaam) wrote :

I want to work on this issue.

Afonne-CID (cidelight)
Changed in ironic:
assignee: nobody → Afonne-CID (cidelight)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to ironic (master)

Fix proposed to branch: master
Review: https://review.opendev.org/c/openstack/ironic/+/964450

Changed in ironic:
status: Triaged → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to ironic (master)

Reviewed: https://review.opendev.org/c/openstack/ironic/+/964450
Committed: https://opendev.org/openstack/ironic/commit/f7e9da0a799bad6e0c87feb87c781e93ae889c6d
Submitter: "Zuul (22348)"
Branch: master

commit f7e9da0a799bad6e0c87feb87c781e93ae889c6d
Author: Afonne-CID <email address hidden>
Date: Tue Oct 21 06:27:39 2025 +0100

    Document instance_uuid JSON PATCH non-compliance

    Add API documentation noting that instance_uuid does not follow
    RFC 6902 behavior in that the "add" operator cannot replace existing
    values, preventing race conditions between Nova compute agents.

    Closes-Bug: #1310843
    Change-Id: I1caaf5b6133d756cf9484d3e5b56f7b8280525db
    Signed-off-by: Afonne-CID <email address hidden>

Changed in ironic:
status: In Progress → Fix Released
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.