Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Allows user to configure number of processes to use when calling
BagIt-python's ``validate`` method. Using more than one when the
Gunicorn worker class is 'gevent' causes BagIt validate to hang. This
change warns the user/installer of Archivematica about that in two
places.
  • Loading branch information
jrwdunham committed Aug 11, 2017
1 parent 7587adc commit 9118930
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
4 changes: 4 additions & 0 deletions install/storage-service.gunicorn-config.py
Expand Up @@ -16,6 +16,10 @@
workers = os.environ.get('SS_GUNICORN_WORKERS', '4')

# http://docs.gunicorn.org/en/stable/settings.html#worker-class
# WARNING: if ``worker_class`` is set to ``'gevent'``, then
# ``BAG_VALIDATION_NO_PROCESSES`` in settings/base.py *must* be set to 1.
# Otherwise reingest will fail at bagit validate. See
# https://github.com/artefactual/archivematica/issues/708
worker_class = os.environ.get('SS_GUNICORN_WORKER_CLASS', 'gevent')

# http://docs.gunicorn.org/en/stable/settings.html#timeout
Expand Down
6 changes: 4 additions & 2 deletions storage_service/locations/models/package.py
Expand Up @@ -12,6 +12,7 @@
import tempfile

# Core Django, alphabetical
from django.conf import settings
from django.db import models
from django.utils.translation import ugettext as _, ugettext_lazy as _l

Expand Down Expand Up @@ -840,7 +841,7 @@ def check_fixity(self, force_local=False, delete_after=True):

bag = bagit.Bag(path)
try:
success = bag.validate(processes=4)
success = bag.validate(processes=settings.BAG_VALIDATION_NO_PROCESSES)
failures = []
message = ""
except bagit.BagValidationError as failure:
Expand Down Expand Up @@ -1195,7 +1196,8 @@ def finish_reingest(self, origin_location, origin_path, reingest_location, reing
bag = bagit.Bag(path)
bag.save(manifests=True)
bag = bagit.Bag(path) # Workaround for bug https://github.com/LibraryOfCongress/bagit-python/pull/63
bag.validate(processes=4) # Raises exception in case of problem
# Raises exception in case of problem
bag.validate(processes=settings.BAG_VALIDATION_NO_PROCESSES)

# Compress if necessary
if to_be_compressed:
Expand Down
7 changes: 7 additions & 0 deletions storage_service/storage_service/settings/base.py
Expand Up @@ -377,3 +377,10 @@ def is_true(env_str):
INSTALLED_APPS += ['shibboleth']

ALLOW_USER_EDITS = False

# WARNING: if Gunicorn is being used to serve the Storage Service and its
# worker class is set to `gevent`, then BagIt validation must use 1 process.
# Otherwise, calls to `validate` will hang because of the incompatibility
# between gevent and multiprocessing (BagIt) concurrency strategies. See
# https://github.com/artefactual/archivematica/issues/708
BAG_VALIDATION_NO_PROCESSES = environ.get('SS_BAG_VALIDATION_NO_PROCESSES', 1)

0 comments on commit 9118930

Please sign in to comment.