← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/launchpad:swift-ignore-more-staging-errors into launchpad:master

 

Colin Watson has proposed merging ~cjwatson/launchpad:swift-ignore-more-staging-errors into launchpad:master.

Commit message:
publish-to-swift: Ignore more errors when checking staging commit

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/440621

We want to ignore even connectivity errors to staging.launchpad.net when deciding which old files to prune from Swift, not just HTTP 4xx/5xx errors.  Pruning is strictly best-effort.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:swift-ignore-more-staging-errors into launchpad:master.
diff --git a/utilities/publish-to-swift b/utilities/publish-to-swift
index 3d13f8c..5e11803 100755
--- a/utilities/publish-to-swift
+++ b/utilities/publish-to-swift
@@ -82,8 +82,12 @@ def prune_old_files_from_swift(options, container_name, object_dir, suffix):
     if suffix:
         suffix = "-" + suffix
     if suffix.endswith("-db"):
-        response = requests.head("https://staging.launchpad.net/";)
-        if not response.ok:
+        try:
+            response = requests.head("https://staging.launchpad.net/";)
+            ok = response.ok
+        except requests.RequestException:
+            ok = False
+        if not ok:
             # Staging is routinely down in order to restore its database
             # from a recent production dump, so don't consider this an
             # error; just skip pruning if we can't determine its revision.