Surpress 404 errors from swift

Because we try swift and then fall back to disk or alternative
path names we get a lot of 404's when looking for a log. These
are currently filling up apache's error.log from our catch-all
exception handler.

We still want to catch all exceptions from attempting swift (as
these will range from 403's through to the swiftclient not existing)
but we want to ignore errors from 404's as they are handled
separately.

Change-Id: I7c03685dfde12a3c09f9a2a9caca811281779875
This commit is contained in:
Joshua Hesketh 2015-07-18 13:07:45 +10:00
parent 03f726cb73
commit 6d7e65df3d
1 changed files with 8 additions and 5 deletions

View File

@ -137,11 +137,14 @@ class SwiftIterableBuffer(collections.Iterable):
swift_config['container'], logname,
resp_chunk_size=chunk_size)
self.file_headers.update(self.resp_headers)
except Exception:
import traceback
sys.stderr.write("Error fetching from swift.\n")
sys.stderr.write('logname: %s\n' % logname)
traceback.print_exc()
except Exception as e:
# Only print the traceback if the error was anything but a
# 404. File not found errors are handled separately.
if 'http_status' not in dir(e) or e.http_status != 404:
import traceback
sys.stderr.write("Error fetching from swift.\n")
sys.stderr.write('logname: %s\n' % logname)
traceback.print_exc()
def __iter__(self):
ext = os.path.splitext(self.logname)[1]