]> git.donarmstrong.com Git - dsa-puppet.git/commitdiff
Allow up to two failed mirrors on a mirror-run
authorPeter Palfrader <peter@palfrader.org>
Fri, 21 Jun 2013 08:48:59 +0000 (10:48 +0200)
committerPeter Palfrader <peter@palfrader.org>
Fri, 21 Jun 2013 08:48:59 +0000 (10:48 +0200)
modules/roles/files/static-mirroring/static-master-run

index f8f2be36ab71d4b93ebf6a94c2f03f7ae9aaed0c..d2f364d6ba791873e937c51d63bb92c31f524b91 100755 (executable)
@@ -11,6 +11,7 @@ import time
 
 base="/srv/static.debian.org"
 serialname = '.serial'
+had_warnings = False
 
 clients = []
 with open('/etc/static-clients.conf') as f:
@@ -100,11 +101,24 @@ def callout(component, serial):
   log("Stage 1 done.")
   cnt = count_statuses(status)
 
-  if 'failed' in cnt > 0:
-    log("Some clients failed, aborting...")
+  if 'failed' in cnt and cnt['failed'] >= 2:
+    log("%d clients failed, aborting..."%(cnt['failed'],))
     stage2(pipes, status, 'abort')
     return False
-  elif 'waiting' in cnt > 0:
+
+  failedmirrorsfile = os.path.join(base, 'master', component + "-failedmirrors")
+  if 'failed' in cnt:
+    log("WARNING: %d clients failed!  Continuing anyway!"%(cnt['failed'],))
+    global had_warnings
+    had_warnings = True
+    f = open(failedmirrorsfile, "w")
+    for c in status:
+      if status[c] == 'failed': f.write(c+"\n")
+    f.close()
+  else:
+    os.unlink(failedmirrorsfile)
+
+  if 'waiting' in cnt:
     log("Committing...")
     stage2(pipes, status, 'go')
     return True
@@ -160,7 +174,8 @@ def run_mirror(component):
     os.rename(cur, live)
     log("Cleaning up.")
     shutil.rmtree(tmpdir_old)
-    log("Done.")
+    if had_warnings: log("Done, with warnings.")
+    else: log("Done.")
     ret = True
   else:
     log("Aborted.")