← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/launchpad:librarian-gc-reduce-staging-oopses into launchpad:master

 

Colin Watson has proposed merging ~cjwatson/launchpad:librarian-gc-reduce-staging-oopses into launchpad:master.

Commit message:
Silence some more librarian-gc OOPSes on non-production systems

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

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

The errors about data being missing from disk or from Swift mostly don't make sense if we have an upstream host (and in one case the attempt to suppress this error no longer worked in a charmed deployment).  There are over 160000 such OOPSes daily from qastaging right now, so it's worth reducing the load on the error-processing system a bit.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:librarian-gc-reduce-staging-oopses into launchpad:master.
diff --git a/lib/lp/services/librarianserver/librariangc.py b/lib/lp/services/librarianserver/librariangc.py
index 7790971..14423be 100644
--- a/lib/lp/services/librarianserver/librariangc.py
+++ b/lib/lp/services/librarianserver/librariangc.py
@@ -280,7 +280,7 @@ def merge_duplicates(con):
         # production but the actual librarian contents has not.
         dupe1_id = dupes[0][0]
         if not file_exists(dupe1_id):
-            if config.instance_name == "staging":
+            if config.librarian_server.upstream_host is not None:
                 log.debug3("LibraryFileContent %d data is missing", dupe1_id)
             else:
                 log.warning("LibraryFileContent %d data is missing", dupe1_id)
@@ -812,10 +812,11 @@ def delete_unwanted_disk_files(con):
         next_wanted_content_id = get_next_wanted_content_id()
     if not swift_enabled:
         while next_wanted_content_id is not None:
-            log.error(
-                "LibraryFileContent %d exists in the database but "
-                "was not found on disk." % next_wanted_content_id
-            )
+            if config.librarian_server.upstream_host is None:
+                log.error(
+                    "LibraryFileContent %d exists in the database but "
+                    "was not found on disk." % next_wanted_content_id
+                )
             next_wanted_content_id = get_next_wanted_content_id()
 
     cur.close()
@@ -984,8 +985,10 @@ def delete_unwanted_swift_files(con):
         # has not run recently. Report an error if the file is older
         # than one week and doesn't exist in Swift.
         path = get_file_path(next_wanted_content_id)
-        if os.path.exists(path) and (
-            os.stat(path).st_ctime < time() - (7 * 24 * 60 * 60)
+        if (
+            config.librarian_server.upstream_host is None
+            and os.path.exists(path)
+            and (os.stat(path).st_ctime < time() - (7 * 24 * 60 * 60))
         ):
             log.error(
                 "LibraryFileContent {} exists in the database and disk "