Commit edb8c6b6 authored by Cristiano Urban's avatar Cristiano Urban
Browse files

Set job phase to 'ERROR' for jobs launched by users not present in the 'users'...


Set job phase to 'ERROR' for jobs launched by users not present in the 'users' table of the VOSpace database.

Signed-off-by: default avatarCristiano Urban <cristiano.urban@inaf.it>
parent 523379ca
Loading
Loading
Loading
Loading
Loading
+21 −3
Original line number Diff line number Diff line
@@ -52,8 +52,8 @@ class StartJobRPCServer(RedisRPCServer):

    def callback(self, requestBody):
        # debug block...
        out = open("start_job_rpc_server_log.txt", "a")
        out.write(json.dumps(requestBody))
        #out = open("start_job_rpc_server_log.txt", "a")
        #out.write(json.dumps(requestBody))

        job = Job()
        job.setId(requestBody["job"]["jobId"])
@@ -71,10 +71,28 @@ class StartJobRPCServer(RedisRPCServer):
                         "errorCode": 3,
                         "errorMsg": errorMsg }
            return response

        # Check if 'read_pending_queue' is full
        if pendingQueueLen >= self.maxPendingJobs:
            job.setPhase("ERROR")
            job.setErrorType("transient")
            job.setErrorMessage("Pending queue is full, please, retry later.")
            errorMsg = "Pending queue is full, please, retry later."
            job.setErrorMessage(errorMsg)
            self.logger.warning(errorMsg)
            errorFlag = True
        # Check if the user is already present in the VOSpace database. If not, change the job phase to 'ERROR'.
        # The user must be created in the database using the 'vos_user' admin command.
        elif not self.dbConn.getUserName(requestBody["job"]["ownerId"]):
            job.setPhase("ERROR")
            job.setErrorType("transient")
            errorMsg = "The user is registered in the authentication system (RAP), but is not present into the 'users' table of the VOSpace database."
            job.setErrorMessage(errorMsg)
            self.logger.warning(errorMsg)
            errorFlag = True
        else:
            errorFlag = False

        if errorFlag:
            try:
                self.dbConn.insertJob(job)
            except Exception: