Skip to content

Commit

Permalink
Better handling when tape dismount (#2323)
Browse files Browse the repository at this point in the history
* Better handling when tape dismount

* Migrate to Compose V2
  • Loading branch information
henrikek authored Aug 13, 2024
1 parent dd39d96 commit b696c01
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ jobs:
- name: Build
run: |
cd docker
docker-compose build essarch
docker compose build essarch
test-windows:
runs-on: windows-latest
Expand Down
21 changes: 14 additions & 7 deletions ESSArch_Core/storage/backends/tape.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,21 @@ def lock_or_wait_for_drive(storage_medium, io_lock_key, wait_timeout=10 * 60):
def wait_for_media_transit(storage_medium, wait_timeout=10 * 60):
logger = logging.getLogger('essarch.storage.backends.tape')
timeout_at = time.monotonic() + wait_timeout
while storage_medium.tape_drive.locked:
logger.debug('Storage medium {} ({}) is in transit, sleeps for 5 seconds and checking again'.format(
storage_medium.medium_id, str(storage_medium.pk)))
if time.monotonic() > timeout_at:
raise ValueError("Timeout waiting for transit of storage medium {} ({})".format(
try:
while storage_medium.tape_drive.locked:
logger.debug('Storage medium {} ({}) is in transit, sleeps for 5 seconds and checking again'.format(
storage_medium.medium_id, str(storage_medium.pk)))
time.sleep(5)
storage_medium.refresh_from_db()
if time.monotonic() > timeout_at:
raise ValueError("Timeout waiting for transit of storage medium {} ({})".format(
storage_medium.medium_id, str(storage_medium.pk)))
time.sleep(5)
storage_medium.refresh_from_db()
except AttributeError as e:
if storage_medium.tape_drive is None:
logger.debug('Storage medium {} ({}) was in transit but is now unmounted'.format(
storage_medium.medium_id, str(storage_medium.pk)))
else:
raise e

def prepare_for_io(self, storage_medium, io_lock_key=None, wait_timeout=10 * 60):
logger = logging.getLogger('essarch.storage.backends.tape')
Expand Down

0 comments on commit b696c01

Please sign in to comment.