Page MenuHomePhabricator

Traceback in icinga-status 'Host' object has no attribute 'downtime'
Closed, ResolvedPublic

Description

icinga-status currently runs into a traceback, which breaks the reboot cookbook (since it executes that script):

jmm@alert1001:~$ /usr/local/bin/icinga-status -j auth1002.eqiad.wmnet
Traceback (most recent call last):
  File "/usr/local/bin/icinga-status", line 286, in <module>
    raise SystemExit(main())
  File "/usr/local/bin/icinga-status", line 281, in main
    print(json_dumps(hosts, default=lambda o: o.to_json()))
  File "/usr/lib/python3.7/json/__init__.py", line 238, in dumps
    **kw).encode(obj)
  File "/usr/lib/python3.7/json/encoder.py", line 199, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "/usr/lib/python3.7/json/encoder.py", line 257, in iterencode
    return _iterencode(o, 0)
  File "/usr/local/bin/icinga-status", line 281, in <lambda>
    print(json_dumps(hosts, default=lambda o: o.to_json()))
  File "/usr/local/bin/icinga-status", line 107, in __json__
    'downtime': self.downtime,
AttributeError: 'Host' object has no attribute 'downtime'

Event Timeline

Change 647208 had a related patch set uploaded (by Jbond; owner: John Bond):
[operations/puppet@production] icinga_status: fix type downtimed != downtime

https://gerrit.wikimedia.org/r/647208

Change 647208 merged by Jbond:
[operations/puppet@production] icinga_status: fix type downtimed != downtime

https://gerrit.wikimedia.org/r/647208

This should be fixed now please re open if yu still see issues

$ /usr/local/bin/icinga-status -j auth1002.eqiad.wmnet        
{"auth1002": {"name": "auth1002", "state": "UP", "optimal": true, "failed_services": [], "downtimed": false, "notifications_enabled": true}}
jbond claimed this task.

This should be fixed now please re open if yu still see issues

Spoke to soon we now see this issue

Exception raised while executing cookbook sre.hosts.reboot-single:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/spicerack/_menu.py", line 226, in run
    raw_ret = runner.run()
  File "/usr/lib/python3/dist-packages/spicerack/_module_api.py", line 19, in run
    return self._run(self.args, self.spicerack)
  File "/srv/deployment/spicerack/cookbooks/sre/hosts/reboot-single.py", line 77, in run
    icinga_ok = icinga.get_status(remote_host.hosts).optimal
  File "/usr/lib/python3/dist-packages/spicerack/icinga.py", line 291, in get_status
    hosts_status[hostname] = HostStatus(**host_status)
TypeError: __init__() got an unexpected keyword argument 'downtimed'
END (FAIL) - Cookbook sre.hosts.reboot-single (exit_code=99)

Change 647243 had a related patch set uploaded (by Jbond; owner: John Bond):
[operations/puppet@production] icinga_status: remove values from json until support added to spicerack

https://gerrit.wikimedia.org/r/647243

Change 647245 had a related patch set uploaded (by Jbond; owner: John Bond):
[operations/software/spicerack@master] icinga: add support for downtimed and notifications_enabled parameters

https://gerrit.wikimedia.org/r/647245

Change 647243 merged by Jbond:
[operations/puppet@production] icinga_status: remove values from json until support added to spicerack

https://gerrit.wikimedia.org/r/647243

I have pushed a patch which should removes the invalid parameters from the json output until spicerack is patched. This should hopefully fix the cookbook

Change 647245 merged by jenkins-bot:
[operations/software/spicerack@master] icinga: add support for downtimed and notifications_enabled parameters

https://gerrit.wikimedia.org/r/647245

I fix has been applied to both spicerack and the icingas_status script. I have checked things work with the following and all looks good to me. please re-open if you still see issues

sudo cookbook sre.hosts.reboot-single pki1001.eqiad.wmnet