check name moved under metadata dictionary
Closed this issue · 2 comments
pfak commented
Hello!
When trying to use sensu_go_check with ansible 2.7.4, and sensu-go 5.0.0 I get a module failure. Further debugging shows me:
root@vps216011:/tmp/.ansible-root/tmp/ansible-tmp-1544296249.73-277063188930744/debug_dir# /tmp/.ansible-root/tmp/ansible-tmp-1544296249.73-277063188930744/AnsiballZ_sensu_go_check.py execute
Traceback (most recent call last):
File "/tmp/.ansible-root/tmp/ansible-tmp-1544296249.73-277063188930744/AnsiballZ_sensu_go_check.py", line 261, in <module>
_ansiballz_main()
File "/tmp/.ansible-root/tmp/ansible-tmp-1544296249.73-277063188930744/AnsiballZ_sensu_go_check.py", line 248, in _ansiballz_main
exitcode = debug(sys.argv[1], zipped_mod, ANSIBALLZ_PARAMS)
File "/tmp/.ansible-root/tmp/ansible-tmp-1544296249.73-277063188930744/AnsiballZ_sensu_go_check.py", line 216, in debug
importer = imp.load_module('__main__', f, script_path, ('.py', 'r', imp.PY_SOURCE))
File "/usr/lib/python3.6/imp.py", line 235, in load_module
return load_source(name, filename, file)
File "/usr/lib/python3.6/imp.py", line 170, in load_source
module = _exec(spec, sys.modules[name])
File "<frozen importlib._bootstrap>", line 618, in _exec
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/tmp/.ansible-root/tmp/ansible-tmp-1544296249.73-277063188930744/debug_dir/__main__.py", line 191, in <module>
main()
File "/tmp/.ansible-root/tmp/ansible-tmp-1544296249.73-277063188930744/debug_dir/__main__.py", line 188, in main
run_module()
File "/tmp/.ansible-root/tmp/ansible-tmp-1544296249.73-277063188930744/debug_dir/__main__.py", line 141, in run_module
check_names = [check['name'] for check in checks]
File "/tmp/.ansible-root/tmp/ansible-tmp-1544296249.73-277063188930744/debug_dir/__main__.py", line 141, in <listcomp>
check_names = [check['name'] for check in checks]
KeyError: 'name'
Outputting 'check list' with json shows that 'name' key has moved under metadata dictionary:
[
{
"command": "/opt/sensu-plugins-ruby/embedded/bin/check-wsrep-ready.rb --user sensu",
"handlers": [],
"high_flap_threshold": 0,
"interval": 60,
"low_flap_threshold": 0,
"publish": true,
"runtime_assets": [],
"subscriptions": [
"percona-xtradb-cluster"
],
"proxy_entity_name": "",
"check_hooks": null,
"stdin": false,
"subdue": null,
"ttl": 0,
"timeout": 0,
"round_robin": false,
"output_metric_format": "",
"output_metric_handlers": [],
"env_vars": null,
"metadata": {
"name": "check-wsrep-ready",
"namespace": "default"
}
}
]
I changed:
check_names = [check['name'] for check in checks]
To:
check_names = [check['metadata']['name'] for check in checks]
But I'm not sure that's the proper approach, but it's working for me now!
jaredledvina commented
Hey @pfak,
Thanks! I haven't had time yet to try out v5 but, that looks correct to me. Mind throwing me a PR and I'll get it merged in for ya?
jaredledvina commented
Should be good now via #89