Dollar sign ($) in config value causes parsing error

Bug #1259729 reported by Craig Jellick on 2013-12-10
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
oslo-incubator
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.

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)
Changed in oslo:
status: Confirmed → In Progress
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) on 2014-01-23
Changed in oslo:
status: Fix Committed → Fix Released
Thierry Carrez (ttx) on 2014-04-17
Changed in oslo:
milestone: icehouse-2 → 2014.1
Haifeng.Yan (yanheven) wrote :

not a perfect solusion,

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers