stx/config - logging DetachedInstanceError

Bug #1998512 reported by Rafael Falcão
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
StarlingX
Fix Released
Low
Lucas de Ataides Barreto

Bug Description

Brief Description
-----------------
While dealing with OpenStack resources, the sysinv log (/var/log/sysinv.log) is throwing a DetachedInstanceError exception.

Severity
--------
Minor

Steps to Reproduce
------------------
system application-upload stx-openstack.tgz
system application-apply stx-openstack
tail -100 /var/log/sysinv.log

Expected Behavior
------------------
No exception should be appearing in the log

Actual Behavior
----------------
DetachedInstanceError is appearing in the log

Reproducibility
---------------
Reproducible

System Configuration
--------------------
SX

Timestamp/Logs
--------------
sysinv 2022-11-29 12:24:40.714 69904 ERROR sysinv.objects.interface [-] DetachedInstanceError unable to get datanetworks for <sysinv.db.sqlalchemy.models.VirtualInterfaces object at 0x7f262633c700>: sqlalchemy.orm.exc.DetachedInstanceError: Parent instance <VirtualInterfaces at 0x7f262633c700> is not bound to a Session; lazy load operation of attribute 'interface_datanetworks' cannot proceed (Background on this error at: http://sqlalche.me/e/13/bhk3)
2022-11-29 12:24:40.714 69904 ERROR sysinv.objects.interface Traceback (most recent call last):
2022-11-29 12:24:40.714 69904 ERROR sysinv.objects.interface File "/usr/lib/python3/dist-packages/sysinv/db/sqlalchemy/objects.py", line 44, in wrapper
2022-11-29 12:24:40.714 69904 ERROR sysinv.objects.interface second_result = klass.from_db_object(first_result)
2022-11-29 12:24:40.714 69904 ERROR sysinv.objects.interface File "/usr/lib/python3/dist-packages/sysinv/objects/interface.py", line 178, in from_db_object
2022-11-29 12:24:40.714 69904 ERROR sysinv.objects.interface return cls._from_db_object(cls(), db_obj)
2022-11-29 12:24:40.714 69904 ERROR sysinv.objects.interface File "/usr/lib/python3/dist-packages/sysinv/objects/base.py", line 478, in _from_db_object
2022-11-29 12:24:40.714 69904 ERROR sysinv.objects.interface cls_object[field] = db_object[field]
2022-11-29 12:24:40.714 69904 ERROR sysinv.objects.interface TypeError: list indices must be integers or slices, not str
2022-11-29 12:24:40.714 69904 ERROR sysinv.objects.interface
2022-11-29 12:24:40.714 69904 ERROR sysinv.objects.interface During handling of the above exception, another exception occurred:
2022-11-29 12:24:40.714 69904 ERROR sysinv.objects.interface
2022-11-29 12:24:40.714 69904 ERROR sysinv.objects.interface Traceback (most recent call last):
2022-11-29 12:24:40.714 69904 ERROR sysinv.objects.interface File "/usr/lib/python3/dist-packages/sysinv/objects/interface.py", line 99, in get_datanetworks
2022-11-29 12:24:40.714 69904 ERROR sysinv.objects.interface if hasattr(db_object, 'interface_datanetworks'):
2022-11-29 12:24:40.714 69904 ERROR sysinv.objects.interface File "/usr/lib/python3/dist-packages/sqlalchemy/orm/attributes.py", line 294, in __get__
2022-11-29 12:24:40.714 69904 ERROR sysinv.objects.interface return self.impl.get(instance_state(instance), dict_)
2022-11-29 12:24:40.714 69904 ERROR sysinv.objects.interface File "/usr/lib/python3/dist-packages/sqlalchemy/orm/attributes.py", line 730, in get
2022-11-29 12:24:40.714 69904 ERROR sysinv.objects.interface value = self.callable_(state, passive)
2022-11-29 12:24:40.714 69904 ERROR sysinv.objects.interface File "/usr/lib/python3/dist-packages/sqlalchemy/orm/strategies.py", line 717, in _load_for_state
2022-11-29 12:24:40.714 69904 ERROR sysinv.objects.interface raise orm_exc.DetachedInstanceError(
2022-11-29 12:24:40.714 69904 ERROR sysinv.objects.interface sqlalchemy.orm.exc.DetachedInstanceError: Parent instance <VirtualInterfaces at 0x7f262633c700> is not bound to a Session; lazy load operation of attribute 'interface_datanetworks' cannot proceed (Background on this error at: http://sqlalche.me/e/13/bhk3)
2022-11-29 12:24:40.714 69904 ERROR sysinv.objects.interface

Test Activity
-------------
Developer Testing

Workaround
----------
N/A

Ghada Khalil (gkhalil)
tags: added: stx.config stx.distro.openstack
Changed in starlingx:
importance: Undecided → Low
Changed in starlingx:
assignee: nobody → Lucas de Ataides Barreto (ldeataid)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to config (master)

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

Changed in starlingx:
status: New → In Progress
tags: added: stx.9.0
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to config (master)

Reviewed: https://review.opendev.org/c/starlingx/config/+/884527
Committed: https://opendev.org/starlingx/config/commit/c64a8f36a4132dd74c5f0a06687b5a1201884b0b
Submitter: "Zuul (22348)"
Branch: master

commit c64a8f36a4132dd74c5f0a06687b5a1201884b0b
Author: Lucas de Ataides <email address hidden>
Date: Fri May 26 13:54:27 2023 -0300

    Add joined query to the InterfaceDataNetworks model

    When performing actions on STX-Openstack (apply, re-apply), sysinv logs
    get filled with a "DetachedInstanceError" message. This was already
    found previously and fixed by [1], but it looks like that isn't working
    for the STX-Openstack application, when the app is applied (or
    re-applied), Neutron needs to fetch some information about the
    interfaces' data networks, which is throwing this DetachedInstanceError
    message.

    Checking the SQLAlchemy documentation [2], it looks like lazy load can
    be allowed via a relationship parameter on the model, which fits this
    case since the VirtualInterfaces (Interface) model needs to get
    information of the InterfaceDataNetwork model.

    This was also previously done for the InterfaceNetworks model on [3]

    This change allows the lazy load of the InterfaceDataNetwork model so
    no error messages are logged to sysinv.

    [1] https://review.opendev.org/c/starlingx/config/+/826340
    [2] https://docs.sqlalchemy.org/en/14/orm/loading_relationships.html
    [3] https://review.opendev.org/c/starlingx/config/+/657645

    Test Plan:
    PASS - Build sysinv package
    PASS - Build ISO with new sysinv package
    PASS - Install and bootstrap an AIO-SX machine
    PASS - Perform a lock/unlock on an AIO-SX machine
    PASS - Apply STX-Openstack app
    PASS - Re-apply STX-Openstack app
    PASS - Visual inspection of sysinv.log shows nothing unusual

    Closes-Bug: 1998512

    Change-Id: Ic5b168e1a01dc53aa3f8658547c1f4776e681cdc
    Signed-off-by: Lucas de Ataides <email address hidden>

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