Skip to content

Commit

Permalink
Use more try blocks to make crash mover more robust.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tony Young committed Mar 8, 2013
1 parent 3a75f08 commit 086596a
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 14 deletions.
29 changes: 26 additions & 3 deletions socorro/app/fetch_transform_save_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,32 @@ def transform(self, crash_id):
source to the destination without changing the data. While this may
be good enough for the raw crashmover, the processor would override
this method to create and save processed crashes"""
raw_crash = self.source.get_raw_crash(crash_id)
dumps = self.source.get_raw_dumps(crash_id)
self.destination.save_raw_crash(raw_crash, dumps, crash_id)
try:
raw_crash = self.source.get_raw_crash(crash_id)
except Exception as x:
self.config.logger.error(
"reading raw_crash: %s",
str(x),
exc_info=True
)
raw_crash = {}
try:
dumps = self.source.get_raw_dumps(crash_id)
except Exception as x:
self.config.logger.error(
"reading dump: %s",
str(x),
exc_info=True
)
dumps = {}
try:
self.destination.save_raw_crash(raw_crash, dumps, crash_id)
except Exception as x:
self.config.logger.error(
"writing raw: %s",
str(x),
exc_info=True
)

#--------------------------------------------------------------------------
def quit_check(self):
Expand Down
42 changes: 31 additions & 11 deletions socorro/external/fs/crashstorage.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,15 @@ def _visit_minute_slot(self, minute_slot_base):
self._get_date_root_name(crash_id)
])
yield crash_id
os.unlink(date_root_path)

try:
os.unlink(date_root_path)
except OSError as e:
self.logger.error("could not find a date root in "
"%s; is crash corrupt?",
namedir,
exc_info=True)

os.unlink(namedir)

def new_crashes(self):
Expand Down Expand Up @@ -473,9 +481,9 @@ def new_crashes(self):
os.rmdir(minute_slot_base)
except OSError as e:
self.logger.error("could not fully remove directory: "
"%s; are there more crashes in it? "
"%s",
minute_slot_base, e)
"%s; are there more crashes in it?",
minute_slot_base,
exc_info=True)

if not skip_dir and hour_slot < current_slot[0]:
try:
Expand All @@ -485,9 +493,9 @@ def new_crashes(self):
os.rmdir(hour_slot_base)
except OSError as e:
self.logger.error("could not fully remove directory: "
"%s; are there more crashes in it? "
"%s",
hour_slot_base, e)
"%s; are there more crashes in it?",
hour_slot_base,
exc_info=True)


class FSLegacyDatedRadixTreeStorage(FSLegacyRadixTreeStorage,
Expand Down Expand Up @@ -527,9 +535,19 @@ def _visit_minute_slot(self, minute_slot_base):
namedir,
self._get_date_root_name(crash_id)
])

yield crash_id
os.unlink(date_root_path)

try:
os.unlink(date_root_path)
except OSError as e:
self.logger.error("could not find a date root in "
"%s; is crash corrupt?",
webhead_slot_base,
exc_info=True)

os.unlink(namedir)

elif stat.S_ISDIR(st_result.st_mode):
webhead_slot = crash_id_or_webhead
webhead_slot_base = os.sep.join([minute_slot_base,
Expand All @@ -544,6 +562,8 @@ def _visit_minute_slot(self, minute_slot_base):
os.rmdir(webhead_slot_base)
except OSError as e:
self.logger.error("could not fully remove directory: "
"%s; are there more crashes in it? "
"%s",
webhead_slot_base, e)
"%s; are there more crashes in it?",
webhead_slot_base,
exc_info=True)
else:
self.logger.critical("unknown file %s found", namedir)

0 comments on commit 086596a

Please sign in to comment.