ArielGlenn has submitted this change and it was merged.

Change subject: scheduler: move command retry updating into its own method
......................................................................


scheduler: move command retry updating into its own method

Change-Id: I16097d1a92159a21ebf321da40f2464a70f859c0
---
M xmldumps-backup/dumpscheduler.py
1 file changed, 26 insertions(+), 18 deletions(-)

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



diff --git a/xmldumps-backup/dumpscheduler.py b/xmldumps-backup/dumpscheduler.py
index 432cc04..b2447ab 100644
--- a/xmldumps-backup/dumpscheduler.py
+++ b/xmldumps-backup/dumpscheduler.py
@@ -324,6 +324,31 @@
     return my_id
 
 
+def update_retries(process, pid, entry):
+    '''
+    update the number of retries left for
+    a command
+    '''
+    retries = entry['onfailure'].split("=", 1)[1]
+    if not retries.isdigit():
+        LOG.error("number of retries must be an integer but "
+                  "found '%s', continuing", retries)
+        entry['onfailure'] = 'continue'
+    else:
+        if process is not None:
+            entry['processes'].remove(process)
+        entry['processids'].remove(pid)
+        if pid in entry['procidsfromcache']:
+            entry['procidsfromcache'].remove(pid)
+        entry['count'] = entry['count'] + 1
+        LOG.info("after failure, retry for %s scheduled", entry['command'])
+        if retries != "0":
+            entry['onfailure'] = "retry=%d" % (int(retries) - 1)
+        else:
+            entry['onfailure'] = "continue"
+            # next failure there will be no more retries
+
+
 class Scheduler(object):
     '''
     handle running a sequence of commands, each command possibly to
@@ -455,24 +480,7 @@
         if entry['onfailure'] == 'continue':
             self.mark_process_done(process, pid, entry)
         elif entry['onfailure'].startswith('retry='):
-            retries = entry['onfailure'].split("=", 1)[1]
-            if not retries.isdigit():
-                LOG.error("number of retries must be an integer but "
-                          "found '%s', continuing", retries)
-                entry['onfailure'] = 'continue'
-            else:
-                if process is not None:
-                    entry['processes'].remove(process)
-                entry['processids'].remove(pid)
-                if pid in entry['procidsfromcache']:
-                    entry['procidsfromcache'].remove(pid)
-                entry['count'] = entry['count'] + 1
-                LOG.info("after failure, retry for %s scheduled", 
entry['command'])
-                if retries != "0":
-                    entry['onfailure'] = "retry=%d" % (int(retries) - 1)
-                else:
-                    entry['onfailure'] = "continue"
-                    # next failure there will be no more retries
+            update_retries(process, pid, entry)
 
     def check_running_by_proc(self, entry):
         '''

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I16097d1a92159a21ebf321da40f2464a70f859c0
Gerrit-PatchSet: 2
Gerrit-Project: operations/dumps
Gerrit-Branch: master
Gerrit-Owner: ArielGlenn <ar...@wikimedia.org>
Gerrit-Reviewer: ArielGlenn <ar...@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