Skip to content
This repository has been archived by the owner on Jul 14, 2021. It is now read-only.

check name moved under metadata dictionary #21

Closed
pfak opened this issue Dec 8, 2018 · 2 comments
Closed

check name moved under metadata dictionary #21

pfak opened this issue Dec 8, 2018 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@pfak
Copy link

pfak commented Dec 8, 2018

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 jaredledvina self-assigned this Dec 8, 2018
@jaredledvina
Copy link
Owner

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 jaredledvina added the bug Something isn't working label Dec 8, 2018
pfak added a commit to pfak/sensu-go-ansible that referenced this issue Dec 8, 2018
metadata dict was created to contain name, namespace in the
first stable release of sensu-go. move name reference to the
dict.

this fixes issue jaredledvina#21
@jaredledvina
Copy link
Owner

Should be good now via #89

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants