missing global_request_id in neutron_lib context from_dict method

Bug #1933802 reported by Shuai Qian
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
neutron
Fix Released
Low
Unassigned

Bug Description

code:
@classmethod
def from_dict(cls, values):
    return cls(user_id=values.get('user_id', values.get('user')),
    ¦ ¦ ¦ tenant_id=values.get('tenant_id', values.get('project_id')),
    ¦ ¦ ¦ is_admin=values.get('is_admin'),
    ¦ ¦ ¦ roles=values.get('roles'),
    ¦ ¦ ¦ timestamp=values.get('timestamp'),
    ¦ ¦ ¦ request_id=values.get('request_id'),
    ¦ ¦ ¦ #global_request_id=values.get('global_request_id'),
    ¦ ¦ ¦ tenant_name=values.get('tenant_name'),
    ¦ ¦ ¦ user_name=values.get('user_name'),
    ¦ ¦ ¦ auth_token=values.get('auth_token'))

project: neutron_lib
path: neutron_lib/context.py

please note the comment line, which should have been passed.

Shuai Qian (qianshuai)
Changed in neutron:
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to neutron-lib (master)
Revision history for this message
Miguel Lavalle (minsel) wrote :

Why is this a bug? I looked in the entire Neutron code. global_request_id is only used once here: https://github.com/openstack/neutron/blob/a33588b08639bd4bb78e632eb1fb2600a96aeb44/neutron/notifiers/nova.py#L83. And it is generated. So how is the absence of global_request_id in the Neutron context affecting you or your deployment?

Changed in neutron:
status: In Progress → Opinion
importance: Undecided → Low
Revision history for this message
Shuai Qian (qianshuai) wrote :

Actually, global_request_id is used everywhere, cuz many many logs get global_request_id and request_id from current context, and the context is always in the thread.

I'm going to string all logs related to a action(e.g. creating server) together by one global_request_id.
So, I must pass the global_request_id to new context when two threads interact.

"from_dict" -- the method generating context -- does not reveive global_request_id, but old context does pass it.

Revision history for this message
Akihiro Motoki (amotoki) wrote :

I think the issue reported here is valid. Context class in neutron-lib inherits Context in oslo.context. Several new fields were added in oslo.context Context.from_dict(), but neutron-lib Context does not catch up with these changes. I think this is the point of this bug report.

tags: added: lib
Revision history for this message
Shuai Qian (qianshuai) wrote :

YES,that's it! @Akihiro Motoki

Akihiro Motoki (amotoki)
Changed in neutron:
status: Opinion → Confirmed
Revision history for this message
OpenStack Infra (hudson-openstack) wrote :
Changed in neutron:
status: Confirmed → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on neutron-lib (master)

Change abandoned by "Shuai Qian <email address hidden>" on branch: master
Review: https://review.opendev.org/c/openstack/neutron-lib/+/798261
Reason: another commit

Revision history for this message
Slawek Kaplonski (slaweq) wrote : auto-abandon-script

This bug has had a related patch abandoned and has been automatically un-assigned due to inactivity. Please re-assign yourself if you are continuing work or adjust the state as appropriate if it is no longer valid.

Changed in neutron:
status: In Progress → New
tags: added: timeout-abandon
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on neutron-lib (master)

Change abandoned by "Slawek Kaplonski <email address hidden>" on branch: master
Review: https://review.opendev.org/c/openstack/neutron-lib/+/798815
Reason: This review is > 4 weeks without comment, and failed Zuul jobs the last time it was checked. We are abandoning this for now. Feel free to reactivate the review by pressing the restore button and leaving a 'recheck' comment to get fresh test results.

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

Reviewed: https://review.opendev.org/c/openstack/neutron-lib/+/859813
Committed: https://opendev.org/openstack/neutron-lib/commit/9ecd5995b6c598cee931087bf13fdd166f404034
Submitter: "Zuul (22348)"
Branch: master

commit 9ecd5995b6c598cee931087bf13fdd166f404034
Author: Kiran Pawar <email address hidden>
Date: Thu Sep 29 08:40:30 2022 +0000

    Use oslo_context.from_dict() for context generation

    Use RequestContext.from_dict in oslo_context to generate context, and
    add/update needed attr such as user_id, tenant_id, tenant_name and
    timestamp.

    Closes-bug: #1933802
    Change-Id: I0527eb5fa8d32d97ca45e44d1b154b6529b3f847

Changed in neutron:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/neutron-lib 3.2.0

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