diff --git a/storage/basestorage.py b/storage/basestorage.py index f7c070a24..05f6f6aeb 100644 --- a/storage/basestorage.py +++ b/storage/basestorage.py @@ -42,9 +42,12 @@ class BaseStorage(StoragePaths): pass def validate(self, client): - """ Called to perform any custom storage system validation. The client is an HTTP + """ Called to perform storage system validation. The client is an HTTP client to use for any external calls. """ - pass + # Put a temporary file to make sure the normal storage paths work. + self.put_content('_verify', 'testing 123') + if not self.exists('_verify'): + raise Exception('Could not find verification file') def get_direct_download_url(self, path, expires_in=60, requires_cors=False, head=False): return None diff --git a/storage/local.py b/storage/local.py index ef515f543..af13389e4 100644 --- a/storage/local.py +++ b/storage/local.py @@ -115,6 +115,8 @@ class LocalStorage(BaseStorageV2): os.remove(content_path) def validate(self, client): + super(LocalStorage, self).validate() + # Load the set of disk mounts. try: mounts = psutil.disk_partitions(all=True) diff --git a/storage/swift.py b/storage/swift.py index 742e7851c..4ea4590cb 100644 --- a/storage/swift.py +++ b/storage/swift.py @@ -157,23 +157,17 @@ class SwiftStorage(BaseStorage): return surl.format(scheme=scheme, host=hostname, full_path=full_path, sig=sig, expires=expires) def validate(self, client): - if self._temp_url_key: - # Add a file to test direct download. - self.put_content('dd_path', 'testing 3456') + super(SwiftStorage, self).validate() + if self._temp_url_key: # Generate a direct download URL. - dd_url = self.get_direct_download_url('dd_path') + dd_url = self.get_direct_download_url('_verify') if not dd_url: - self.remove('dd_path') raise Exception('Could not validate direct download URL; the token may be invalid.') # Try to retrieve the direct download URL. response = client.get(dd_url, timeout=2) - - # Remove the test file. - self.remove('dd_path') - if response.status_code != 200: logger.debug('Direct download failure: %s => %s with body %s', dd_url, response.status_code, response.text) diff --git a/util/config/validator.py b/util/config/validator.py index 50253bf63..274963a0c 100644 --- a/util/config/validator.py +++ b/util/config/validator.py @@ -107,13 +107,9 @@ def _validate_registry_storage(config, _): if replication_enabled and storage_type == 'LocalStorage': raise Exception('Locally mounted directory not supported with storage replication') - # Run custom validation on the driver. + # Run validation on the driver. driver.validate(app.config['HTTPCLIENT']) - # Put and remove a temporary file to make sure the normal storage paths work. - driver.put_content('_verify', 'testing 123') - driver.remove('_verify') - # Run setup on the driver if the read/write succeeded. driver.setup() except Exception as ex: