Skip to content

[FLINK-31931] Return 404 for a gone TaskManager and stop the Web UI from re-polling it#28735

Open
MartijnVisser wants to merge 2 commits into
apache:masterfrom
MartijnVisser:fix-tm-details-404
Open

[FLINK-31931] Return 404 for a gone TaskManager and stop the Web UI from re-polling it#28735
MartijnVisser wants to merge 2 commits into
apache:masterfrom
MartijnVisser:fix-tm-details-404

Conversation

@MartijnVisser

Copy link
Copy Markdown
Contributor

What is the purpose of the change

Requesting /taskmanagers/:taskmanagerid for a TaskManager that is no longer registered (for example after a TaskManager is lost while the Web UI's TaskManager page keeps polling it, or when following a link from a job's exception history) returned HTTP 500 with an Unhandled exception ERROR log on the JobManager, and the Web UI kept re-requesting it indefinitely.

This returns a proper 404 for a gone TaskManager and stops the futile polling, showing a clear "TaskManager not available" notice instead of an endless skeleton.

This supersedes #22542 (thanks @JunRuiLee for the original investigation). That PR addressed FLINK-31931 by preventing the exception-history page from linking to a gone TaskManager. Handling the not-found at the destination instead is more robust: it also covers deep-links and a TaskManager dying while its page is open, it is not racy (a TaskManager can disappear right after the link is rendered), and it keeps the link informative for the common case where the exception's TaskManager is already gone by the time the history is viewed.

Brief change log

  • [runtime/rest] TaskManagerDetailsHandler strips the failure with stripCompletionException (not stripExecutionException), so the UnknownTaskExecutorException to NOT_FOUND mapping actually fires; this matches the sibling TaskManager handlers. Previously a gone TaskManager produced a 500 plus a repeated Unhandled exception ERROR log.
  • [runtime-web] loadManager no longer swallows errors; a shared poll helper stops polling once the backend reports the TaskManager is gone (404), while transient errors keep retrying. The TaskManager status view shows a "TaskManager not available" notice and the metric cards are hidden instead of rendering blank tables.

Verifying this change

  • New unit test TaskManagerDetailsHandlerTest#testUnknownTaskExecutorLeadsToNotFound asserts a 404 for an unknown TaskManager id.
  • New Vitest specs cover the poll helper (stops on 404, keeps retrying on transient errors) and the status/metrics components (notice shown / cards hidden on 404).
  • Manually verified on a standalone cluster: killing a TaskManager now yields a single 404 that stops repeating, a "TaskManager not available" notice, and no Unhandled exception ERROR log on the JobManager, versus the previous endless 500s.

Does this pull request potentially affect one of the following parts:

  • Dependencies (does it add or upgrade a dependency): no
  • The public API, i.e., is any changed class annotated with @Public(Evolving): no
  • The serializers: no
  • The runtime per-record code paths (performance sensitive): no
  • Anything that affects deployment or recovery: no
  • The S3 file system connector: no

Documentation

  • Does this pull request introduce a new feature? no
  • If yes, how is the feature documented? not applicable

AI Usage Disclosure

  • Claude Code

…kManager in TaskManagerDetailsHandler

TaskManagerDetailsHandler stripped the failure from its exceptionally stage
with stripExecutionException, which does not unwrap the CompletionException
that a CompletableFuture reports failures with. The
instanceof UnknownTaskExecutorException check therefore never matched, so a
request for a gone TaskManager returned 500 with an "Unhandled exception"
ERROR log instead of the intended 404. Use stripCompletionException, as the
sibling TaskManager handlers already do.

Generated-by: Claude Opus 4.8 (1M context)
The TaskManager status and metrics views re-requested the TaskManager detail
on every refresh tick, so a TaskManager that had been lost kept generating
failing /taskmanagers/<id> requests indefinitely. loadManager also swallowed
every error, hiding the not-found case from callers.

Let loadManager propagate errors and share a small poll helper that stops
once the backend reports the TaskManager is gone (404), while transient
errors keep retrying. The status view then shows a "no longer available"
notice instead of an endless skeleton, and the metrics cards are hidden
instead of rendering blank tables.

Generated-by: Claude Opus 4.8 (1M context)
@flinkbot

flinkbot commented Jul 13, 2026

Copy link
Copy Markdown
Collaborator

CI report:

Bot commands The @flinkbot bot supports the following commands:
  • @flinkbot run azure re-run the last Azure build

@spuru9

spuru9 commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

@MartijnVisser Can you add before and after images to the PR.

@doguscan-namal

Copy link
Copy Markdown

Is "410 Gone" a better response code here if we knew the TaskManager was there but is gone and this is permanent? https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/410

Otherwise, 404 default should be fine.

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.

4 participants