Merge pull request #1660 from coreos-inc/storage-status

Add storage validation to the status endpoint
This commit is contained in:
josephschorr 2016-08-03 11:09:48 -04:00 committed by GitHub
commit 83849f4320
7 changed files with 30 additions and 19 deletions

View file

@ -158,23 +158,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)