[OVN] AgentCache.agents can change during an iteration operation

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

Bug Description

Reference bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2089420

During the ``neutron.plugins.ml2.drivers.ovn.agent.neutron_agent.AgentCache.__iter__`` iteration, an event to add or deleted an OVN agent can happen. The dictionary ``AgentCache.agents`` can change and trigger the error reported in the snippet.

Snippet: https://paste.opendev.org/show/bWn8eKHKIjsWb4MM6pd2/

Changed in neutron:
importance: Undecided → Critical
importance: Critical → Medium
assignee: nobody → Rodolfo Alonso (rodolfo-alonso-hernandez)
status: New → Incomplete
status: Incomplete → Confirmed
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/+/843933

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/+/843933
Committed: https://opendev.org/openstack/neutron/commit/a71fe45d9628f0dc67ccd12d94a51a7b801ec9d0
Submitter: "Zuul (22348)"
Branch: master

commit a71fe45d9628f0dc67ccd12d94a51a7b801ec9d0
Author: Rodolfo Alonso Hernandez <email address hidden>
Date: Sun May 15 22:48:46 2022 +0000

    [OVN] Protect the AgentCache iteration by copying the local cache

    During the execution of ``AgentCache.__iter__``, the content of
    "self.agents" can change; the Neutron server can attend to an event
    to add or delete an OVN agent. If that happens, the iteration will
    fail with the error:
      "RuntimeError: dictionary changed size during iteration"

    To avoid this, before iterating the list of agents, the cache
    singleton creates a copy of the local cache. The aim of making this
    copy is to avoid using locks between threads.

    Closes-Bug: #1976292
    Change-Id: Icf92685579409282bad0a80ba42531c93738e0b1

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

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

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

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

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

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

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

Reviewed: https://review.opendev.org/c/openstack/neutron/+/844549
Committed: https://opendev.org/openstack/neutron/commit/eb562b60a3f128fc45c9a90e1a849efbd6a62c57
Submitter: "Zuul (22348)"
Branch: stable/xena

commit eb562b60a3f128fc45c9a90e1a849efbd6a62c57
Author: Rodolfo Alonso Hernandez <email address hidden>
Date: Sun May 15 22:48:46 2022 +0000

    [OVN] Protect the AgentCache iteration by copying the local cache

    During the execution of ``AgentCache.__iter__``, the content of
    "self.agents" can change; the Neutron server can attend to an event
    to add or delete an OVN agent. If that happens, the iteration will
    fail with the error:
      "RuntimeError: dictionary changed size during iteration"

    To avoid this, before iterating the list of agents, the cache
    singleton creates a copy of the local cache. The aim of making this
    copy is to avoid using locks between threads.

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

    Closes-Bug: #1976292
    Change-Id: Icf92685579409282bad0a80ba42531c93738e0b1
    (cherry picked from commit a71fe45d9628f0dc67ccd12d94a51a7b801ec9d0)

tags: added: in-stable-xena
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to neutron (stable/yoga)

Reviewed: https://review.opendev.org/c/openstack/neutron/+/844493
Committed: https://opendev.org/openstack/neutron/commit/fbacaf7becd8c25824cadcd7c1f4080d8daf50b7
Submitter: "Zuul (22348)"
Branch: stable/yoga

commit fbacaf7becd8c25824cadcd7c1f4080d8daf50b7
Author: Rodolfo Alonso Hernandez <email address hidden>
Date: Sun May 15 22:48:46 2022 +0000

    [OVN] Protect the AgentCache iteration by copying the local cache

    During the execution of ``AgentCache.__iter__``, the content of
    "self.agents" can change; the Neutron server can attend to an event
    to add or delete an OVN agent. If that happens, the iteration will
    fail with the error:
      "RuntimeError: dictionary changed size during iteration"

    To avoid this, before iterating the list of agents, the cache
    singleton creates a copy of the local cache. The aim of making this
    copy is to avoid using locks between threads.

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

    Closes-Bug: #1976292
    Change-Id: Icf92685579409282bad0a80ba42531c93738e0b1
    (cherry picked from commit a71fe45d9628f0dc67ccd12d94a51a7b801ec9d0)

tags: added: in-stable-yoga
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to neutron (stable/wallaby)

Reviewed: https://review.opendev.org/c/openstack/neutron/+/844552
Committed: https://opendev.org/openstack/neutron/commit/9182712672f05d1b2849957c7632d703180c5e0f
Submitter: "Zuul (22348)"
Branch: stable/wallaby

commit 9182712672f05d1b2849957c7632d703180c5e0f
Author: Rodolfo Alonso Hernandez <email address hidden>
Date: Sun May 15 22:48:46 2022 +0000

    [OVN] Protect the AgentCache iteration by copying the local cache

    During the execution of ``AgentCache.__iter__``, the content of
    "self.agents" can change; the Neutron server can attend to an event
    to add or delete an OVN agent. If that happens, the iteration will
    fail with the error:
      "RuntimeError: dictionary changed size during iteration"

    To avoid this, before iterating the list of agents, the cache
    singleton creates a copy of the local cache. The aim of making this
    copy is to avoid using locks between threads.

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

    Closes-Bug: #1976292
    Change-Id: Icf92685579409282bad0a80ba42531c93738e0b1
    (cherry picked from commit a71fe45d9628f0dc67ccd12d94a51a7b801ec9d0)
    (cherry picked from commit eb562b60a3f128fc45c9a90e1a849efbd6a62c57)

tags: added: in-stable-wallaby
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/neutron 18.5.0

This issue was fixed in the openstack/neutron 18.5.0 release.

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

This issue was fixed in the openstack/neutron 19.4.0 release.

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

This issue was fixed in the openstack/neutron 20.2.0 release.

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

This issue was fixed in the openstack/neutron 21.0.0.0rc1 release candidate.

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.