ygot icon indicating copy to clipboard operation
ygot copied to clipboard

Diff api does generate deletes for leaf list values

Open adelshafiei opened this issue 1 year ago • 6 comments

I changed a leaf list value from [1, 18, 25] to [18, 25, 34]. Ygot diff api generate an update with value [18, 25, 34] and no delete. This results in the final list of [1, 18, 25, 34] which is not expected.

adelshafiei avatar Nov 17 '23 02:11 adelshafiei

Hi, ygot.Diff returns a Notification value. What did you do with the Notification value that caused the final list to occur?

wenovus avatar Nov 17 '23 02:11 wenovus

I used the notification list to update device config. In the notification list, there is an update for [18, 25, 34] but no delete is generated for value 1 in the leaf list

adelshafiei avatar Nov 17 '23 02:11 adelshafiei

Did you use gNMI.Set with an Update message? If so, I believe setting a leaf-list should overwrite the value instead of appending to them.

That being said, taking a look at RFC7950, NETCONF insert seems to offer more flexible operations, while the gNMI spec doesn't explicitly talk about this scenario. @robshakir Do we have a stance on what happens with leaf-lists when gNMI.Set with Update is executed? Since we don't have an insert operation it seems like replacement must be our behaviour to keep things simple? Esp. if a non-leaf update is made containing leaf-list values. If so I'll update the spec to make this clearer.

wenovus avatar Nov 17 '23 04:11 wenovus

Yes, we do not allow partial update of leaf-lists in gNMI -- we declaratively require them to be entirely specified.

robshakir avatar Nov 18 '23 06:11 robshakir

In this case, can I enhance the ygot diff api to return a replace gnmipb.Update slice along side the gnmi notification to be used together for the gnmi set request?

adelshafiei avatar Nov 18 '23 19:11 adelshafiei

Not quite sure what enhancement you had in mind. Can you just call Set.Replace now instead of Set.Update? It seems like the device is not conforming to the right spec (I will make a PR to update the spec soon), and since Diff only returns leaves it seems like a safe thing to do.

wenovus avatar Nov 20 '23 04:11 wenovus