Current state is the task lifecycle state recorded from a worker’s actual condition. A manager treats the worker as authoritative for this state, rather than trusting only its own record of requested work. section 7.3.3 section 7.6
The system keeps two related views: a task event represents desired state, while the worker datastore represents current state. The manager periodically queries each worker and copies back state, start time, finish time, and container ID. section 7.6 section 7.3.3
Treat current state carefully at API and storage boundaries:
- When a stop request arrives, copy the stored task before changing its state and enqueueing it as desired work. section 5.4
- Avoid mutating the datastore object directly: datastore values are pointers, so doing so would make current and desired state identical prematurely. section 5.4
Stopping a task
A stop handler finds the task in the worker datastore, copies it, changes the copy to task.Completed, and places the copy on the queue. The stored task continues representing current state until worker processing updates it. section 5.4
