[SPARK-39620][Web UI] Use same condition in history server page and API to filter applications #37008
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
Updated REST API
/api/v1/applications, to use the same condition as history server page to filter completed/incomplete applications.Why are the changes needed?
When opening summary page, history server follows this logic:
Issue is that page and REST API are using different conditions to filter applications. In
HistoryPage, an application is considered as completed as long as the last attempt is completed. But inApplicationListResource, all attempts should be completed. This brings inconsistency and will cause issue in a corner case.In driver, event queues have capacity to protect memory. When there's too many events, some of them will be dropped and the event log file will be incomplete. For an application with multiple attempts, there's possibility that the last attempt is completed, but the previous attempts is considered as incomplete due to loss of application end event.
For this type of application, page thinks it is completed, but the API thinks it is still running. When opening summary page:
So the user won't be able to see this app in history server.
Does this PR introduce any user-facing change?
Yes, there will be a change on
/api/v1/applicationsAPI and history server summary page.When calling API, for application mentioned above, previously it is considered as running. After the change it is considered as completed. So the result will be different using same filter. But this change should be OK. Because attempts are executed sequentially and incrementally. So if an attempt with bigger ID is completed, the previous attempts can be considered as completed.
For history server summary page, previously user is not able to see the application. Now it will appear in the completed applications.
How was this patch tested?
Add a new unit test
HistoryServerPageSuite, which will check whetherHistoryPagebehaves the same asApplicationListResourcewhen filtering applications. To implement the test, there's a minor change ofHistoryPage, exposing a method calledshouldDisplayApplicationsto tell whether the summary page will display applications.The test verifies that:
HistoryPageshould not display applications, and API should return an empty list.HistoryPageshould display applications, and API should return a non-empty list.Currently 2 scenarios are included: