PearsonEducation / Alarmageddon

Full-stack monitoring and alerting Python library.
Other
15 stars 10 forks source link

Slack publisher misnamed hook_url causes error in 1.0.4 #21

Open chris-skud opened 7 years ago

chris-skud commented 7 years ago

With the addition of internal logging, the Slack Publisher throws the following error:

Traceback (most recent call last):
  File "run_suite.py", line 66, in <module>
    test()
  File "/var/lib/jenkins/jobs/utx-system-monitors-production/workspace/.venv/local/lib/python2.7/site-packages/click/core.py", line 716, in __call__
    return self.main(*args, **kwargs)
  File "/var/lib/jenkins/jobs/utx-system-monitors-production/workspace/.venv/local/lib/python2.7/site-packages/click/core.py", line 696, in main
    rv = self.invoke(ctx)
  File "/var/lib/jenkins/jobs/utx-system-monitors-production/workspace/.venv/local/lib/python2.7/site-packages/click/core.py", line 889, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/var/lib/jenkins/jobs/utx-system-monitors-production/workspace/.venv/local/lib/python2.7/site-packages/click/core.py", line 534, in invoke
    return callback(*args, **kwargs)
  File "run_suite.py", line 50, in test
    alarmageddon.run_tests(validations, publishers)
  File "/var/lib/jenkins/jobs/utx-system-monitors-production/workspace/.venv/local/lib/python2.7/site-packages/alarmageddon/run.py", line 89, in run_tests
    timeout, timeout_retries)
  File "/var/lib/jenkins/jobs/utx-system-monitors-production/workspace/.venv/local/lib/python2.7/site-packages/alarmageddon/run.py", line 151, in _run_validations
    reporter.report()
  File "/var/lib/jenkins/jobs/utx-system-monitors-production/workspace/.venv/local/lib/python2.7/site-packages/alarmageddon/reporter.py", line 48, in report
    logger.debug("Reporting to {}".format(publisher))
  File "/var/lib/jenkins/jobs/utx-system-monitors-production/workspace/.venv/local/lib/python2.7/site-packages/alarmageddon/publishing/slack.py", line 61, in __str__
    return "Slack: {}".format(self.hook_url)
AttributeError: 'SlackPublisher' object has no attribute 'hook_url'

I believe hook_url needs a leading underscore here: https://github.com/PearsonEducation/Alarmageddon/blob/dev/alarmageddon/publishing/slack.py#L61

curtisallen commented 7 years ago

Seeing this with the release 1.0.4

scotthellman commented 7 years ago

Sorry about that! We don't use Slack here so we're relying purely on unit tests to make sure it works. Guess we have some more tests to write 😃

Looks straightforward enough, but I want to write those new tests and make sure this problem isn't lurking in any other classes. I'll try to get a fix pushed up tomorrow - in the meantime 1.0.3 should work as long as you aren't trying to convert your SlackPublisher to a string anywhere.

scotthellman commented 7 years ago

Ok, this should be fixed as of f10aabf7a56a53 in the dev branch. Could yall try pulling down dev and making sure it's working for you? Once you've confirmed that it is, I'll push out a new pypi release.

(you can pull down the dev branch with pip using: pip install git+https://github.com/PearsonEducation/Alarmageddon.git@dev#egg=alarmageddon )