NFV VIM fails on StopIterator exceptions in newer python

Bug #1963277 reported by Al Bailey
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
StarlingX
Fix Released
Medium
Al Bailey

Bug Description

When running the VIM (nfv) on debian bullseye (which uses python 3.9.2) the VIM fails to start.

The exception is a little misleading

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/nfv_vim/vim.py", line 167, in process_main
    selobj.selobj_dispatch(PROCESS_TICK_INTERVAL_IN_MS)
  File "/usr/lib/python3/dist-packages/nfv_common/selobj/_selobj_module.py", line 105, in selobj_dispatch
    callback.send(selobj)
  File "/usr/lib/python3/dist-packages/nfv_common/tasks/_task_scheduler.py", line 332, in task_work_complete
    task.task_work_complete(task_work)
  File "/usr/lib/python3/dist-packages/nfv_common/tasks/_task.py", line 193, in task_work_complete
    self._target.send(task_result)
RuntimeError: generator raised StopIteration

_task.py", line 193 target.send is expected to raise a StopIteration
and _task_scheduler.py" line 332 expects to catch it.

However in python 3.7 (and later) a change was introduced (mentioned here)
https://docs.python.org/3/whatsnew/3.7.html#changes-in-python-behavior
and described here:
https://www.python.org/dev/peps/pep-0479/

which means we need to change the vim code everywhere that does this:
except StopIteration:

to instead be this:
except (StopIteration, RuntimeError):

These are the places in the code that need to be updated:
nfv_common/tasks/_task_scheduler.py (5 places)
nfv_common/timers/_timer.py (1 place)
nfv_common/selobj/_selobj_module.py (3 places)

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

Fix proposed to branch: master
Review: https://review.opendev.org/c/starlingx/nfv/+/831841

Changed in starlingx:
status: New → In Progress
Revision history for this message
Al Bailey (albailey1974) wrote :

Even though I uploaded a review, I am leaving this unassigned because I hate that I get so many emails for launchpads

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

Reviewed: https://review.opendev.org/c/starlingx/nfv/+/831841
Committed: https://opendev.org/starlingx/nfv/commit/94ce75c0d45589b197b5481d21f85035e16291ce
Submitter: "Zuul (22348)"
Branch: master

commit 94ce75c0d45589b197b5481d21f85035e16291ce
Author: albailey <email address hidden>
Date: Thu Mar 3 12:59:28 2022 -0600

    Update nfv code to work properly on python3.7+

    The coroutines in nfv internally raise StopIteration,
    however in python 3.7, that exception is converted to
    a RuntimeError: https://www.python.org/dev/peps/pep-0479/

    The vim code that catches a StopIteration exception has
    been updated to catch both types.

    The OCF scripts on a Debian system runs python3, and need
    explicit /usr/bin/python3 added to them

    Test-Plan:
     - Verified a Debian environment running python 3.9 is able
    to start nfv-vim without the process immediately crashing.
     - Verified a Centos environment running the older python2.7
    still able to run nfv-vim.
     - Verified Centos installation

    Closes-Bug: 1963277
    Closes-Bug: 1962787
    Signed-off-by: albailey <email address hidden>
    Change-Id: Ib54926738aeafbee0c90e7a2b5a4ad9556a3d7f1

Changed in starlingx:
status: In Progress → Fix Released
Ghada Khalil (gkhalil)
tags: added: stx.7.0 stx.debian stx.nfv
Changed in starlingx:
importance: Undecided → Medium
assignee: nobody → Al Bailey (albailey1974)
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.