magnum pod-create fails with KeyError exception for user_name

Bug #1464376 reported by Dane LeBlanc
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Magnum
Fix Released
Undecided
Dane LeBlanc

Bug Description

If DevStack is used to instantiate the magnum plugin, and the devstack localrc/local.conf has the default values for:
   LOG_COLOR (default value = True)
   SYSLOG (default value = False)
then a magnum pod-create operation fails with a 500 error code (invalid syntax (line 2)), and the m-api.log log file
shows tracebacks for a "KeyError: 'user_name'" exception.

For example:

openstack@devstack-40:~/kubernetes/examples/redis$ magnum pod-create --manifest ./redis-master.yaml --bay testbay
ERROR: invalid syntax (line 2) (HTTP 500)
openstack@devstack-40:~/kubernetes/examples/redis$

The m-api.log file shows this traceback:

2015-06-08 10:31:33.707 [00;32mDEBUG magnum.cmd.api [[00;36m-[00;32m] [01;35m[00;32moslo_versionedobjects.fatal_exception_format_errors = False[00m [00;33mfrom (pid=16976) log_opt_values /usr/local/lib/python2.7/dist-packages/oslo_config/cfg.py:2221[00m
2015-06-08 10:31:33.707 [00;32mDEBUG magnum.cmd.api [[00;36m-[00;32m] [01;35m[00;32m********************************************************************************[00m [00;33mfrom (pid=16976) log_opt_values /usr/local/lib/python2.7/dist-packages/oslo_config/cfg.py:2223[00m
2015-06-08 10:31:33.707 [00;36mINFO magnum.cmd.api [[00;36m-[00;36m] [01;35m[00;36mserving on http://10.86.7.40:9511[00m
10.86.7.40 - - [08/Jun/2015 10:31:34] "GET / HTTP/1.1" 200 318
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 session.py, line 195
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'

Dane LeBlanc (leblancd)
Changed in magnum:
assignee: nobody → Dane LeBlanc (leblancd)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to magnum (master)

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

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

Reviewed: https://review.openstack.org/190801
Committed: https://git.openstack.org/cgit/openstack/magnum/commit/?id=617b772e556a9cf874031a9068a9e31156242aa0
Submitter: Jenkins
Branch: master

commit 617b772e556a9cf874031a9068a9e31156242aa0
Author: Dane LeBlanc <email address hidden>
Date: Thu Jun 11 16:01:22 2015 -0400

    Modify magnum api context to use user_name and project_name

    Problem description:
    If DevStack is used to instantiate the magnum plugin, and the
    devstack localrc/local.conf has the default values for:
       LOG_COLOR (default value = True)
       SYSLOG (default value = False)
    then upon startup (i.e. running DevStack's stack.sh), the magnum devstack
    lib calls the DevStack common setup_colorized_logging function, but
    without passing the optional 'project_var' and 'user_var' arguments to
    this function. As a result, the setup_colorized_logging
    function uses its default values of "user_name" and "project_name"
    when it defines the logging_context_format_string (which in turn gets
    configured in /etc/magnum/magnum.conf). The problem is that "user_name"
    and "project_name" are not defined in the API context used by Magnum,
    so that whenever the magnum plugin does a logging call, a KeyError
    exception for the non-existant key "user_name" is generated.

    Fix description:
    The fix is to modify the Magnum context to use "user_name" and
    "project_name" attributes to be consistent with the default context
    format string set up by DevStack.

    Change-Id: Ia0c34899609735ff9d8b4597101e004e2684657e
    Closes-Bug: #1464376

Changed in magnum:
status: In Progress → Fix Committed
Adrian Otto (aotto)
Changed in magnum:
milestone: none → mitaka-1
status: Fix Committed → 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.