parent
66aaf0e4a2
commit
26ae629189
3 changed files with 24 additions and 1 deletions
|
@ -58,6 +58,10 @@ class BaseStorage(StoragePaths):
|
|||
""" Called to perform any storage system setup. """
|
||||
pass
|
||||
|
||||
def validate(self):
|
||||
""" Called to perform any custom storage system validation. """
|
||||
pass
|
||||
|
||||
def get_direct_download_url(self, path, expires_in=60, requires_cors=False):
|
||||
return None
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ import shutil
|
|||
import hashlib
|
||||
import io
|
||||
import logging
|
||||
import psutil
|
||||
|
||||
from uuid import uuid4
|
||||
|
||||
|
@ -145,5 +146,20 @@ class LocalStorage(BaseStorageV2):
|
|||
else:
|
||||
logger.debug('Content already exists at path: %s', final_path_abs)
|
||||
|
||||
def validate(self):
|
||||
# Load the set of disk mounts.
|
||||
try:
|
||||
mounts = psutil.disk_partitions(all=True)
|
||||
except:
|
||||
logger.exception('Could not load disk partitions')
|
||||
return
|
||||
|
||||
# Verify that the storage's root path is under a mounted Docker volume.
|
||||
for mount in mounts:
|
||||
if mount.mountpoint != '/' and self._root_path.startswith(mount.mountpoint):
|
||||
if mount.device == 'tmpfs':
|
||||
return
|
||||
|
||||
raise Exception('Storage path %s is not under a mounted volume.\n\n'
|
||||
'Registry data must be stored under a mounted volume '
|
||||
'to prevent data loss' % self._root_path)
|
||||
|
|
|
@ -82,7 +82,10 @@ def _validate_registry_storage(config, _):
|
|||
""" Validates registry storage. """
|
||||
driver = get_storage_provider(config)
|
||||
|
||||
# Put and remove a temporary file.
|
||||
# Run custom validation on the driver.
|
||||
driver.validate()
|
||||
|
||||
# Put and remove a temporary file to make sure the normal storage paths work.
|
||||
driver.put_content('_verify', 'testing 123')
|
||||
driver.remove('_verify')
|
||||
|
||||
|
|
Reference in a new issue