Dollar sign ($) in config value causes parsing error

Bug #1259729 reported by Craig Jellick
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
oslo-incubator
Fix Released
Medium
Davanum Srinivas (DIMS)

Bug Description

The value of one of our config properties, specifically metering_secret in /etc/ceilometer/ceilometer.conf, had a dollar sign ($) in it and this caused an error when starting the service because the value wasn't parsed properly:

Trace back:
 [-] no such option: k2
ceilometer Traceback (most recent call last):
   File "/usr/bin/ceilometer-collector", line 10, in <module>
     sys.exit(collector())
   File "/usr/lib/python2.6/site-packages/ceilometer/collector/service.py", line 299, in collector
     'ceilometer.collector')).wait()
   File "/usr/lib/python2.6/site-packages/ceilometer/openstack/common/service.py", line 162, in wait
     status, signo = self._wait_for_exit_or_signal()
   File "/usr/lib/python2.6/site-packages/ceilometer/openstack/common/service.py", line 137, in _wait_for_exit_or_si gnal
     CONF.log_opt_values(LOG, std_logging.DEBUG)
   File "/usr/lib/python2.6/site-packages/oslo/config/cfg.py", line 1949, in log_opt_values
     _sanitize(opt, getattr(group_attr, opt_name)))
   File "/usr/lib/python2.6/site-packages/oslo/config/cfg.py", line 2192, in __getattr__
     return self._conf._get(name, self._group)
   File "/usr/lib/python2.6/site-packages/oslo/config/cfg.py", line 1992, in _get
     value = self._substitute(self._do_get(name, group, namespace))
   File "/usr/lib/python2.6/site-packages/oslo/config/cfg.py", line 2048, in _substitute
     return tmpl.safe_substitute(self.StrSubWrapper(self))
   File "/usr/lib64/python2.6/string.py", line 205, in safe_substitute
     return self.pattern.sub(convert, self.template)
   File "/usr/lib64/python2.6/string.py", line 190, in convert
     return '%s' % (mapping[named],)
   File "/usr/lib/python2.6/site-packages/oslo/config/cfg.py", line 2266, in __getitem__
     value = getattr(self.conf, key)
   File "/usr/lib/python2.6/site-packages/oslo/config/cfg.py", line 1648, in __getattr__
     raise NoSuchOptError(name)
 NoSuchOptError: no such option: k2

So, the line in the config file looked something like this:
metering_secret=foobar-somethin$k2-foo-something
The oslo config parser must be interpreting regex characters or something. We tried quoting and escaping (via a backslash) to work around this issue, but neither worked.

Revision history for this message
Davanum Srinivas (DIMS) (dims-v) wrote :

We are using Python String templates so the escape is '$$' - please see http://docs.python.org/2/library/string.html#template-strings

I am adding a review to treat '\$' to be an escape as well

Changed in oslo:
status: New → Confirmed
importance: Undecided → Medium
assignee: nobody → Davanum Srinivas (DIMS) (dims-v)
Revision history for this message
Davanum Srinivas (DIMS) (dims-v) wrote :
Changed in oslo:
status: Confirmed → In Progress
Revision history for this message
ChangBo Guo(gcb) (glongwave) wrote :

dims,
I guess this can be worked round with metering_secret=foobar-somethin$$k2-foo-something.

I met this similar case like host_password=pw$$$$ ( the ture password is pw$$$$).

Changed in oslo:
status: In Progress → Fix Committed
Changed in oslo:
milestone: none → icehouse-2
Thierry Carrez (ttx)
Changed in oslo:
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in oslo:
milestone: icehouse-2 → 2014.1
Revision history for this message
Haifeng.Yan (yanheven) wrote :

not a perfect solusion,

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.