Catch the output when testing our rules
Redirect stderr to stdout so we can see the error message from promtool
and then re-raise a new exception to make it easier to report the error
to the user
@@ -28,11 +28,14 @@ def check_rules(rules):
fp.write(rendered)
fp.flush()
- subprocess.check_call([
+ try:
+ subprocess.check_output([
settings.PROMGEN['rule_writer']['promtool_path'],
'check-rules',
fp.name
- ])
+ ], stderr=subprocess.STDOUT)
+ except subprocess.CalledProcessError as e:
+ raise Exception(rendered + e.output.decode('utf8'))
def render_rules(rules=None):
