Lee-W commented on code in PR #77015:
URL: https://github.com/apache/airflow/pull/77015#discussion_r4717189735


##########
providers/databricks/src/airflow/providers/databricks/operators/databricks.py:
##########
@@ -97,6 +98,10 @@
     "BLOCKED",
     "WAITING_FOR_RETRY",
 )
+# Databricks repairs failed or canceled runs. A SKIPPED run, or one that never 
started for another

Review Comment:
   Should we add the Jobs API page that the repairable set comes from be linked 
next to the REPAIRABLE_RUN_* constants?



##########
providers/databricks/docs/operators/run_now.rst:
##########
@@ -126,8 +126,13 @@ On retry the operator checks the prior run's state:
 
 * if it is still running, the operator reconnects and continues polling
 * if it already succeeded, the operator returns immediately without triggering 
a new run
-* if it failed terminally, or the run no longer exists because its history 
expired, the operator
-  triggers a fresh run
+* if it failed, timed out or was canceled (result state ``FAILED``, 
``TIMEDOUT`` or ``CANCELED``),

Review Comment:
   this bullet lists timed out, but the row labelled “Failed or canceled” in 
the table further down still omits it. (line 172)



##########
providers/databricks/src/airflow/providers/databricks/operators/databricks.py:
##########
@@ -97,6 +98,10 @@
     "BLOCKED",
     "WAITING_FOR_RETRY",
 )
+# Databricks repairs failed or canceled runs. A SKIPPED run, or one that never 
started for another
+# reason (e.g. MAXIMUM_CONCURRENT_RUNS_REACHED), has nothing to repair, so it 
gets a fresh run.
+REPAIRABLE_RUN_LIFE_CYCLE_STATES = ("TERMINATED", "INTERNAL_ERROR")
+REPAIRABLE_RUN_RESULT_STATES = ("FAILED", "TIMEDOUT", "CANCELED")

Review Comment:
   if a run cancelled by on_kill comes back as canceled, the next retry would 
repair it, since "CANCELED" is in this set. Is that intended?



##########
providers/databricks/src/airflow/providers/databricks/operators/databricks.py:
##########
@@ -1582,6 +1609,28 @@ def is_job_active(self, status: str) -> bool:
     def is_job_succeeded(self, status: str) -> bool:
         return is_run_succeeded(status)
 
+    def resume_failed_job(self, external_id: JsonValue, status: str, context: 
Context) -> JsonValue | None:
+        # cancel_previous_runs keeps only the newest run going; reviving this 
one would break that.
+        if not is_run_repairable(status) or self.cancel_previous_runs:
+            return None
+        run_id = cast("int", external_id)
+        self._merged_json = self._build_run_now_payload(context)
+        if self.databricks_repair_reason_new_settings:
+            run_state = self._hook.get_run_state(run_id)
+            if not is_repair_reason_match_exist(self, run_state):
+                return None
+            update_job_for_repair(self, self._hook, 
self._merged_json["job_id"], run_state)
+        repair_json: dict[str, Any] = {"run_id": run_id, 
"rerun_all_failed_tasks": True}
+        latest_repair_id = self._hook.get_latest_repair_id(run_id)
+        if latest_repair_id is not None:
+            repair_json["latest_repair_id"] = latest_repair_id
+        if "job_parameters" in self._merged_json:
+            repair_json["job_parameters"] = self._merged_json["job_parameters"]
+        # set this before repairing so on_kill can cancel the run while a lost 
reply is re-checked.
+        self.run_id = run_id

Review Comment:
   from reading the code, if repair_run fails and the following run_now also 
raises, self.run_id stays on the old run. Is a later cancel_run on that run 
harmless?



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