Skip to content

Instantiation contacts minio server when auto_create_bucket enabled #94

@jayvdb

Description

@jayvdb

The constructor of django-minio-storage with auto_create_bucket enabled contacts the server and can raise an exception if it hasnt started yet.

It would be nice if this could be delayed until the storage is being used. I do want the auto-create, but not during the constructor where delays ad exceptions like this are not expected.

  File "/usr/lib/python3.8/site-packages/sorl/thumbnail/default.py", line 24, in _setup
    self._wrapped = get_module_class(settings.THUMBNAIL_STORAGE)()
  File "/usr/lib/python3.8/site-packages/minio_storage/storage.py", line 360, in __init__
    super().__init__(
  File "/usr/lib/python3.8/site-packages/minio_storage/storage.py", line 75, in __init__
    self._init_check()
  File "/usr/lib/python3.8/site-packages/minio_storage/storage.py", line 81, in _init_check
    if self.auto_create_bucket and not self.client.bucket_exists(
  File "/usr/lib/python3.8/site-packages/minio/api.py", line 453, in bucket_exists
    self._url_open('HEAD', bucket_name=bucket_name)
  File "/usr/lib/python3.8/site-packages/minio/api.py", line 2035, in _url_open
    region = self._get_bucket_region(bucket_name)
  File "/usr/lib/python3.8/site-packages/minio/api.py", line 1965, in _get_bucket_region
    region = self._get_bucket_location(bucket_name)
  File "/usr/lib/python3.8/site-packages/minio/api.py", line 1998, in _get_bucket_location
    response = self._http.urlopen(method, url,
  File "/usr/lib/python3.8/site-packages/urllib3/poolmanager.py", line 330, in urlopen
    response = conn.urlopen(method, u.request_uri, **kw)
  File "/usr/lib/python3.8/site-packages/urllib3/connectionpool.py", line 747, in urlopen
    return self.urlopen(
  File "/usr/lib/python3.8/site-packages/urllib3/connectionpool.py", line 747, in urlopen
    return self.urlopen(
  File "/usr/lib/python3.8/site-packages/urllib3/connectionpool.py", line 747, in urlopen
    return self.urlopen(
  [Previous line repeated 2 more times]
  File "/usr/lib/python3.8/site-packages/urllib3/connectionpool.py", line 719, in urlopen
    retries = retries.increment(
  File "/usr/lib/python3.8/site-packages/urllib3/util/retry.py", line 436, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='localhost', port=8081): Max retries exceeded with url: /media?location= (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f936a1dc790>: Failed to establish a new connection: [Errno 111] Connection refused'))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions