Repository navigation
feat(taskmaster): go on after ignored errors - #143
Conversation
Executor jobs with the annotation `ignore-error: "true"` (TES 1.1 `executors[].ignore_error`, set by the TESK API) no longer stop the task when they fail: the job is kept, a warning is logged, and the next executor and the outputs filer run. Cancelled tasks and executor jobs that were deleted (never ran) still stop the task; `Job` records such deletions in `deleted`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Replace `Job.deleted` with `Job.ended_by_taskmaster`: set whenever the taskmaster fails or deletes the job itself (a pod that can't start or be scheduled, also failed by an earlier run, as the job's `activeDeadlineSeconds` shows). Such failures aren't the executor's own and stop the task even with `ignore-error: "true"`, so a task can't go on after an executor that never ran, or next to one whose pod may still be active. Tests and docs follow the review. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Evictions, OOM kills and lost nodes count as the executor's own failures; a failed attempt to fail or delete a job stops the task in doubt; deleted jobs show as missing in the TESK API. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Reviewer's GuideData structuresTrack when the taskmaster itself failed or deleted a job so ignored executor errors cannot hide failures unrelated to the executor's run.
ImplementationClassify eligible executor failures, wait for failed pods to terminate, and continue task execution only when the failure is safe to ignore.
DocumentationExplain which executor failures are ignored, why taskmaster-ended jobs remain fatal, and the required upgrade order.
TestsExercise ignored-error classification, task continuation and stopping conditions, job-end tracking, and the wait for Kubernetes to mark jobs failed.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #143 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 10 10
Lines 1625 1648 +23
=========================================
+ Hits 1625 1648 +23 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Linked issuesChecked at commit 8211741 #142 feat(taskmaster): go on after ignored executor errors · 4 of 5 met
|
There was a problem hiding this comment.
Hey - I've found 4 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="src/tesk_core/taskmaster.py" line_range="179" />
<code_context>
created_jobs.append(job)
status = job.run_to_completion(poll_interval, check_cancelled, args.pod_timeout)
+ if status == "Failed" and not job.ended_by_taskmaster and ignores_error(executor):
+ logger.warning("Executor job '%s' failed; ignoring the error", jobname)
+ return
</code_context>
<issue_to_address>
**Later executors overlap failed pods**
When kubernetes reports `FailureTarget` while a pod from the failed executor is still active or terminating, `Job.get_status` returns `Failed` before the executor’s pods have terminated, so `run_executor` returns for an ignored failure and starts later work while those pods can still access the shared PVC or perform external side effects.
Wait for the failed executor’s pods to terminate before returning from the ignored-failure path.
</issue_to_address>
### Comment 2
<location path="src/tesk_core/job.py" line_range="141" />
<code_context>
self.max_queue: int | None = None
self.delete_unschedulable = False
self.deleting = False
+ self.ended_by_taskmaster = False
self.body = body
self.body["metadata"]["name"] = self.name
</code_context>
<issue_to_address>
**Restart loses taskmaster end intent**
When A fail/delete request errors or an executor is deleted, then the taskmaster restarts before exiting and the executor later fails, `ended_by_taskmaster` exists only in memory, and a new `Job` resets it to `False`; after restart, `run_to_completion` can resume or recreate the executor and `run_executor` can treat its failure as ignorable, so the task continues after an executor the taskmaster had ended.
Persist the taskmaster’s end intent so a restarted taskmaster can recover it for existing or recreated executor jobs.
Also at `src/tesk_core/job.py:222-223`, `src/tesk_core/job.py:358-392`, `src/tesk_core/taskmaster.py:179`.
</issue_to_address>
### Comment 3
<location path="src/tesk_core/job.py" line_range="222" />
<code_context>
return self.status, is_all_pods_runnning
job = self.bv1.read_namespaced_job(self.name, self.namespace)
+ spec = getattr(job, "spec", None)
+ if getattr(spec, "active_deadline_seconds", None) == FAIL_DEADLINE:
+ self.ended_by_taskmaster = True
self.status = "Running"
</code_context>
<issue_to_address>
**Executor failures stop instead of being ignored**
When an executor manifest already specifies `activeDeadlineSeconds` equal to `FAIL_DEADLINE` and the job fails with `ignore-error: "true"`, `Job.get_status` marks the job as taskmaster-ended solely because its deadline matches `FAIL_DEADLINE`, so `run_executor` refuses to ignore the executor’s own failure and stops the task.
Determine whether the taskmaster set the deadline instead of inferring taskmaster intent from the deadline value alone.
</issue_to_address>
### Comment 4
<location path="src/tesk_core/taskmaster.py" line_range="179" />
<code_context>
created_jobs.append(job)
status = job.run_to_completion(poll_interval, check_cancelled, args.pod_timeout)
+ if status == "Failed" and not job.ended_by_taskmaster and ignores_error(executor):
+ logger.warning("Executor job '%s' failed; ignoring the error", jobname)
+ return
</code_context>
<issue_to_address>
**Cancellation reports successful completion**
When cancellation arrives after the last executor’s cancellation check, the last executor failure is ignored, and the task has no PVC, `run_executor` returns from the ignored-failure branch, and `run_task` skips its post-executor cancellation check when `pvc` is `None`; the taskmaster exits normally and the caller sees a completed task.
Check for cancellation after the executor loop regardless of whether the task has a PVC.
Also at `src/tesk_core/taskmaster.py:181`.
</issue_to_address>Sourcery assessment
Needs a human reviewer. 4 findings to address first, and if a failed executor is incorrectly treated as ignorable, later executors and the outputs filer can still run, uploading incomplete or wrong outputs to the configured destination. Reverting stops this behavior for future tasks but cannot retract outputs already uploaded.
Blocking findings: src/tesk_core/taskmaster.py:179, src/tesk_core/job.py:141, src/tesk_core/job.py:222, src/tesk_core/taskmaster.py:179
With `FailureTarget` (Kubernetes 1.31+), a job counts as failed while its pods may still terminate. Before going on after an ignored failure, wait until Kubernetes marks the job `Failed` (for at most `--pod-timeout`; otherwise stop the task), so that the next executor doesn't run next to them on the task's volume. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Summary
The taskmaster supports TES 1.1
executors[].ignore_error. It works onthe TESK API's side together with elixir-cloud-aai/tesk-api#159.
ignore-error: "true"(the contractwith the TESK API, which sets it for
ignore_error: true) that fails nolonger stops the task. The taskmaster keeps the job, logs
Executor job '...' failed; ignoring the error, and goes on with the nextexecutor and the outputs filer. A task whose other jobs complete then
deletes its PVC, as on success.
Failed(Job.wait_failed). Kubernetes 1.31+ setsFailureTargetfirst and
Failedonly once the pods have ended, so the failed podscan't run next to the next executor on the task's volume. The wait lasts
at most
--pod-timeout; after that, the task stops.taskmaster ended itself still stops the task, because its container may
never have run. Those are jobs failed through
activeDeadlineSecondsbecause a pod couldn't start or be scheduled (also by an earlier
taskmaster run), and deleted jobs. The new
Job.ended_by_taskmasterflag records this. Cancellation stops the task as before.
taskmaster before the TESK API), Development (the e2e list).
Closes #142
Verification
coverage run -m pytest && coverage report: 775 passed, 7 skipped (e2eskipped locally); 100% coverage.
ruff check .,ruff format --check .,mypy: clean.mkdocs build --strict: clean.tests/unit/test_taskmaster_ignore_error.py. Thenew e2e test
test_executor_ignoring_errorruns a failing ignoredexecutor, then one that writes an output, and checks the upload. It runs
in CI's
End-to-end testjob, because there is no kind cluster locally.End-to-end test(kind) and both imagescans.
adversarial-reviewerandquality-reviewer, two rounds. Round 1found that taskmaster-ended jobs (can't start, fail-and-keep after an
unschedulable pod, the timeout branch) would have been ignored. That was
fixed with
ended_by_taskmaster. Round 2 had low findings only; thedocs findings are fixed.
FailureTargetoverlap is fixed (the waitabove). The other 3 are answered in their threads and resolved; see
below.
Declined review findings
(5xx), the flag stays set. A job that then fails on its own still stops
the task. This is deliberate: when in doubt, the task stops, and the
docs say so. Clearing the flag would need more state for a rare race.
Treating them differently would need a lookup of each pod's failure
reason. Kubernetes reports them as the executor's own failures, and the
docs now say so.
A failed job keeps its
activeDeadlineSeconds: 1, which a restartedtaskmaster reads back. In the other cases, any later failure is the
executor's own run.
TESK API never sets
activeDeadlineSecondson executor jobs.without a PVC. The TESK API reports
CANCELEDfrom the label whateverthe taskmaster does, and there is nothing left to skip.
Open questions
None.
🤖 Generated with Claude Code