saltstack / salt

Software to automate the management and configuration of any infrastructure or application at scale. Get access to the Salt software package repository here:
https://repo.saltproject.io/
Apache License 2.0
14.15k stars 5.47k forks source link

Route53: [ERROR ] Nested output failed #29121

Closed szwed closed 6 years ago

szwed commented 8 years ago

When running highstate with the following config first time:

    kafka-dns-route53-records:
      boto_route53.present:
        - name: {{ grains['id'] }}.example.com.
        - value: {{ salt['network.interfaces']()['eth0']['inet'][0]['address'] }}
        - zone: example.com.
        - ttl: 60
        - record_type: A
        - region: universal
        - keyid: XXX
        - key: XXX

I see these errors:

 [ERROR   ] Nested output failed:
 Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/salt/output/__init__.py", line 43, in try_printout
    return get_printout('nested', opts)(data).rstrip()
  File "/usr/lib/python2.7/dist-packages/salt/output/highstate.py", line 85, in output
    return _format_host(host, hostdata)[0]
  File "/usr/lib/python2.7/dist-packages/salt/output/highstate.py", line 129, in _format_host
    key=lambda k: data[k].get('__run_num__', 0)):
  File "/usr/lib/python2.7/dist-packages/salt/output/highstate.py", line 129, in <lambda>
    key=lambda k: data[k].get('__run_num__', 0)):
 AttributeError: 'str' object has no attribute 'get'
 [ERROR   ] Nested output failed:
 Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/salt/output/__init__.py", line 43, in try_printout
    return get_printout('nested', opts)(data).rstrip()
  File "/usr/lib/python2.7/dist-packages/salt/output/highstate.py", line 85, in output
    return _format_host(host, hostdata)[0]
  File "/usr/lib/python2.7/dist-packages/salt/output/highstate.py", line 129, in _format_host
    key=lambda k: data[k].get('__run_num__', 0)):
  File "/usr/lib/python2.7/dist-packages/salt/output/highstate.py", line 129, in <lambda>
    key=lambda k: data[k].get('__run_num__', 0)):
 AttributeError: 'str' object has no attribute 'get'
 [ERROR   ] Nested output failed:
 Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/salt/output/__init__.py", line 43, in try_printout
    return get_printout('nested', opts)(data).rstrip()
  File "/usr/lib/python2.7/dist-packages/salt/output/highstate.py", line 85, in output
    return _format_host(host, hostdata)[0]
  File "/usr/lib/python2.7/dist-packages/salt/output/highstate.py", line 137, in _format_host
    schanged, ctext = _format_changes(ret['changes'])
  File "/usr/lib/python2.7/dist-packages/salt/output/highstate.py", line 421, in _format_changes
    __opts__)
  File "/usr/lib/python2.7/dist-packages/salt/output/__init__.py", line 164, in out_format
    return try_printout(data, out, opts)
  File "/usr/lib/python2.7/dist-packages/salt/output/__init__.py", line 46, in try_printout
    return get_printout('raw', opts)(data).rstrip()
  File "/usr/lib/python2.7/dist-packages/salt/output/highstate.py", line 85, in output
    return _format_host(host, hostdata)[0]
  File "/usr/lib/python2.7/dist-packages/salt/output/highstate.py", line 129, in _format_host
    key=lambda k: data[k].get('__run_num__', 0)):
  File "/usr/lib/python2.7/dist-packages/salt/output/highstate.py", line 129, in <lambda>
    key=lambda k: data[k].get('__run_num__', 0)):
 AttributeError: 'str' object has no attribute 'get'
 [ERROR   ] Nested output failed: 
 Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/salt/output/__init__.py", line 43, in try_printout
    return get_printout('nested', opts)(data).rstrip()
  File "/usr/lib/python2.7/dist-packages/salt/output/highstate.py", line 85, in output
    return _format_host(host, hostdata)[0]
  File "/usr/lib/python2.7/dist-packages/salt/output/highstate.py", line 129, in _format_host
    key=lambda k: data[k].get('__run_num__', 0)):
  File "/usr/lib/python2.7/dist-packages/salt/output/highstate.py", line 129, in <lambda>
    key=lambda k: data[k].get('__run_num__', 0)):
 AttributeError: 'str' object has no attribute 'get'
 [ERROR   ] An un-handled exception was caught by salt's global exception handler: 
 AttributeError: 'str' object has no attribute 'get'
 Traceback (most recent call last):
  File "/usr/bin/salt", line 10, in <module>
    salt_main()
  File "/usr/lib/python2.7/dist-packages/salt/scripts.py", line 454, in salt_main
    client.run()
  File "/usr/lib/python2.7/dist-packages/salt/cli/salt.py", line 204, in run
    self._output_ret(ret_, out)
  File "/usr/lib/python2.7/dist-packages/salt/cli/salt.py", line 303, in _output_ret
    salt.output.display_output(ret, out, self.config)
  File "/usr/lib/python2.7/dist-packages/salt/output/__init__.py", line 86, in display_output
    display_data = try_printout(data, out, opts)
  File "/usr/lib/python2.7/dist-packages/salt/output/__init__.py", line 46, in try_printout
    return get_printout('raw', opts)(data).rstrip()
  File "/usr/lib/python2.7/dist-packages/salt/output/highstate.py", line 85, in output
    return _format_host(host, hostdata)[0]
  File "/usr/lib/python2.7/dist-packages/salt/output/highstate.py", line 137, in _format_host
    schanged, ctext = _format_changes(ret['changes'])
  File "/usr/lib/python2.7/dist-packages/salt/output/highstate.py", line 421, in _format_changes
    __opts__)
  File "/usr/lib/python2.7/dist-packages/salt/output/__init__.py", line 164, in out_format
    return try_printout(data, out, opts)
  File "/usr/lib/python2.7/dist-packages/salt/output/__init__.py", line 46, in try_printout
    return get_printout('raw', opts)(data).rstrip()
  File "/usr/lib/python2.7/dist-packages/salt/output/highstate.py", line 85, in output
    return _format_host(host, hostdata)[0]
  File "/usr/lib/python2.7/dist-packages/salt/output/highstate.py", line 129, in _format_host
    key=lambda k: data[k].get('__run_num__', 0)):
  File "/usr/lib/python2.7/dist-packages/salt/output/highstate.py", line 129, in <lambda>
    key=lambda k: data[k].get('__run_num__', 0)):
 AttributeError: 'str' object has no attribute 'get' 
 Traceback (most recent call last):
  File "/usr/bin/salt", line 10, in <module>
    salt_main()
  File "/usr/lib/python2.7/dist-packages/salt/scripts.py", line 454, in salt_main
    client.run()
  File "/usr/lib/python2.7/dist-packages/salt/cli/salt.py", line 204, in run
    self._output_ret(ret_, out)
  File "/usr/lib/python2.7/dist-packages/salt/cli/salt.py", line 303, in _output_ret
    salt.output.display_output(ret, out, self.config)
  File "/usr/lib/python2.7/dist-packages/salt/output/__init__.py", line 86, in display_output
    display_data = try_printout(data, out, opts)
  File "/usr/lib/python2.7/dist-packages/salt/output/__init__.py", line 46, in try_printout
    return get_printout('raw', opts)(data).rstrip()
  File "/usr/lib/python2.7/dist-packages/salt/output/highstate.py", line 85, in output
    return _format_host(host, hostdata)[0]
  File "/usr/lib/python2.7/dist-packages/salt/output/highstate.py", line 137, in _format_host
    schanged, ctext = _format_changes(ret['changes'])
  File "/usr/lib/python2.7/dist-packages/salt/output/highstate.py", line 421, in _format_changes
    __opts__)
  File "/usr/lib/python2.7/dist-packages/salt/output/__init__.py", line 164, in out_format
    return try_printout(data, out, opts)
  File "/usr/lib/python2.7/dist-packages/salt/output/__init__.py", line 46, in try_printout
    return get_printout('raw', opts)(data).rstrip()
  File "/usr/lib/python2.7/dist-packages/salt/output/highstate.py", line 85, in output
    return _format_host(host, hostdata)[0]
  File "/usr/lib/python2.7/dist-packages/salt/output/highstate.py", line 129, in _format_host
    key=lambda k: data[k].get('__run_num__', 0)):
  File "/usr/lib/python2.7/dist-packages/salt/output/highstate.py", line 129, in <lambda>
    key=lambda k: data[k].get('__run_num__', 0)):
 AttributeError: 'str' object has no attribute 'get'

The DNS entry is created and every next time I run highstate everything looks fine, but the errors are very confusing, especially when creating new environments.

Used Salt: salt 2015.8.1 (Beryllium)

jfindlay commented 8 years ago

@szwed, thanks for the report.

rallytime commented 8 years ago

@szwed This error looks to me like the first call of salt['network.interfaces']() is returning a string instead of a dictionary. Therefore the keys you've added to the end of that call can't be retrieved because you can't get keys from a string.

If you can figure out what the string is that is being returning on that first call in the initial highstate run, that should help determine whether this is a bug or expected behavior.

Otherwise, you may have to pull the value out earlier in the template with conditionals or write a simple custom module to massage the value to an expected format..

L4rS6 commented 8 years ago

I get exactly the same error if I specify highstate as outputter and there are open (GIT-Checkout) changes: salt '*' state.highstate --out highstate


      ID: user@hostname:repo
Function: git.latest
  Result: None
 Comment: Remote 'origin' would be fetched. Repository would be updated from 116d373 to 51dc339.
 Started: 15:38:48.638824
Duration: 1080.417 ms
 Changes:
          ----------
          revision:
              ----------
              new:
                  51dc339a155e5586764aae1793044e6a2a05d1d2
              old:
                  116d373122c14081555c1c55130a163e76297ee4
stale[bot] commented 6 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

If this issue is closed prematurely, please leave a comment and we will gladly reopen the issue.