Skip to content

Commit

Permalink
fix: NEVER_ATTEMPTED session actions should not report startedAt or e…
Browse files Browse the repository at this point in the history
…ndedAt (#237)

Signed-off-by: Graeme McHale <gmchale@amazon.com>
  • Loading branch information
gmchale79 authored Mar 21, 2024
1 parent 6e8e566 commit 99fd7d3
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 18 deletions.
3 changes: 2 additions & 1 deletion docs/worker_api_contract.md
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,8 @@ attempt to run.

If the Worker Agent reports these Session Action as `FAILED`, `INTERRUPTED`, or `CANCELED` then the Worker Agent
must report all queued Session Actions after it in the Session as `NEVER_ATTEMPTED`; except for
`envExit` actions that correspond to already completed `envEnter` Session Actions. The service
`envExit` actions that correspond to already completed `envEnter` Session Actions. Session Actions that are
reported as `NEVER_ATTEMPTED` must not report `startedAt` or `endedAt` times. The service
must not queue additional Session Actions to the Session except for `envExit` Session Actions that
correspond to already completed `envEnter` Session Actions for the same Session.

Expand Down
4 changes: 2 additions & 2 deletions src/deadline_worker_agent/scheduler/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -618,8 +618,8 @@ def _fail_all_actions(
action["sessionActionId"]: SessionActionStatus(
id=action["sessionActionId"],
completed_status="FAILED" if action is actions[0] else "NEVER_ATTEMPTED",
start_time=now,
end_time=now,
start_time=now if action is actions[0] else None,
end_time=now if action is actions[0] else None,
status=ActionStatus(
state=ActionState.FAILED,
fail_message=str(error_message),
Expand Down
41 changes: 26 additions & 15 deletions test/unit/scheduler/test_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -704,17 +704,21 @@ def test_log_provision_error(
action_update := scheduler._action_updates_map.get(action_id, None)
), f"no action update for {action_id}"
assert action_update.id == action_id
assert action_update.completed_status == (
"FAILED" if action_num == 1 else "NEVER_ATTEMPTED"
)
assert action_update.status is not None
assert action_update.status.state == ActionState.FAILED
assert (
action_update.status.fail_message
== f"Log provisioning error: {log_provision_error_msg}"
)
assert action_update.start_time == datetime_now_mock.return_value
assert action_update.end_time == datetime_now_mock.return_value
if action_num == 1:
assert action_update.completed_status == "FAILED"

assert action_update.start_time == datetime_now_mock.return_value
assert action_update.end_time == datetime_now_mock.return_value
else:
assert action_update.completed_status == "NEVER_ATTEMPTED"
assert action_update.start_time is None
assert action_update.end_time is None

@pytest.mark.parametrize(
argnames="job_details_error",
Expand Down Expand Up @@ -783,14 +787,18 @@ def test_job_details_error(
action_update := scheduler._action_updates_map.get(action_id, None)
), f"no action update for {action_id}"
assert action_update.id == action_id
assert action_update.completed_status == (
"FAILED" if action_num == 1 else "NEVER_ATTEMPTED"
)
assert action_update.status is not None
assert action_update.status.state == ActionState.FAILED
assert action_update.status.fail_message == str(job_details_error)
assert action_update.start_time == datetime_now_mock.return_value
assert action_update.end_time == datetime_now_mock.return_value
if action_num == 1:
assert action_update.completed_status == "FAILED"

assert action_update.start_time == datetime_now_mock.return_value
assert action_update.end_time == datetime_now_mock.return_value
else:
assert action_update.completed_status == "NEVER_ATTEMPTED"
assert action_update.start_time is None
assert action_update.end_time is None

@pytest.mark.skipif(os.name != "nt", reason="Windows-only test.")
def test_job_details_run_as_worker_agent_user_windows(
Expand Down Expand Up @@ -856,14 +864,17 @@ def test_job_details_run_as_worker_agent_user_windows(
action_update := scheduler._action_updates_map.get(action_id, None)
), f"no action update for {action_id}"
assert action_update.id == action_id
assert action_update.completed_status == (
"FAILED" if action_num == 1 else "NEVER_ATTEMPTED"
)
assert action_update.status is not None
assert action_update.status.state == ActionState.FAILED
assert action_update.status.fail_message == expected_err_msg
assert action_update.start_time == datetime_now_mock.return_value
assert action_update.end_time == datetime_now_mock.return_value
if action_num == 1:
assert action_update.completed_status == "FAILED"
assert action_update.start_time == datetime_now_mock.return_value
assert action_update.end_time == datetime_now_mock.return_value
else:
assert action_update.completed_status == "NEVER_ATTEMPTED"
assert action_update.start_time is None
assert action_update.end_time is None


class TestQueueAwsCredentialsManagement:
Expand Down

0 comments on commit 99fd7d3

Please sign in to comment.