Cannot attach/detach mirror to LSP using lsp_attach_mirror/lsp_detach_mirror

Bug #2055094 reported by Dmitry Skorykh
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
ovsdbapp
Fix Released
Undecided
Unassigned

Bug Description

I'm using an API to manipulate mirrors and found the following log entries and nothing changed in LSP mirror_rules column.

```
2024-02-26 09:41:09,079 ovsdbapp.backend.ovs_idl.vlog [POLLIN] on fd 7
2024-02-26 09:41:09,079 ovsdbapp.backend.ovs_idl.transaction Running txn n=1 command(idx=0): LspAttachMirror(_result=None, port=c572ebdc-df15-4ef9-ad00-20de9fddaf2b, mirror=1c84771a-ef64-4b12-838d-bd6c6effe212, may_exist=False)
2024-02-26 09:41:09,080 ovsdbapp.backend.ovs_idl.vlog attempting to write bad value to column mirror_rules (ovsdb error: expected uuid, got <class 'str'>)
2024-02-26 09:41:09,080 ovsdbapp.backend.ovs_idl.transaction Transaction caused no change
```

A little investigation led to the `run_idl` method in the `LspAttachMirror` and `LspDetachMirror` commands. When trying to use `lsp_attach_mirror` and `lsp_detach_mirror` I got this error when passing mirror UUIDs represented as string as described in API docstring. https://opendev.org/openstack/ovsdbapp/src/branch/master/ovsdbapp/schema/ovn_northbound/api.py#L1534

That's because of incorrect passed value to `row.addvalue(...)`
https://opendev.org/openstack/ovsdbapp/src/branch/master/ovsdbapp/schema/ovn_northbound/commands.py#L1226
and this string value follows to https://github.com/openvswitch/ovs/blob/master/python/ovs/db/data.py#L146 and here it's failed when string is passed.

So, we should pass looked up `mirror` row instead of raw string/uuid to the row.addvalue method.

Also I've found that tests were passed without issues because we use pass the `mirror` arg with the uuid.UUID type to call corresponding methods. But there are also some tests for API methods that expect str or uuid.UUID and we don't test API with strings and check only with UUID.

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

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

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

Reviewed: https://review.opendev.org/c/openstack/ovsdbapp/+/910278
Committed: https://opendev.org/openstack/ovsdbapp/commit/f9ec5ac7c8943e018e72d509fe6c358e8d1f37b4
Submitter: "Zuul (22348)"
Branch: master

commit f9ec5ac7c8943e018e72d509fe6c358e8d1f37b4
Author: Dmitrii Skorykh <email address hidden>
Date: Tue Feb 27 01:00:00 2024 +0300

    nb: commands: fix passing string to LSP attach/detach mirror API

    Pass an instance of idlutils.Row mirror as a value instead of raw string/uuid
    to addvalue/delvalue methods since OVS library Atom.from_python() ctor
    doesn't expect string as an argument.

    Closes-bug: #2055094
    Change-Id: Ibc1a5aaefe68f7e02f92285900654c9f70aed69e

Changed in ovsdbapp:
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.