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. """
|
""" Called to perform any storage system setup. """
|
||||||
pass
|
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):
|
def get_direct_download_url(self, path, expires_in=60, requires_cors=False):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ import shutil
|
||||||
import hashlib
|
import hashlib
|
||||||
import io
|
import io
|
||||||
import logging
|
import logging
|
||||||
|
import psutil
|
||||||
|
|
||||||
from uuid import uuid4
|
from uuid import uuid4
|
||||||
|
|
||||||
|
@ -145,5 +146,20 @@ class LocalStorage(BaseStorageV2):
|
||||||
else:
|
else:
|
||||||
logger.debug('Content already exists at path: %s', final_path_abs)
|
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. """
|
""" Validates registry storage. """
|
||||||
driver = get_storage_provider(config)
|
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.put_content('_verify', 'testing 123')
|
||||||
driver.remove('_verify')
|
driver.remove('_verify')
|
||||||
|
|
||||||
|
|
Reference in a new issue