seelmann commented on a change in pull request #3596: [AIRFLOW-2747] Explicit
re-schedule of sensors
URL: https://github.com/apache/incubator-airflow/pull/3596#discussion_r218587026
##########
File path: airflow/models.py
##########
@@ -1744,6 +1749,29 @@ def dry_run(self):
self.render_templates()
task_copy.dry_run()
+ @provide_session
+ def handle_reschedule(self, reschedule_exception, test_mode=False,
context=None,
+ session=None):
+ self.end_date = timezone.utcnow()
+ self.set_duration()
+
+ # Log reschedule request
+ session.add(TaskReschedule(self.task, self.execution_date,
self._try_number,
+ self.start_date, self.end_date,
+ reschedule_exception.reschedule_date))
+
+ # set state
+ self.state = State.NONE
+
+ # Decrement try_number so subsequent runs will use the same try number
and write
+ # to same log file.
+ self._try_number -= 1
+
+ if not test_mode:
+ session.merge(self)
+ session.commit()
Review comment:
I tried to figure out what that `test_mode` is about. If I get it right it
has nothing to do with "unit_test_mode" but only with the CLI's "test" sub
command [1]. It says "... without ... recording its state in the database.". I
wasn't aware of that.
In `handle_error()` the `TaskFail` is written even in test mode to the DB,
but the task instance itself is not updated.
For `handle_reschedule()` I don't think it makes sense to record that event.
But I have I'd like to verify it and probably also add some unit tests...
[1] https://airflow.apache.org/cli.html#test
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services