[JAY-749] Add a method to retrieve the list of tasks running on the Elasticsearch cluster#62
Merged
sergio-bobillier merged 5 commits intomasterfrom Mar 13, 2026
Merged
Conversation
The method allows the caller to retrieve information about the currently running tasks in the cluster. The underlying logic (the Elasticsearch::Tasks class) already existed, this change only makes it accessible through the client, instead of forcing the caller to initialize the class directly (which requires the client to be passed to it).
Moves the logic to retry Elasticsearch requests out of the Client class and into a new mixin module. This allows other classes to reuse the retry logic. The mixin will be used in an upcoming commit to decouple the Tasks class from the Client class and to add some new methods to it.
Changes the Tasks class' #by_id method to stop using the #task_by_id method of the Client class. This decouples the classes because it allows the Tasks class' dependencies to be injected. It no longer requires the Client class to define a method specifically for the Tasks class. And allows the Tasks class to be used with any client that can provide it with access to Elasticsearch's transport client. To make sure that the class has retained its functionality a very basic integration test is being added.
This method causes a coupling between Tasks and Client, which is not ideal. Hence it is being deprecated and will be removed in an upcomming commit.
222c8fb to
0857853
Compare
The method returns a Hash with information about the tasks running on the Elasticsearch cluster. The method accepts an optional argument to filter the tasks by their action type and a boolean argument that causes Elasticsearch to add detailed information about each task to the response when set to true.
0857853 to
4618796
Compare
sheputis
approved these changes
Mar 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The main objective in this pull request is to add the
#allmethod to theElasticsearch::Tasksclass. The method returns aHashwith the list of tasks currently running on the Elasticsearch cluster.The main use case for this method at the time of writing was to monitor the Segment Merge tasks since requests for such tasks pretty much always timeout due to long execution times.
To avoid code duplication and further coupling of the
Tasksand theClientclasses the following changes are also being made:#tasksmethod is being added to theClientclass. This method returns an instance of theTasksclass that is initialized with theClientinstance. This releaves the caller from having to initialize theTasksclass directly and allows for better encapsulation of theClientclass.Clientclass and into a newRetriableRequestmixin. The mixin is then being used by both theClientand theTasksclasses.Tasks#by_idmethod is being refactored to avoid using the#task_by_idmethod in theClientclass, which is beign deprecated and will be removed in a future commit.