logging context format error

Bug #1456428 reported by chenglch
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Ironic
Expired
High
Unassigned
devstack
Invalid
Undecided
Thiago Paiva Brito
oslo.context
Invalid
Undecided
Unassigned

Bug Description

I use the latest devstack with LOG_COLOR enabled to setup the environment.
Devstack will set logging_context_format_string with a default value.

in devstack/functions setup_colorized_logging
iniset $conf_file $conf_section logging_context_format_string "%(asctime)s.%(msecs)03d %(color)s%(levelname)s %(name)s [%(request_id)s %("$user_var")s %("$project_var")s%(color)s] %(instance)s%(color)s%(message)s"
https://github.com/openstack-dev/devstack/blob/master/functions#L530

When I start the ironic conductor in the debug mode,
I will see the following message :
Traceback (most recent call last):
  File "/usr/lib/python2.7/logging/__init__.py", line 851, in emit
    msg = self.format(record)
  File "/usr/lib/python2.7/logging/__init__.py", line 724, in format
    return fmt.format(record)
  File "/usr/local/lib/python2.7/dist-packages/oslo_log/formatters.py", line 235, in format
    return logging.Formatter.format(self, record)
  File "/usr/lib/python2.7/logging/__init__.py", line 467, in format
    s = self._fmt % record.__dict__
KeyError: 'user_name'
Logged from file amqp.py, line 97
Traceback (most recent call last):
  File "/usr/lib/python2.7/logging/__init__.py", line 851, in emit
    msg = self.format(record)
  File "/usr/local/lib/python2.7/dist-packages/oslo_log/handlers.py", line 69, in format
    return logging.StreamHandler.format(self, record)
  File "/usr/lib/python2.7/logging/__init__.py", line 724, in format
    return fmt.format(record)
  File "/usr/local/lib/python2.7/dist-packages/oslo_log/formatters.py", line 235, in format
    return logging.Formatter.format(self, record)
  File "/usr/lib/python2.7/logging/__init__.py", line 467, in format
    s = self._fmt % record.__dict__
KeyError: 'user_name'
Logged from file amqp.py, line 97

Nova also set the logging_context_format_string in nova.conf with the default value, but no such message in the log file.

chenglch (chenglch)
Changed in ironic:
assignee: nobody → chenglch (chenglch)
Changed in ironic:
status: New → Confirmed
Changed in ironic:
status: Confirmed → Invalid
Changed in devstack:
status: New → Confirmed
assignee: nobody → Thiago Paiva Brito (thiagop)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to devstack (master)

Fix proposed to branch: master
Review: https://review.openstack.org/184568

Changed in devstack:
status: Confirmed → In Progress
chenglch (chenglch)
Changed in ironic:
status: Invalid → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to ironic (master)

Fix proposed to branch: master
Review: https://review.openstack.org/184714

Revision history for this message
Dmitry Tantsur (divius) wrote :

Shouldn't fix go to oslo.context instead?

Changed in ironic:
importance: Undecided → High
Revision history for this message
Thiago Paiva Brito (outbrito) wrote :

IMHO, Devstack should be adapted to work with Ironic and oslo_context, not the reverse. And I also think that inserting 'user_name' is duplicating the already existing 'user' injected by oslo_context.

Revision history for this message
chenglch (chenglch) wrote :

The 'user' and 'tenant' in oslo_context is ID value, 'user_name' is name string value. Maybe 'user_name' parameter in the context log is friendly purpose. Devstack can remove the default 'user_name' and 'project_name' parameters for ironic log context, but I think Ironic should add these parameters in context object like nova.

chenglch (chenglch)
Changed in ironic:
assignee: chenglch (chenglch) → nobody
status: In Progress → Confirmed
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on devstack (master)

Change abandoned by Thiago Paiva Brito (<email address hidden>) on branch: master
Review: https://review.openstack.org/184568
Reason: Hey Jim!

It appears that someone has already done that on the Ironic plugin. Abandoning this then.

Changed in oslo.context:
status: New → Incomplete
Revision history for this message
Pavlo Shchelokovskyy (pshchelo) wrote :

I am running fresh devstack with colorized logging (which is default if run in a proper/interactive terminal instead of CI) and do not see such errors.

Moving the bug to incomplete for Ironic and Invalid for DevStack (patch was abandoned and Ironic has moved to devstack plugin anyway).

Changed in ironic:
status: Confirmed → Incomplete
Changed in devstack:
status: In Progress → Invalid
Revision history for this message
Launchpad Janitor (janitor) wrote :

[Expired for Ironic because there has been no activity for 60 days.]

Changed in ironic:
status: Incomplete → Expired
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on ironic (master)

Change abandoned by Ruby Loo (<email address hidden>) on branch: master
Review: https://review.openstack.org/184714

Revision history for this message
Ruby Loo (rloo) wrote :

This bug has been around for awhile and I don't actually know whether there is an issue with oslo.context or not. Since it had been 'incomplete' anyway, I just changed it to invalid. Feel free to re-open or open a new bug if you have more details.

Changed in oslo.context:
status: Incomplete → Invalid
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.