Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

problem using colons in keys #64

Open
dvandok opened this issue Jan 23, 2017 · 4 comments
Open

problem using colons in keys #64

dvandok opened this issue Jan 23, 2017 · 4 comments
Assignees

Comments

@dvandok
Copy link

dvandok commented Jan 23, 2017

I use a networking component for specifying default routes in ipv6, using the routing target as the key in yaml, as such:

parameters:
  network:
    routes:
      '::0/0':
        via: ${network:ipv6:gateway}

If I do this on the highest level (node level) it's ok; but if it is done via class inclusion I get the following error. Given the double escape symbols I'm suspecting there is an issue with the use of ':' as part of the key.

Traceback (most recent call last):
  File "/usr/bin/reclass-salt", line 9, in <module>
    load_entry_point('reclass==1.4.1', 'console_scripts', 'reclass-salt')()
  File "/usr/lib/python2.7/dist-packages/reclass/adapters/salt.py", line 105, in cli
    class_mappings=class_mappings)
  File "/usr/lib/python2.7/dist-packages/reclass/adapters/salt.py", line 38, in ext_pillar
    data = reclass.nodeinfo(minion_id)
  File "/usr/lib/python2.7/dist-packages/reclass/core.py", line 136, in nodeinfo
    return self._nodeinfo_as_dict(nodename, self._nodeinfo(nodename))
  File "/usr/lib/python2.7/dist-packages/reclass/core.py", line 122, in _nodeinfo
    ret.interpolate()
  File "/usr/lib/python2.7/dist-packages/reclass/datatypes/entity.py", line 65, in interpolate
    self._parameters.interpolate()
  File "/usr/lib/python2.7/dist-packages/reclass/datatypes/parameters.py", line 180, in interpolate
    self._interpolate_inner(path, refvalue)
  File "/usr/lib/python2.7/dist-packages/reclass/datatypes/parameters.py", line 214, in _interpolate_inner
    path.set_value(self._base, new)
  File "/usr/lib/python2.7/dist-packages/reclass/utils/dictpath.py", line 125, in set_value
    self._get_innermost_container(base)[self._get_key()] = value
  File "/usr/lib/python2.7/dist-packages/reclass/utils/dictpath.py", line 106, in _get_innermost_container
    container = container[i]
KeyError: '\\:\\:0/0'
@lottspot
Copy link
Collaborator

I'll have to dig into reproducing this one a little more, but the stack trace seems to indicate that this is caused by the way the interpolation syntax is constructed (which makes it curious that this issue would come up on a string which is not supposed to be interpolated). Thanks for the report.

@lottspot lottspot self-assigned this Jan 23, 2017
@dvandok
Copy link
Author

dvandok commented Jan 24, 2017

OK, here's the most minimalist example I can still reproduce the error with. This is a node definition, say example.yml:

parameters:
  p: v
  ':':
    bad: ${p}

The error goes away when I replace ${p} by a static value.

HTH

@lottspot
Copy link
Collaborator

That does help, and seems to confirm the indication of the initial traceback that this issue exists along the interpolation code path.

@dvandok
Copy link
Author

dvandok commented Jan 25, 2017

More digging around, I found that bluntly removing the call to escape_string in DictPath::new_subpath()
https://github.com/madduck/reclass/blob/master/reclass/utils/dictpath.py#L117
gets rid of the problem. The escaping seems to be used for disambiguating the string representation of a DictPath, but is not required as the internals of DictPath keep a list anyway.

Not entirely sure this doesn't break something else, but the test suite still works.

AndrewPickford pushed a commit to AndrewPickford/reclass that referenced this issue Sep 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants