Alexandros Kosiaris has submitted this change and it was merged.

Change subject: check_puppetrun: Move the failure checks at the top
......................................................................


check_puppetrun: Move the failure checks at the top

The big failure checks should be at the top of the checking logic. That
allows to bail out early in case of serious issues without running code
that will have no change in the outcome.

While at it, rename the failure ruby symbols and actually print them to
given an indication to the user as to what is actually going on

Change-Id: I677fedc9129e1da0fcf9d3238cd3016c3969edcd
---
M modules/base/files/monitoring/check_puppetrun
1 file changed, 13 insertions(+), 12 deletions(-)

Approvals:
  Giuseppe Lavagetto: Looks good to me, but someone else must approve
  Alexandros Kosiaris: Verified; Looks good to me, approved



diff --git a/modules/base/files/monitoring/check_puppetrun 
b/modules/base/files/monitoring/check_puppetrun
index 7df6abd..fe150a3 100755
--- a/modules/base/files/monitoring/check_puppetrun
+++ b/modules/base/files/monitoring/check_puppetrun
@@ -92,11 +92,11 @@
             failcount = summary["events"]["failure"] || 0
         end
     rescue
-        failcount = :unknown
+        failcount = :failed_to_parse_summary_file
         summary = nil
     end
 else
-    failcount = :nostatefile
+    failcount = :no_summary_file
 end
 
 def time_ago(s)
@@ -110,6 +110,17 @@
   "Indeterminate amount of time (see time_ago)"
 end
 
+
+if failcount == :failed
+    puts "CRITICAL: puppet fail"
+    exit 2
+end
+
+if failcount == :failed_to_parse_summary_file || failcount == :no_summary_file
+    puts "UNKNOWN: Failed to check. Reason is: #{failcount}"
+    exit 3
+end
+
 time_since_last_run = Time.now.to_i - lastrun
 human_time_since_last_run = time_ago(time_since_last_run)
 
@@ -121,16 +132,6 @@
 if not enabled
     puts "WARNING: Puppet is currently disabled, message: #{disabled_message}, 
last run #{human_time_since_last_run} ago with #{failcount} failures"
     exit 1
-end
-
-if failcount == :failed
-    puts "CRITICAL: puppet fail"
-    exit 2
-end
-
-if failcount == :unknown || failcount == :nostatefile
-    puts "UNKNOWN: Failed to check. Probably failed to read the state file"
-    exit 3
 end
 
 if failcount > 0

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I677fedc9129e1da0fcf9d3238cd3016c3969edcd
Gerrit-PatchSet: 3
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Alexandros Kosiaris <akosia...@wikimedia.org>
Gerrit-Reviewer: Alexandros Kosiaris <akosia...@wikimedia.org>
Gerrit-Reviewer: Gehel <gleder...@wikimedia.org>
Gerrit-Reviewer: Giuseppe Lavagetto <glavage...@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