This service is meant to replace Kibana's "pull" model of task scheduling, replacing it with a "push" model. It implements most of the high-level implementation details described in the task manager readme, with some tweaks:
- Every
{poll_interval}
milliseconds, check the{index}
for any tasks that need to be run:runAt
is pastattempts
is less than the configured threshold
- Attempt to claim the task by using optimistic concurrency to set:
- status to
running
startedAt
to nowretryAt
to next time task should retry if it times out and is still inrunning
status
- status to
- Determine which Kibana nodes have capacity to accept new tasks:
- Count how many tasks are still
running
and have not passed theirretryAt
time - Group them by
ownerId
, and only assign a new task to a KibanaownerId
with less than 10running
tasks
- Count how many tasks are still
- Push the task to Kibana using a
_run_now
API - If the task passes its
retryAt
without switching back toidle
, increment theattempts
count and reschedule it
When Kibana receives a task through _run_now
:
- Execute the task through the
ephemeralRunNow
function - If the task succeeds:
- If it is recurring, store the result of the run in the index, and reschedule
- If it is not recurring, remove it from the index
This creates a cyclical pattern of:
↱ → Elasticsearch → ↴
↑ ↓
Kibana ← ← ← Elastask
- Check out or cherry-pick
7bf01ac
from this Kibana feature branch. - In
kibana.dev.yml
, set:xpack.task_manager.ephemeral_tasks.enabled: true xpack.task_manager.unsafe.disable_task_claiming: true
- Run as many Kibana nodes from this branch as you want to test with
- Install Rustup from rustup.rs
- In this repo, run
cargo build
- Configure
elastask.yaml
as needed. By default, it will connect to a single kibana running atlocalhost:5601
, so be sure to add as many nodes as you'll be spinning up
- Start Elasticsearch and all your Kibana instances
- Run
cargo run