In this recipe, we will learn how Mesos communicates the task's state changes and how to handle these changes.
Right now, we should be able to spawn new tasks on a Mesos cluster but when we deploy tasks with an invalid command, such as false
:
curl -X POST "http://localhost:9090/?cmd=false"
This task immediately ends with an exit code equal to 1. In the Mesos UI, we can see these tasks have failed but it's not presented in completed tasks. This is because each task state update needs to be acknowledged by the framework.
In the subscribe
event switch, add the following case:
case Event_UPDATE: log.Printf("Handle update returns: %v", handleUpdate(event.Update))
Then implement the handleUpdate
function:
func handleUpdate(update *Event_Update) error { return call(&Call{ Type: Call_ACKNOWLEDGE.Enum(), Acknowledge: &Call_Acknowledge{ AgentId: update.Status.AgentId, TaskId: update...