Duplicate selector in top file gives unhelpful traceback
salt 2014.7.0-n/a-9da5d13 (Helium)
top.sls:
'role:foo':
- match: grain
- foo
'role:foo':
- match: grain
- something.foo
Passed invalid arguments: can't serialize ConstructorError()
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/salt/cli/caller.py", line 129, in call
ret['return'] = func(*args, **kwargs)
File "/usr/lib/python2.7/dist-packages/salt/modules/state.py", line 343, in highstate
serial.dump(ret, fp_)
File "/usr/lib/python2.7/dist-packages/salt/payload.py", line 149, in dump
fn_.write(self.dumps(msg))
File "/usr/lib/python2.7/dist-packages/salt/payload.py", line 115, in dumps
return msgpack.dumps(msg)
File "_packer.pyx", line 259, in msgpack._packer.packb (msgpack/_packer.cpp:259)
File "_packer.pyx", line 184, in msgpack._packer.Packer.pack (msgpack/_packer.cpp:184)
File "_packer.pyx", line 159, in msgpack._packer.Packer._pack (msgpack/_packer.cpp:159)
File "_packer.pyx", line 159, in msgpack._packer.Packer._pack (msgpack/_packer.cpp:159)
File "_packer.pyx", line 179, in msgpack._packer.Packer._pack (msgpack/_packer.cpp:179)
TypeError: can't serialize ConstructorError()
Hi @johtso. I too dislike these sorts of unhelpful errors and I like it when we can get these cleaned up. Many thanks!
I can't seem to replicate this at all. Could you paste the exact top file you're using and the command that you're running to produce this error? A salt --versions-report would be helpful as well. Thanks!
Just ran into the same issue on salt-call 2014.1.13 (Hydrogen) Had two definitions in top.sls for minion like this: 'qa-cdh51-slave*':
Error on minion: Passed invalid arguments: can't serialize ConstructorError()
@sambanshee can you give us the exact top file you're using? That will be very helpful in trying to replicate this issue.
Also, if you're able to easily test this on a newer release, we cut 2014.7.0 earlier this week, and there have been many changes and improvements on this release. It's still in the packaging phase, but we should be officially announcing soon, and I am curious if this is still an issue.
I observed the same issue on 2014.7.1. Basically, any top.sls file with ID duplicates ends with such an error, e.g.:
base:
'*':
- cmd1
'*':
- cmd2
When I run salt-call state.show_top from a minion (2014.7.1) it ends with exception:
[DEBUG ] Rendered data from file: /var/cache/salt/minion/files/base/top.sls:
base:
'*':
- cmd1
'*':
- cmd2
[ERROR ] An un-handled exception was caught by salt's global exception handler:
SaltRenderError: Conflicting ID '*'
Traceback (most recent call last):
File "/usr/bin/salt-call", line 11, in <module>
salt_call()
File "/usr/lib/python2.6/site-packages/salt/scripts.py", line 123, in salt_call
client.run()
File "/usr/lib/python2.6/site-packages/salt/cli/__init__.py", line 420, in run
caller.run()
File "/usr/lib/python2.6/site-packages/salt/cli/caller.py", line 225, in run
ret = self.call()
File "/usr/lib/python2.6/site-packages/salt/cli/caller.py", line 129, in call
ret['return'] = func(*args, **kwargs)
File "/usr/lib/python2.6/site-packages/salt/modules/state.py", line 801, in show_top
top_ = st_.get_top()
File "/usr/lib/python2.6/site-packages/salt/state.py", line 2336, in get_top
tops = self.get_tops()
File "/usr/lib/python2.6/site-packages/salt/state.py", line 2213, in get_tops
saltenv=saltenv
File "/usr/lib/python2.6/site-packages/salt/template.py", line 84, in compile_template
ret = render(input_data, saltenv, sls, **render_kwargs)
File "/usr/lib/python2.6/site-packages/salt/renderers/yaml.py", line 54, in render
raise SaltRenderError(exc)
SaltRenderError: Conflicting ID '*'
Traceback (most recent call last):
File "/usr/bin/salt-call", line 11, in <module>
salt_call()
File "/usr/lib/python2.6/site-packages/salt/scripts.py", line 123, in salt_call
client.run()
File "/usr/lib/python2.6/site-packages/salt/cli/__init__.py", line 420, in run
caller.run()
File "/usr/lib/python2.6/site-packages/salt/cli/caller.py", line 225, in run
ret = self.call()
File "/usr/lib/python2.6/site-packages/salt/cli/caller.py", line 129, in call
ret['return'] = func(*args, **kwargs)
File "/usr/lib/python2.6/site-packages/salt/modules/state.py", line 801, in show_top
top_ = st_.get_top()
File "/usr/lib/python2.6/site-packages/salt/state.py", line 2336, in get_top
tops = self.get_tops()
File "/usr/lib/python2.6/site-packages/salt/state.py", line 2213, in get_tops
saltenv=saltenv
File "/usr/lib/python2.6/site-packages/salt/template.py", line 84, in compile_template
ret = render(input_data, saltenv, sls, **render_kwargs)
File "/usr/lib/python2.6/site-packages/salt/renderers/yaml.py", line 54, in render
raise SaltRenderError(exc)
salt.exceptions.SaltRenderError: Conflicting ID '*'
When I run salt-call state.highstate it ends with misleading error message:
[DEBUG ] Rendered data from file: /var/cache/salt/minion/files/base/top.sls:
base:
'*':
- cmd1
'*':
- cmd2
Passed invalid arguments: can't serialize ConstructorError()
Traceback (most recent call last):
File "/usr/lib/python2.6/site-packages/salt/cli/caller.py", line 129, in call
ret['return'] = func(*args, **kwargs)
File "/usr/lib/python2.6/site-packages/salt/modules/state.py", line 344, in highstate
serial.dump(ret, fp_)
File "/usr/lib/python2.6/site-packages/salt/payload.py", line 149, in dump
fn_.write(self.dumps(msg))
File "/usr/lib/python2.6/site-packages/salt/payload.py", line 139, in dumps
return msgpack.dumps(odict_encoder(msg))
File "_msgpack.pyx", line 172, in msgpack._msgpack.packb (msgpack/_msgpack.c:2375)
File "_msgpack.pyx", line 152, in msgpack._msgpack.Packer.pack (msgpack/_msgpack.c:2064)
File "_msgpack.pyx", line 154, in msgpack._msgpack.Packer.pack (msgpack/_msgpack.c:1972)
File "_msgpack.pyx", line 137, in msgpack._msgpack.Packer._pack (msgpack/_msgpack.c:1685)
File "_msgpack.pyx", line 137, in msgpack._msgpack.Packer._pack (msgpack/_msgpack.c:1685)
File "_msgpack.pyx", line 149, in msgpack._msgpack.Packer._pack (msgpack/_msgpack.c:1886)
TypeError: can't serialize ConstructorError()
I can also confirm this issue with the latest stable release 2014.7.5.
Thanks for the bump here @dsumsky. I can confirm this behavior in 2014.7.5 as well. Some of the stacktraces are getting hidden a little better on 2014.7.5 than they were in 2014.7.1, but the errors aren't very helpful.
I tested at the current HEAD of 2014.7 as well as v2014.7.5. I have a local minion running on a master and I also tried salt-call commands. state.highstate doesn't show the stacktrace in both methods (salt vs salt-call) but state.show_top does stacktrace with the same final error. Here's my reproduction steps:
# cat /srv/salt/top.sls
base:
'nt-*':
- foo
'nt-*':
- bar
# salt --versions
Salt: 2014.7.5-120-gb0f4b28
Python: 2.7.6 (default, Mar 22 2014, 22:59:56)
Jinja2: 2.7.3
M2Crypto: 0.21.1
msgpack-python: 0.4.4
msgpack-pure: Not Installed
pycrypto: 2.6.1
libnacl: Not Installed
PyYAML: 3.11
ioflo: Not Installed
PyZMQ: 14.0.1
RAET: Not Installed
ZMQ: 4.0.4
Mako: 0.9.1
# salt-call --local state.highstate
[INFO ] Loading fresh modules for state activity
[INFO ] Fetching file from saltenv 'base', ** skipped ** latest already in cache 'salt://top.sls'
Passed invalid arguments: Cannot serialize ConstructorError()
# salt-call --local state.show_top
[INFO ] Loading fresh modules for state activity
[INFO ] Fetching file from saltenv 'base', ** skipped ** latest already in cache 'salt://top.sls'
[ERROR ] An un-handled exception was caught by salt's global exception handler:
SaltRenderError: Conflicting ID 'nt-*'
Traceback (most recent call last):
File "/usr/local/bin/salt-call", line 11, in <module>
salt_call()
File "/root/SaltStack/salt/salt/scripts.py", line 123, in salt_call
client.run()
File "/root/SaltStack/salt/salt/cli/__init__.py", line 422, in run
caller.run()
File "/root/SaltStack/salt/salt/cli/caller.py", line 227, in run
ret = self.call()
File "/root/SaltStack/salt/salt/cli/caller.py", line 129, in call
ret['return'] = func(*args, **kwargs)
File "/root/SaltStack/salt/salt/modules/state.py", line 801, in show_top
top_ = st_.get_top()
File "/root/SaltStack/salt/salt/state.py", line 2376, in get_top
tops = self.get_tops()
File "/root/SaltStack/salt/salt/state.py", line 2253, in get_tops
saltenv=saltenv
File "/root/SaltStack/salt/salt/template.py", line 84, in compile_template
ret = render(input_data, saltenv, sls, **render_kwargs)
File "/root/SaltStack/salt/salt/renderers/yaml.py", line 54, in render
raise SaltRenderError(exc)
SaltRenderError: Conflicting ID 'nt-*'
Traceback (most recent call last):
File "/usr/local/bin/salt-call", line 11, in <module>
salt_call()
File "/root/SaltStack/salt/salt/scripts.py", line 123, in salt_call
client.run()
File "/root/SaltStack/salt/salt/cli/__init__.py", line 422, in run
caller.run()
File "/root/SaltStack/salt/salt/cli/caller.py", line 227, in run
ret = self.call()
File "/root/SaltStack/salt/salt/cli/caller.py", line 129, in call
ret['return'] = func(*args, **kwargs)
File "/root/SaltStack/salt/salt/modules/state.py", line 801, in show_top
top_ = st_.get_top()
File "/root/SaltStack/salt/salt/state.py", line 2376, in get_top
tops = self.get_tops()
File "/root/SaltStack/salt/salt/state.py", line 2253, in get_tops
saltenv=saltenv
File "/root/SaltStack/salt/salt/template.py", line 84, in compile_template
ret = render(input_data, saltenv, sls, **render_kwargs)
File "/root/SaltStack/salt/salt/renderers/yaml.py", line 54, in render
raise SaltRenderError(exc)
salt.exceptions.SaltRenderError: Conflicting ID 'nt-*'
# salt nt-master state.highstate
nt-master:
TypeError encountered executing state.highstate: Cannot serialize ConstructorError(). See debug log for more info.
# salt nt-master state.show_top
nt-master:
The minion function caused an exception: Traceback (most recent call last):
File "/root/SaltStack/salt/salt/minion.py", line 1020, in _thread_return
return_data = func(*args, **kwargs)
File "/root/SaltStack/salt/salt/modules/state.py", line 801, in show_top
top_ = st_.get_top()
File "/root/SaltStack/salt/salt/state.py", line 2376, in get_top
tops = self.get_tops()
File "/root/SaltStack/salt/salt/state.py", line 2253, in get_tops
saltenv=saltenv
File "/root/SaltStack/salt/salt/template.py", line 84, in compile_template
ret = render(input_data, saltenv, sls, **render_kwargs)
File "/root/SaltStack/salt/salt/renderers/yaml.py", line 54, in render
raise SaltRenderError(exc)
SaltRenderError: Conflicting ID 'nt-*'
hi!
~# salt-minion --versions-report
Salt: 2015.5.0
Python: 2.6.5 (r265:79063, Oct 1 2012, 22:04:36)
Jinja2: 2.7-dev
M2Crypto: 0.20.1
msgpack-python: 0.1.9.final
msgpack-pure: Not Installed
pycrypto: 2.6
libnacl: Not Installed
PyYAML: 3.09
ioflo: Not Installed
PyZMQ: 13.0.0
RAET: Not Installed
ZMQ: 3.2.2
Mako: Not Installed
if top.sls contains conflict id
~# salt-call state.highstate test=True -l trace
...
[DEBUG ] LazyLoaded highstate.output
[DEBUG ] Traceback (most recent call last):
File "/usr/lib/pymodules/python2.6/salt/output/__init__.py", line 46, in try_printout
return get_printout(out, opts)(data).rstrip()
File "/usr/lib/pymodules/python2.6/salt/output/highstate.py", line 84, in output
return _format_host(host, hostdata)[0]
File "/usr/lib/pymodules/python2.6/salt/output/highstate.py", line 221, in _format_host
ret['comment'] = ret['comment'].decode('utf-8')
AttributeError: 'ConstructorError' object has no attribute 'decode'
[DEBUG ] LazyLoaded nested.output
[TRACE ] data = {'local': {'no_|-states_|-states_|-None': {'comment': ConstructorError(), '__run_num__': 0, 'changes': {}, 'result': False, 'name': 'No States'}}}
local:
----------
no_|-states_|-states_|-None:
----------
__run_num__:
0
changes:
----------
comment:
name:
No States
result:
False
I have fixed these stacktraces in #27426. Please give that a try and make sure I didn't miss anything.
@sakateka I am not sure if the bug you're seeing is the same as this one - it might make sense to open a new issue about that.