dstandish commented on code in PR #31317:
URL: https://github.com/apache/airflow/pull/31317#discussion_r1195668326


##########
airflow/providers/google/cloud/operators/dataproc.py:
##########
@@ -2029,6 +2029,16 @@ def execute(self, context: Context):
         )
 
         self.job_id = new_job_id
+
+        job = self.hook.get_job(project_id=self.project_id, 
region=self.region, job_id=self.job_id)
+        state = job.status.state
+        if state == JobStatus.State.DONE:
+            return self.job_id
+        elif state == JobStatus.State.ERROR:
+            raise AirflowException(f"Job failed:\n{job}")
+        elif state == JobStatus.State.CANCELLED:
+            raise AirflowException(f"Job was cancelled:\n{job}")
+

Review Comment:
   Shouldn't this only be in the `defer` path?  Otherwise it would seem it is 
duplicative.
   
   And then might be nice to shove this code into a private method too.
   
   e.g.
   
   ```python
           if self.deferrable:
               job_id = self._check_before_defer(...)
               if job_id:
                   return job_id
               self.defer(
                   trigger=DataprocSubmitTrigger(
   ```
   



-- 
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]

Reply via email to