diff --git a/transfer_service/retrieve_executor.py b/transfer_service/retrieve_executor.py index 0243185f648292031fa49c2adf0f3c432af05c4e..58af73cbd34b65ecd6a75364239a5dfd0261613d 100644 --- a/transfer_service/retrieve_executor.py +++ b/transfer_service/retrieve_executor.py @@ -258,9 +258,10 @@ class RetrieveExecutor(TaskExecutor): """ results = [{"target": ""}] results[0]["target"] = self.jobObj.jobInfo["transfer"]["target"] - self.dbConn.setResults(self.jobId, results) + #self.dbConn.setResults(self.jobId, results) + self.jobObj.setResults(results) self.jobObj.setPhase("COMPLETED") - self.dbConn.setPhase(self.jobId, "COMPLETED") + self.dbConn.insertJob(self.jobObj) self.dbConn.setEndTime(self.jobId) self.jobObj.endTime = datetime.datetime.now().isoformat() @@ -274,10 +275,8 @@ class RetrieveExecutor(TaskExecutor): destPath = srcPath.replace(baseSrcPath, baseDestPath) self.destPathList.append(destPath) self.jobObj.jobInfo["destPathList"] = self.destPathList.copy() - - # Send e-mail notification - m = Mailer(self.logger) + m = Mailer(self.logger) m.addRecipient(self.adminEmail) userEmail = self.dbConn.getUserEmail(self.jobObj.ownerId) if userEmail != self.adminEmail: @@ -294,6 +293,8 @@ class RetrieveExecutor(TaskExecutor): Your files are available and can be downloaded. """ + + # Send e-mail notification m.setMessage("VOSpace data retrieve notification: Job COMPLETED", msg) m.send() diff --git a/transfer_service/retrieve_preprocessor.py b/transfer_service/retrieve_preprocessor.py index 44d12d8968a83d9c122bd51b9db6292cce0aa13f..f510f51bb9a35dd58e993eaa42e620996dc847b4 100644 --- a/transfer_service/retrieve_preprocessor.py +++ b/transfer_service/retrieve_preprocessor.py @@ -50,10 +50,8 @@ class RetrievePreprocessor(TaskExecutor): self.nodeList.append(target + '/' + el["value"]) self.jobObj.jobInfo["nodeList"] = self.nodeList.copy() - def update(self, status): - # Send e-mail notification + def update(self, status): m = Mailer(self.logger) - m.addRecipient(self.adminEmail) userEmail = self.dbConn.getUserEmail(self.jobObj.ownerId) if userEmail != self.adminEmail: @@ -68,6 +66,8 @@ class RetrievePreprocessor(TaskExecutor): Owner ID: {self.jobObj.ownerId} """ + + # Send e-mail notification m.setMessage(f"VOSpace data retrieve notification: Job {status}", msg) m.send() diff --git a/transfer_service/store_executor.py b/transfer_service/store_executor.py index fd42182e67610061caa19e7cc5edd3da5e95bcfa..990386add27ef68e2704516f3ed25f44a9f18355 100644 --- a/transfer_service/store_executor.py +++ b/transfer_service/store_executor.py @@ -123,8 +123,7 @@ class StoreExecutor(TaskExecutor): try: results = [{"target": ""}] self.dbConn.setResults(self.jobId, results) - - # Send e-mail notification + m = Mailer(self.logger) m.addRecipient(self.adminEmail) self.userEmail = self.dbConn.getUserEmail(self.userId) @@ -181,12 +180,15 @@ class StoreExecutor(TaskExecutor): """ msg += info m.setMessage("VOSpace data storage notification", msg) + # Send e-mail notification m.send() - else: - self.logger.info("Updating job phase to ERROR") + else: self.jobObj.setPhase("ERROR") - self.dbConn.setPhase(self.jobId, "ERROR") + self.jobObj.setErrorType("fatal") + self.jobObj.setErrorMessage("FATAL: something went wrong during the execution phase.") + self.dbConn.insertJob(self.jobObj) self.dbConn.setEndTime(self.jobId) + self.logger.info("Job phase updated to ERROR.") msg = f""" ########## VOSpace data storage procedure summary ########## @@ -216,7 +218,7 @@ class StoreExecutor(TaskExecutor): def cleanup(self): try: srcPathPrefix = self.storageStorePath.replace("{username}", self.username) - self.logger.info(f"Cleanup of {srcPathPrefix}...") + self.logger.info(f"Cleanup of '{srcPathPrefix}'...") srcData = os.listdir(srcPathPrefix) for el in srcData: nodeOSPath = srcPathPrefix + '/' + el diff --git a/transfer_service/store_preprocessor.py b/transfer_service/store_preprocessor.py index 3cc9d02cc45c9b7b93a844d1747c8bfe0c495355..253e0d60c65dfc75214d29f82b39dfab5c421cce 100644 --- a/transfer_service/store_preprocessor.py +++ b/transfer_service/store_preprocessor.py @@ -220,17 +220,16 @@ class StorePreprocessor(TaskExecutor): def update(self, status): try: m = Mailer(self.logger) - m.addRecipient(self.adminEmail) userEmail = self.dbConn.getUserEmail(self.jobObj.ownerId) if userEmail != self.adminEmail: m.addRecipient(userEmail) if status == "OK": - self.logger.info("Job phase updated to QUEUED.") self.jobObj.setPhase("QUEUED") self.dbConn.setPhase(self.jobId, "QUEUED") - # Send e-mail notification + self.logger.info("Job phase updated to QUEUED.") + msg = f""" Dear user, your job has been QUEUED. @@ -246,14 +245,14 @@ class StorePreprocessor(TaskExecutor): """ m.setMessage("VOSpace data storage notification: Job QUEUED", msg) m.send() - else: - # Send e-mail notification - self.logger.info("Job phase updated to ERROR.") + else: self.jobObj.setPhase("ERROR") self.jobObj.setErrorType("fatal") + self.jobObj.setErrorMessage("FATAL: something went wrong during the preprocessing phase.") self.dbConn.insertJob(self.jobObj) self.dbConn.setEndTime(self.jobId) self.setDestinationQueueName("write_terminated") + self.logger.info("Job phase updated to ERROR.") msg = f""" Dear user, @@ -268,6 +267,8 @@ class StorePreprocessor(TaskExecutor): This issue will be automatically reported to the administrator. """ + + # Send e-mail notification m.setMessage("VOSpace data storage notification: Job ERROR", msg) m.send() except Exception: