Skip to content

Keep a finished workflow's node statuses current instead of expiring them - #1298

Open
romer8 wants to merge 2 commits into
tethysplatform:mainfrom
Aquaveo:fix/trust-terminal-node-statuses
Open

romer8 wants to merge 2 commits into
tethysplatform:mainfrom
Aquaveo:fix/trust-terminal-node-statuses

Conversation

@romer8

@romer8 romer8 commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

Description

Persisted node statuses expire after 60s so a stopped reporter falls back to live statuses. That is right while a workflow runs and pointless once it finishes — a workflow that left the queue with every node terminal will never report again. It is also where the fallback most often fails: finished workflows' working directories get cleaned up, and condorpy chdirs into one, so the details row raises FileNotFoundError.

Requires both the workflow and every node to be terminal. The workflow alone is not enough (a held node can be requeued); the nodes alone are not enough (a reporter that never sends a final report leaves the last node non-terminal, and that copy must keep expiring).

Changes Made to Code

  • node_statuses_are_current returns true for a finished workflow whose nodes are all terminal.
  • New all_node_statuses_are_terminal; a node with no status counts against the set.
  • Five tests, three of which fail without the change.

romer8 added 2 commits August 15, 2026 15:27
…them

Persisted node statuses are served only while they are recent, so that a
deployment whose reporter has stopped falls back to reading live statuses
rather than showing values that never advance. That rule is right while a
workflow is running and pointless once it has finished: a workflow that has
left the queue with every node in a status it cannot leave will never report
again, so expiring its statuses only sends the views to the scheduler to be
told the same thing.

It is also the case where reading live statuses is most likely to fail.
Working directories of finished workflows are eventually cleaned up, and
condorpy chdirs into one to query the queue, so the fallback raises
FileNotFoundError and the whole details row fails to render.

Both halves of the new condition are load-bearing. The workflow's own status is
not enough, because a node can be reported terminal and then requeued -- a held
node that DAGMan retries -- and the workflow is only terminal once DAGMan has
departed. The nodes are not enough either: a reporter that never sends a final
report leaves the last node non-terminal, and that copy must not be trusted
forever. Requiring both means a workflow recorded by such a reporter keeps
expiring and reading live, which is the behaviour it has today.

A node with no persisted status counts against the set rather than being
skipped, so a workflow nothing has ever reported on is unaffected.
@coveralls

coveralls commented Aug 15, 2026

Copy link
Copy Markdown

Coverage Status

coverage: 99.993% (-0.007%) from 100.0% — Aquaveo:fix/trust-terminal-node-statuses into tethysplatform:main

Copilot AI 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.

🟡 Changes recommended

Two moderate findings remain unresolved regarding held nodes and custom terminal statuses.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Updates Condor workflow status caching so completed workflows with terminal nodes retain persisted statuses beyond normal expiry.

Changes:

  • Adds terminal-aware freshness logic.
  • Adds five unit tests.
  • Documents the fix in release notes.
File summaries
File Summary
tethys_compute/models/condor/condor_workflow.py Implements terminal-aware caching. Moderate (2 votes): Held may be incorrectly treated as terminal. Moderate (1 vote): custom terminal statuses are not recognized. Nit (1 vote): update reporting documentation for the exception.
tests/unit_tests/test_tethys_compute/test_models/test_CondorWorkflow.py Adds coverage for terminal and nonterminal cache behavior.
docs/whats_new.rst Documents the bug fix.
Review details

Suppressed comments (2)

tethys_compute/models/condor/condor_workflow.py:118

  • The public reporting documentation still says that node_statuses_are_current becomes false after node_statuses_max_age and the views then read live statuses (docs/tethys_sdk/jobs.rst:324). This new terminal-workflow exception makes that contract incomplete; document that the cache remains current only when the workflow and every persisted node are terminal, while nonterminal workflows still require periodic reports.
        Age stops mattering once there is nothing left to learn. A workflow that has
        left the queue with every node in a status it cannot leave will never report
        again, so expiring its statuses only sends the views to the scheduler to be
        told the same thing -- and a finished workflow is the one whose working
        directory is most likely to have been cleaned up, which is what reading a
        node's live status needs.

tethys_compute/models/condor/condor_workflow.py:124

  • This check misses custom terminal statuses: TethysJob stores those as OTH and is_terminal resolves the name from extended_properties. A CondorWorkflow reported with a registered custom terminal status will therefore keep expiring its complete node cache instead of satisfying the workflow-terminal condition. Use self.is_terminal here.
            self.cached_status in self.TERMINAL_STATUSES
            and self.all_node_statuses_are_terminal
  • Files reviewed: 3/3 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +148 to +151
return all(
self.STATUS_MAP.get(status) in self.TERMINAL_STATUS_CODES
for status in statuses
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants