yuseok89 commented on code in PR #74621:
URL: https://github.com/apache/airflow/pull/74621#discussion_r4558517678
##########
providers/amazon/src/airflow/providers/amazon/aws/operators/emr.py:
##########
@@ -1497,12 +1497,22 @@ def execute_complete(self, context: Context, event:
dict[str, Any] | None = None
if validated_event["status"] == "success":
self.log.info("Serverless job completed")
return validated_event["job_details"]["job_id"]
- self.log.info("Cancelling EMR Serverless job %s", self.job_id)
- self.hook.conn.cancel_job_run(
+
+ job_state = self.hook.conn.get_job_run(
applicationId=validated_event["job_details"]["application_id"],
jobRunId=validated_event["job_details"]["job_id"],
+ )["jobRun"]["state"]
+ if job_state in EmrServerlessHook.JOB_TERMINAL_STATES:
+ self.log.info("EMR Serverless job canceled/terminated with status
%s", job_state)
+ else:
+ self.log.info("Cancelling EMR Serverless job %s", self.job_id)
+ self.hook.conn.cancel_job_run(
Review Comment:
If the run reaches a terminal state between `get_job_run` and
`cancel_job_run`, could the cancel raise and hide the failure reason?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]