[FLINK-31931] Return 404 for a gone TaskManager and stop the Web UI from re-polling it#28735
[FLINK-31931] Return 404 for a gone TaskManager and stop the Web UI from re-polling it#28735MartijnVisser wants to merge 2 commits into
Conversation
…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)
|
@MartijnVisser Can you add before and after images to the PR. |
|
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. |
Good question. I'd keep 404 here. The status comes from mapping |
What is the purpose of the change
Requesting
/taskmanagers/:taskmanageridfor 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 anUnhandled exceptionERROR 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
TaskManagerDetailsHandlerstrips the failure withstripCompletionException(notstripExecutionException), so theUnknownTaskExecutorExceptiontoNOT_FOUNDmapping actually fires; this matches the sibling TaskManager handlers. Previously a gone TaskManager produced a 500 plus a repeatedUnhandled exceptionERROR log.loadManagerno 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
TaskManagerDetailsHandlerTest#testUnknownTaskExecutorLeadsToNotFoundasserts a 404 for an unknown TaskManager id.Unhandled exceptionERROR log on the JobManager, versus the previous endless 500s.Does this pull request potentially affect one of the following parts:
@Public(Evolving): noDocumentation
AI Usage Disclosure