Skip to content

Commit

Permalink
Merge pull request #6895 from readthedocs/humitos/azure-blob-timeout
Browse files Browse the repository at this point in the history
On Azure .exists blob timeout, log the exception and return False
  • Loading branch information
ericholscher authored Apr 14, 2020
2 parents 5d8a969 + 9ffd97f commit e988f2a
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions readthedocs/storage/azure_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

"""Django storage classes to use with Azure Blob storage service."""

import logging
from azure.common import AzureMissingResourceHttpError
from django.conf import settings
from django.contrib.staticfiles.storage import ManifestFilesMixin
Expand All @@ -13,6 +14,9 @@
from .mixins import OverrideHostnameMixin


log = logging.getLogger(__name__) # pylint: disable=invalid-name


class AzureBuildMediaStorage(BuildMediaStorageMixin, OverrideHostnameMixin, AzureStorage):

"""An Azure Storage backend for build artifacts."""
Expand All @@ -30,6 +34,14 @@ def url(self, name, expire=None, http_method=None): # noqa
"""
return super().url(name, expire)

def exists(self, name):
"""Override to catch timeout exception and return False."""
try:
return super().exists(name)
except Exception: # pylint: disable=broad-except
log.exception('Timeout calling Azure .exists. name=%s', name)
return False


class AzureBuildStorage(AzureStorage):

Expand Down

0 comments on commit e988f2a

Please sign in to comment.