Skip to content

fix: select only executor jobs for a single task - #183

Merged
uniqueg merged 4 commits into
devfrom
fix/182-executor-job-selector
Nov 14, 2026
Merged

uniqueg merged 4 commits into
devfrom
fix/182-executor-job-selector

Conversation

@uniqueg

@uniqueg uniqueg commented Nov 14, 2026 •

Copy link
Copy Markdown
Member

Summary

listSingleTaskExecutorJobs (used by GET /tasks/{id} and POST /tasks/{id}:cancel) now selects taskmaster-name=<id>,job-type=executor instead of taskmaster-name=<id> only. Taskmasters with elixir-cloud-aai/tesk-core#147 also give the filer jobs the label taskmaster-name; TaskBuilder routes every listed job without job-type to the outputs filer slot, so the inputs filer stood in as the outputs filer. After an ignored executor failure whose wait timed out, GET /tasks/{id} then reported COMPLETE instead of SYSTEM_ERROR.

Executor jobs have always carried job-type=executor (TESK API builds their template), so the selector works with old and new taskmasters alike and can be deployed before the tesk-core release that labels filer jobs.

  • Fix: KubernetesClientWrapper.listSingleTaskExecutorJobs.
  • Tests: new SingleTaskJobsIT (WireMock stubs per label selector, with a filer job labelled as by tesk-core#147): the timed-out ignore_error case is SYSTEM_ERROR, and a failed inputs filer isn't taken for a failed outputs filer. Both failed before the fix (COMPLETE and SYSTEM_ERROR). Updated KubernetesClientWrapperTest and the WireMock URL in MockUtil.
  • Docs: docs/upgrading.md gets the upgrade order (this TESK API before or together with a taskmaster that labels filer jobs), and the ignore_error note no longer says "taskmaster first", which would contradict it if one tesk-core release brings both. docs/index.md ("Getting tasks") says how a single task's executors and outputs filer are matched.

Closes #182

Verification

  • ./mvnw -B clean verify (Java 21): BUILD SUCCESS, all unit and integration tests pass, JaCoCo check passes. Before the fix: KubernetesClientWrapperTest.listSingleTaskExecutorJobs and both SingleTaskJobsIT tests failed.
  • ./mvnw -B spotless:check checkstyle:check (Java 8): BUILD SUCCESS, 0 violations.
  • mkdocs build --strict: passes.
  • CI: all checks pass (CI passed, Test, Lint, Docs, Smoke test, Scan image, CodeQL, codecov).

Declined review findings

  • Quality reviewer (low): no IT for POST /tasks/{id}:cancel. Cancel reads the task through the same readTask as GET /tasks/{id}, which the new ITs cover; the adversarial reviewer confirmed the shared path.
  • Quality reviewer (low): SingleTaskJobsIT repeats the Spring/WireMock setup of the other ITs. That is the existing convention; MockUtil has no general job builder to reuse (its jobList is reused).

Open questions

None.

🤖 Generated with Claude Code

Summary by Sourcery

Select only executor jobs when reading or cancelling a single task to prevent filer jobs from producing incorrect task states.

Bug Fixes:

  • Restrict single-task executor job selection to jobs labelled with both the task and executor type, preventing filer jobs from being misidentified as executors.
  • Correct task state reporting when filer jobs share the taskmaster label, including ignored executor failures and failed input filers.

Documentation:

  • Document executor and outputs-filer matching rules and provide the required upgrade order for taskmasters that label filer jobs.

Tests:

  • Add integration coverage for shared filer labels and update Kubernetes client selector tests and mocks.

uniqueg and others added 3 commits November 14, 2026 22:15
listSingleTaskExecutorJobs selected a task's jobs by the label
taskmaster-name alone. Taskmasters with tesk-core#147 also give the
filers' jobs that label, so that the inputs filer stood in as the
outputs filer: GET /tasks/{id} reported COMPLETE instead of
SYSTEM_ERROR after an ignored executor failure whose taskmaster stopped
before the outputs filer. Select job-type=executor as well.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
TESK API with the executor-only selector must be deployed before a
taskmaster that labels the filers' jobs with taskmaster-name.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The ignore_error note said to upgrade the taskmaster first, which
contradicts the order needed for filer labels if one tesk-core release
brings both. Describe how a single task's jobs are matched in "Getting
tasks", and say in SingleTaskJobsIT that its stubs are keyed per
selector.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@sourcery-ai

sourcery-ai Bot commented Nov 14, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

Implementation

Restrict single-task executor job listing to jobs carrying both the taskmaster and executor labels, preventing filer jobs from being treated as executors.

  • src/main/java/uk/ac/ebi/tsc/tesk/k8s/service/KubernetesClientWrapper.java L333-343
  • src/test/java/uk/ac/ebi/tsc/tesk/k8s/service/KubernetesClientWrapperTest.java L434

Documentation

Document how single-task executor and outputs-filer jobs are identified, and the safe rollout order for taskmasters that label filer jobs.

  • docs/index.md L89-92
  • docs/upgrading.md L78-101

Tests

Add integration coverage showing filer-label collisions no longer corrupt task state, using job-list responses keyed to the respective selectors.

  • src/integration-test/java/uk/ac/ebi/tsc/tesk/SingleTaskJobsIT.java L1-173

Other changes

Files not grouped.

  • src/integration-test/java/uk/ac/ebi/tsc/tesk/MockUtil.java L29

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 14, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.61%. Comparing base (ec56f34) to head (2d3cb02).

Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #183      +/-   ##
==========================================
+ Coverage   77.60%   77.61%   +0.01%     
==========================================
  Files          74       74              
  Lines        3487     3489       +2     
  Branches      416      416              
==========================================
+ Hits         2706     2708       +2     
  Misses        621      621              
  Partials      160      160              

☔ 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 14, 2026 21:35
@sourcery-ai

sourcery-ai Bot commented Nov 14, 2026 •

Copy link
Copy Markdown

Linked issues

Checked at commit 2d3cb02

#182 fix: select only executor jobs for a single task · 3 of 3 met

# Requirement Status Notes
1 Select single-task executor jobs by both taskmaster-name= and job-type=executor. ✅ Met listSingleTaskExecutorJobs now uses both labels, keeping filer jobs out of the executor list.
2 Prevent filer jobs carrying taskmaster-name from being mistaken for the outputs filer and corrupting single-task state. ✅ Met The integration tests cover the ignored-executor-failure state and a failed inputs filer; the selector excludes both filer jobs.
3 Update the selector unit-test expectation and the integration-test WireMock URL. ✅ Met Both now expect the selector containing taskmaster-name and job-type=executor.

@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 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="docs/upgrading.md" line_range="90" />
<code_context>
+  (before: `taskmaster-name` only). Taskmasters of tesk-core releases with
+  [tesk-core#147](https://github.com/elixir-cloud-aai/tesk-core/issues/147)
+  also give the filers' jobs the label `taskmaster-name`. Upgrade TESK API
+  to this release before, or together with, setting the taskmaster to such
+  a release (`TESK_API_TASKMASTER_IMAGE_VERSION`, see
+  [Configuration](configuration.md)); never set it on an older TESK API.
</code_context>
<issue_to_address>
**Task state and cancellation are wrong**

When the API and taskmaster are upgraded together while old API replicas still handle requests, `readTask` selects the labelled inputs filer, and `TaskBuilder` treats that untyped job as the outputs filer, so task reads report the wrong state and cancellation can be rejected while the taskmaster is running.

Require the API rollout to finish before enabling a taskmaster release that adds the filer labels.

Also at `docs/upgrading.md:91`.
</issue_to_address>

Sourcery assessment

Approval pending. 1 finding to address first.

Blocking findings: docs/upgrading.md:90


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

Comment thread docs/upgrading.md Resolved
During a rolling update, older TESK API replicas still serve requests
and misreport tasks of a taskmaster that labels the filers' jobs. Set
that taskmaster only once no older replica runs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@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.

Sourcery assessment

Approved.

@uniqueg
uniqueg merged commit 39011c4 into dev Nov 14, 2026
25 checks passed
@uniqueg
uniqueg deleted the fix/182-executor-job-selector branch November 14, 2026 21:42
uniqueg added a commit that referenced this pull request Nov 14, 2026
Brings in #161, #174, #175, #176, #178, #181, #183 and #184. The
conflict in docs/upgrading.md is resolved by merging both lists under
"To 1.3.0": the upgrade order for filer labels and Java 21 come first,
and the TES 1.1 fields item no longer says that ignore_error: true is
refused.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
uniqueg added a commit that referenced this pull request Nov 14, 2026
Lists the changes merged into dev since the notes were written:
Java 21 (#161), ignore_error (#174), the resource server (#175),
output file logs (#176), the Kubernetes client (#178), Dependabot
labels (#181), the executor job selector (#183) and full test coverage
(#184). Adds a Breaking changes section, as in the 1.2.0 notes, and
sets date-released to the planned tag date, 2026-11-16.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.

fix: select only executor jobs for a single task

1 participant