Skip to content

Commit

Permalink
return False when run launchers try to terminate a run that is alread…
Browse files Browse the repository at this point in the history
…y finished

Summary:
Make this is a no-op rather than moving a run from a terminal state into a non-terminal state.
  • Loading branch information
gibsondan committed Jul 23, 2024
1 parent 96af08f commit 2b705e3
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def terminate(self, run_id):
return False

run = self._instance.get_run_by_id(run_id)
if not run:
if not run or run.is_finished:
return False

self._instance.report_run_canceling(run)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,9 @@ def test_terminated_run(
terminated_run = instance.get_run_by_id(run_id)
assert terminated_run and terminated_run.status == DagsterRunStatus.CANCELED

# termination is a no-op once run is finished
assert not launcher.terminate(run_id)

poll_for_event(
instance,
run_id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ def terminate(self, run_id):
tags = self._get_run_tags(run_id)

run = self._instance.get_run_by_id(run_id)
if not run:
if not run or run.is_finished:
return False

self._instance.report_run_canceling(run)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ def terminate(self, run_id):
check.str_param(run_id, "run_id")

run = self._instance.get_run_by_id(run_id)
if not run:
if not run or run.is_finished:
return False

self._instance.report_run_canceling(run)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ def _get_container(self, run):
def terminate(self, run_id):
run = self._instance.get_run_by_id(run_id)

if not run:
if not run or run.is_finished:
return False

self._instance.report_run_canceling(run)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -448,3 +448,6 @@ def _test_launch(

poll_for_finished_run(instance, run.run_id, timeout=60)
assert instance.get_run_by_id(run.run_id).status == DagsterRunStatus.CANCELED

# termination is a no-op once run is finished
assert not launcher.terminate(run.run_id)
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ def terminate(self, run_id):
check.str_param(run_id, "run_id")
run = self._instance.get_run_by_id(run_id)

if not run:
if not run or run.is_finished:
return False

self._instance.report_run_canceling(run)
Expand Down

0 comments on commit 2b705e3

Please sign in to comment.