Skip to content

feat(taskmaster): go on after ignored errors - #143

Merged
uniqueg merged 4 commits into
devfrom
feat/ignore-error
Nov 13, 2026
Merged

uniqueg merged 4 commits into
devfrom
feat/ignore-error

Conversation

@uniqueg

@uniqueg uniqueg commented Nov 13, 2026 •

Copy link
Copy Markdown
Member

Summary

The taskmaster supports TES 1.1 executors[].ignore_error. It works on
the TESK API's side together with elixir-cloud-aai/tesk-api#159.

  • An executor job with the annotation ignore-error: "true" (the contract
    with the TESK API, which sets it for ignore_error: true) that fails no
    longer stops the task. The taskmaster keeps the job, logs
    Executor job '...' failed; ignoring the error, and goes on with the next
    executor and the outputs filer. A task whose other jobs complete then
    deletes its PVC, as on success.
  • Before going on, the taskmaster waits until Kubernetes marks the job
    Failed (Job.wait_failed). Kubernetes 1.31+ sets FailureTarget
    first and Failed only once the pods have ended, so the failed pods
    can't run next to the next executor on the task's volume. The wait lasts
    at most --pod-timeout; after that, the task stops.
  • Only failures of the job's own pods are ignored. A job that the
    taskmaster ended itself still stops the task, because its container may
    never have run. Those are jobs failed through activeDeadlineSeconds
    because a pod couldn't start or be scheduled (also by an earlier
    taskmaster run), and deleted jobs. The new Job.ended_by_taskmaster
    flag records this. Cancellation stops the task as before.
  • Docs: Taskmaster (what is ignored and what isn't), Upgrading (upgrade the
    taskmaster before the TESK API), Development (the e2e list).

Closes #142

Verification

  • coverage run -m pytest && coverage report: 775 passed, 7 skipped (e2e
    skipped locally); 100% coverage.
  • ruff check ., ruff format --check ., mypy: clean.
  • mkdocs build --strict: clean.
  • New unit tests are in tests/unit/test_taskmaster_ignore_error.py. The
    new e2e test test_executor_ignoring_error runs a failing ignored
    executor, then one that writes an output, and checks the upload. It runs
    in CI's End-to-end test job, because there is no kind cluster locally.
  • CI: all checks passed, including End-to-end test (kind) and both image
    scans.
  • Review: adversarial-reviewer and quality-reviewer, two rounds. Round 1
    found 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; the
    docs findings are fixed.
  • Sourcery: 4 findings. The FailureTarget overlap is fixed (the wait
    above). The other 3 are answered in their threads and resolved; see
    below.

Declined review findings

  • If the taskmaster's attempt to fail or delete a job gets a server error
    (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.
  • Eviction, OOM kill and node loss are ignored like other failures.
    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.
  • Sourcery asked to persist the taskmaster's end intent across restarts.
    A failed job keeps its activeDeadlineSeconds: 1, which a restarted
    taskmaster reads back. In the other cases, any later failure is the
    executor's own run.
  • Sourcery asked about an executor with its own 1-second deadline. The
    TESK API never sets activeDeadlineSeconds on executor jobs.
  • Sourcery asked about a cancellation after the last executor in a task
    without a PVC. The TESK API reports CANCELED from the label whatever
    the taskmaster does, and there is nothing left to skip.

Open questions

None.

🤖 Generated with Claude Code

uniqueg and others added 3 commits November 13, 2026 21:57
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]>
@uniqueg uniqueg self-assigned this Nov 13, 2026
@sourcery-ai

sourcery-ai Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

Data structures

Track when the taskmaster itself failed or deleted a job so ignored executor errors cannot hide failures unrelated to the executor's run.

  • src/tesk_core/job.py L110-115 (+5 small edits)

Implementation

Classify eligible executor failures, wait for failed pods to terminate, and continue task execution only when the failure is safe to ignore.

  • src/tesk_core/job.py L412-440
  • src/tesk_core/taskmaster.py L112-118, L179-188, L193-206 (+1 small edits)

Documentation

Explain which executor failures are ignored, why taskmaster-ended jobs remain fatal, and the required upgrade order.

  • docs/development.md L92-95
  • docs/taskmaster.md L43-72
  • docs/upgrading.md L21-27

Tests

Exercise ignored-error classification, task continuation and stopping conditions, job-end tracking, and the wait for Kubernetes to mark jobs failed.

  • tests/e2e/cluster.py L93, L109-110, L115-124
  • tests/e2e/test_taskmaster_e2e.py L60-88
  • tests/unit/test_taskmaster_ignore_error.py L1-425

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@codecov

codecov Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (a72fe33) to head (8211741).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@uniqueg
uniqueg marked this pull request as ready for review November 13, 2026 21:29
@sourcery-ai

sourcery-ai Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

Linked issues

Checked at commit 8211741

#142 feat(taskmaster): go on after ignored executor errors · 4 of 5 met

# Requirement Status Notes
1 The TESK API marks executors with ignore_error: true using ignore-error: "true". ❌ Not addressed The taskmaster consumes this annotation, but this diff does not add the TESK API behavior that sets it.
2 Keep a failed executor job with the annotation and continue with the next executor and outputs filer. ✅ Met The taskmaster retains the failed job, logs the ignored error, and continues after Kubernetes marks it Failed.
3 Stop for cancellation and for executor jobs deleted or ended by the taskmaster, including unschedulable jobs or jobs the taskmaster couldn't fail. ✅ Met Cancellation still stops task execution; ended_by_taskmaster prevents these jobs from being treated as ignorable executor failures.
4 Add unit and end-to-end tests. ✅ Met The diff adds unit coverage and an end-to-end test for an ignored failure followed by executor and output processing.
5 Document ignored executor failures and upgrade the taskmaster before the TESK API. ✅ Met The Taskmaster and Upgrading docs explain the behavior and upgrade order.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread src/tesk_core/taskmaster.py Resolved
Comment thread src/tesk_core/job.py Resolved
Comment thread src/tesk_core/job.py Resolved
Comment thread src/tesk_core/taskmaster.py Resolved
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]>
@uniqueg
uniqueg merged commit ba4f8d9 into dev Nov 13, 2026
46 checks passed
@uniqueg
uniqueg deleted the feat/ignore-error branch November 13, 2026 22:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(taskmaster): go on after ignored executor errors

1 participant