Added few more logs for upload_blob operation.

Change-Id: I3eb6485992ce686944bd94e5dc8c6a2e53f4a8b6
This commit is contained in:
Kushal Agrawal 2018-05-02 11:35:30 +05:30
parent 92bc2ad89f
commit 86d40aa3bf
2 changed files with 24 additions and 10 deletions

View File

@ -743,12 +743,17 @@ def delete_lock(context, lock_id, session):
stop_max_attempt_number=50)
def save_blob_data(context, blob_data_id, data, session):
"""Save blob data to database."""
with session.begin():
blob_data = models.ArtifactBlobData()
blob_data.id = blob_data_id
blob_data.data = data.read()
blob_data.save(session=session)
return "sql://" + blob_data.id
LOG.debug("Starting Blob data upload in database for %s", blob_data_id)
try:
with session.begin():
blob_data = models.ArtifactBlobData()
blob_data.id = blob_data_id
blob_data.data = data.read()
blob_data.save(session=session)
return "sql://" + blob_data.id
except Exception as e:
LOG.error("Exception received during blob upload %s", e)
raise
@retry(retry_on_exception=_retry_on_deadlock, wait_fixed=500,

View File

@ -602,8 +602,10 @@ class Engine(object):
fd, path = tpool.execute(
af.validate_upload, context, af, field_name, fd)
else:
LOG.debug("Initiating Pre_upload hook")
fd = tpool.execute(af.pre_upload_hook,
context, af, field_name, blob_key, fd)
LOG.debug("Pre_upload hook executed successfully")
except exception.GlareException:
raise
except Exception as e:
@ -634,10 +636,17 @@ class Engine(object):
{'artifact': af.id, 'blob': blob_name})
# Step 3. Change blob status to 'active'
with self.lock_engine.acquire(context, lock_key):
af = af.show(context, artifact_id)
af = self._save_blob_info(
context, af, field_name, blob_key, blob_info)
try:
with self.lock_engine.acquire(context, lock_key):
af = af.show(context, artifact_id)
af = self._save_blob_info(
context, af, field_name, blob_key, blob_info)
except Exception as e:
msg = _("Exception occured while updating blob status to active"
" for artifact Id : [%(artifact_id)s] , %(error_msg)s") %\
{"artifact_id": artifact_id, "error_msg": str(e)}
LOG.error(msg)
raise
af.post_upload_hook(context, af, field_name, blob_key)