tvalentyn commented on code in PR #41627:
URL: https://github.com/apache/beam/pull/41627#discussion_r4774605916


##########
sdks/python/apache_beam/runners/dataflow/internal/apiclient.py:
##########
@@ -956,9 +966,35 @@ def modify_job_state(self, job_id, new_state) -> bool:
     request.job_id = job_id
     request.project_id = self.google_cloud_options.project
     request.location = self.google_cloud_options.region
-    request.job = dataflow.Job(requested_state=new_state)
+    request.job = dataflow.Job(requested_state=requested_state)
+
+    def _should_retry(exception):
+      if retry.retry_on_server_errors_filter(exception):
+        return True
+      if (requested_state == dataflow.JobState.JOB_STATE_CANCELLED and
+          isinstance(exception, exceptions.FailedPrecondition)):
+        try:
+          current_state = self.get_job(job_id).current_state
+        except Exception as get_job_exn:  # pylint: disable=broad-except
+          _LOGGER.warning(
+              'Unable to fetch job %s state after FailedPrecondition on '
+              'cancel; will not retry: %s',
+              job_id,
+              get_job_exn)
+          return False
+        return current_state not in _NON_RETRYABLE_CANCEL_STATES

Review Comment:
   so should modify_job_state  treat current_state in (JOB_STATE_CANCELLED, 
JOB_STATE_CANCELLING) as a successful no-op or not?



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