Filippo Giunchedi has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/368160 )

Change subject: prometheus: handle non-existant or empty puppet last run summary
......................................................................


prometheus: handle non-existant or empty puppet last run summary

Bug: T170932
Change-Id: I45b6e47f7847cb4c3d8b8c72befa8f412164c83f
---
M modules/prometheus/files/usr/local/bin/prometheus-puppet-agent-stats
1 file changed, 11 insertions(+), 0 deletions(-)

Approvals:
  jenkins-bot: Verified
  Filippo Giunchedi: Looks good to me, approved



diff --git 
a/modules/prometheus/files/usr/local/bin/prometheus-puppet-agent-stats 
b/modules/prometheus/files/usr/local/bin/prometheus-puppet-agent-stats
index 16124de..8fa76aa 100755
--- a/modules/prometheus/files/usr/local/bin/prometheus-puppet-agent-stats
+++ b/modules/prometheus/files/usr/local/bin/prometheus-puppet-agent-stats
@@ -39,6 +39,9 @@
     resources_failed = Gauge('resources_failed', 'Number of failed resources 
on last run',
                              namespace='puppet_agent', registry=registry)
     resources_failed.set(0)
+    collection_error = Gauge('collection_error', 'Error collecting data',
+                             namespace='puppet_agent', registry=registry)
+    collection_error.set(0)
 
     summary_file = os.path.join(puppet_state_dir, 'last_run_summary.yaml')
     try:
@@ -49,6 +52,14 @@
         log.exception(e)
         summary_parse_fail.set(1)
         return
+    except IOError as e:
+        log.exception(e)
+        collection_error.set(1)
+        return
+
+    if not summary_yaml:
+        failed.set(1)
+        return
 
     if 'time' in summary_yaml:
         last_run.set(summary_yaml['time'].get('last_run', 0))

-- 
To view, visit https://gerrit.wikimedia.org/r/368160
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I45b6e47f7847cb4c3d8b8c72befa8f412164c83f
Gerrit-PatchSet: 2
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Filippo Giunchedi <fgiunch...@wikimedia.org>
Gerrit-Reviewer: Filippo Giunchedi <fgiunch...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to