OVN AgentCache get_agents method filters agents incorrectly if hostname overlaps

Bug #2110094 reported by yatin
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
neutron
Fix Released
Medium
Rodolfo Alonso

Bug Description

It was observed in a dcn environment where compute hostnames overlapped, like compute-0 and dcn1-compute-0, and the current code filters both of these host when any of these as passed as filter i.e host=dcn1-compute-0.

Operation:- openstack port create --network dcn1-public --host dcn1-compute-0 port1

Fails as:-
2025-05-06 13:47:55.433 17 INFO neutron.plugins.ml2.drivers.ovn.mech_driver.mech_driver [None req-d4108c07-ba6a-467b-9b90-3d4d2a848fe3 376d4365073844daae419672441d3bc1 8d7a61145d2347b8ba7eb5f7c28cd4ae - - default default] Refusing to bind port 618b3861-f36e-4f37-8b24-83ba8bcff143 on host dcn1-compute-0 due to the OVN chassis bridge mapping physical networks ['datacentre'] not supporting physical network: leaf1
2025-05-06 13:47:55.433 17 ERROR neutron.plugins.ml2.managers [None req-d4108c07-ba6a-467b-9b90-3d4d2a848fe3 376d4365073844daae419672441d3bc1 8d7a61145d2347b8ba7eb5f7c28cd4ae - - default default] Failed to bind port 618b3861-f36e-4f37-8b24-83ba8bcff143 on host dcn1-compute-0 for vnic_type normal using segments [{'id': 'c36c1b38-cee5-4d1a-ab68-3638e221695a', 'network_type': 'flat', 'physical_network': 'leaf1', 'segmentation_id': None, 'network_id': '4f35cb1c-69d7-4582-b3a5-0cf380c56f62'}]

compute-0 - ovn-bridge-mappings=datacentre:br-ex
dcn1-compute-0 - ovn-bridge-mappings=leaf1:br-ex

Even the bridge mappings on dcn1-compute-0 is correct we can see the failure as it's not filtering correctly the hosts. This needs to be fixed.

Current code is:-
https://github.com/openstack/neutron/blob/123bd115f3b65ba09560685ad6cf68c6934a6535/neutron/plugins/ml2/drivers/ovn/agent/neutron_agent.py#L290C1-L298C26

    def get_agents(self, filters=None):
        filters = filters or {}
        agent_list = []
        for agent in self:
            agent_dict = agent.as_dict()
            if all(agent_dict[k] in v for k, v in filters.items()):
                agent_list.append(agent)
        return agent_list

Originally reported at https://issues.redhat.com/browse/OSPRH-16439

Miro Tomaska (mtomaska)
Changed in neutron:
importance: Undecided → High
status: New → Confirmed
Miro Tomaska (mtomaska)
Changed in neutron:
importance: High → Medium
Changed in neutron:
assignee: nobody → Rodolfo Alonso (rodolfo-alonso-hernandez)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to neutron (master)

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

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

Reviewed: https://review.opendev.org/c/openstack/neutron/+/949584
Committed: https://opendev.org/openstack/neutron/commit/26739f7c769a48f71c8590bbc481e1a11d8e793f
Submitter: "Zuul (22348)"
Branch: master

commit 26739f7c769a48f71c8590bbc481e1a11d8e793f
Author: Rodolfo Alonso Hernandez <email address hidden>
Date: Mon May 12 12:45:20 2025 +0000

    [OVN] OVN agent retrieval filter matching improvement

    This patch improves the OVN agent retrieval method, adding a better
    filter matching algorithm:
    * If the filter field matches the agent field, then the values should
      match identically.
    * If the filter field is an iterator, then it is expected that at least
      one of the passed values in this iterator matches with the agent field
      value.

    Closes-Bug: #2110094
    Change-Id: Iaaf0bfdd485f62be7527bb0c48acc49527c6e9a1

Changed in neutron:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to neutron (stable/2025.1)

Fix proposed to branch: stable/2025.1
Review: https://review.opendev.org/c/openstack/neutron/+/951646

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to neutron (stable/2024.2)

Fix proposed to branch: stable/2024.2
Review: https://review.opendev.org/c/openstack/neutron/+/951647

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to neutron (stable/2024.1)

Fix proposed to branch: stable/2024.1
Review: https://review.opendev.org/c/openstack/neutron/+/951648

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to neutron (stable/2025.1)

Reviewed: https://review.opendev.org/c/openstack/neutron/+/951646
Committed: https://opendev.org/openstack/neutron/commit/b958f4e0c3996b42274875dba03eb60e038e06aa
Submitter: "Zuul (22348)"
Branch: stable/2025.1

commit b958f4e0c3996b42274875dba03eb60e038e06aa
Author: Rodolfo Alonso Hernandez <email address hidden>
Date: Mon May 12 12:45:20 2025 +0000

    [OVN] OVN agent retrieval filter matching improvement

    This patch improves the OVN agent retrieval method, adding a better
    filter matching algorithm:
    * If the filter field matches the agent field, then the values should
      match identically.
    * If the filter field is an iterator, then it is expected that at least
      one of the passed values in this iterator matches with the agent field
      value.

    Conflicts:
      neutron/common/utils.py

    Closes-Bug: #2110094
    Change-Id: Iaaf0bfdd485f62be7527bb0c48acc49527c6e9a1
    (cherry picked from commit 26739f7c769a48f71c8590bbc481e1a11d8e793f)

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to neutron (stable/2024.2)

Reviewed: https://review.opendev.org/c/openstack/neutron/+/951647
Committed: https://opendev.org/openstack/neutron/commit/8463c6ec84b6321f91a496cea2850d8ebf8c9f8c
Submitter: "Zuul (22348)"
Branch: stable/2024.2

commit 8463c6ec84b6321f91a496cea2850d8ebf8c9f8c
Author: Rodolfo Alonso Hernandez <email address hidden>
Date: Mon May 12 12:45:20 2025 +0000

    [OVN] OVN agent retrieval filter matching improvement

    This patch improves the OVN agent retrieval method, adding a better
    filter matching algorithm:
    * If the filter field matches the agent field, then the values should
      match identically.
    * If the filter field is an iterator, then it is expected that at least
      one of the passed values in this iterator matches with the agent field
      value.

    Conflicts:
      neutron/common/utils.py
      neutron/plugins/ml2/drivers/ovn/agent/neutron_agent.py

    Closes-Bug: #2110094
    Change-Id: Iaaf0bfdd485f62be7527bb0c48acc49527c6e9a1
    (cherry picked from commit 26739f7c769a48f71c8590bbc481e1a11d8e793f)
    (cherry picked from commit b958f4e0c3996b42274875dba03eb60e038e06aa)

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to neutron (stable/2024.1)

Reviewed: https://review.opendev.org/c/openstack/neutron/+/951648
Committed: https://opendev.org/openstack/neutron/commit/1814fbb4c85c68873bbe0037101f46169ccd617e
Submitter: "Zuul (22348)"
Branch: stable/2024.1

commit 1814fbb4c85c68873bbe0037101f46169ccd617e
Author: Rodolfo Alonso Hernandez <email address hidden>
Date: Mon May 12 12:45:20 2025 +0000

    [OVN] OVN agent retrieval filter matching improvement

    This patch improves the OVN agent retrieval method, adding a better
    filter matching algorithm:
    * If the filter field matches the agent field, then the values should
      match identically.
    * If the filter field is an iterator, then it is expected that at least
      one of the passed values in this iterator matches with the agent field
      value.

    Conflicts:
      neutron/common/utils.py
      neutron/plugins/ml2/drivers/ovn/agent/neutron_agent.py

    Closes-Bug: #2110094
    Change-Id: Iaaf0bfdd485f62be7527bb0c48acc49527c6e9a1
    (cherry picked from commit 26739f7c769a48f71c8590bbc481e1a11d8e793f)
    (cherry picked from commit b958f4e0c3996b42274875dba03eb60e038e06aa)
    (cherry picked from commit b264bb9fd16fecbaa845e9622c0838a65a659bd9)

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/neutron 26.0.1

This issue was fixed in the openstack/neutron 26.0.1 Epoxy release.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/neutron 27.0.0.0b1

This issue was fixed in the openstack/neutron 27.0.0.0b1 Flamingo development milestone.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/neutron 24.2.1

This issue was fixed in the openstack/neutron 24.2.1 Caracal release.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/neutron 25.2.1

This issue was fixed in the openstack/neutron 25.2.1 Dalmatian 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.