func (self *manager) HandleStatusMessage(statusMessage *mesosproto.StatusUpdateMessage) { glog.Infof("Status Update %v\n", statusMessage) status := statusMessage.GetUpdate().GetStatus() switch { case *status.State == mesosproto.TaskState_TASK_RUNNING: task, _ := taskRegistry.Fetch(status.GetTaskId().GetValue()) task.Running = true task.SlaveID = status.GetSlaveId().GetValue() managerInterface.UpdateTaskWithDockerInfo(task, status.GetData()) case *status.State == mesosproto.TaskState_TASK_FAILED: taskRegistry.Delete(status.GetTaskId().GetValue()) glog.Infoln("Task Failed: ", status.GetTaskId().GetValue()) case *status.State == mesosproto.TaskState_TASK_LOST: switch { case strings.Contains(status.GetMessage(), "Task has duplicate ID"): // ignore case strings.Contains(status.GetMessage(), "is no longer valid"): task, _ := taskRegistry.Fetch(status.GetTaskId().GetValue()) task.RequestSent = false default: taskRegistry.Delete(status.GetTaskId().GetValue()) } glog.Infoln("Task Lost: ", status.GetTaskId().GetValue()) case *status.State == mesosproto.TaskState_TASK_FINISHED: taskRegistry.Delete(status.GetTaskId().GetValue()) glog.Infoln("Task Finished: ", status.GetTaskId().GetValue()) case *status.State == mesosproto.TaskState_TASK_KILLED: taskRegistry.Delete(status.GetTaskId().GetValue()) glog.Infoln("Task Killed: ", status.GetTaskId().GetValue()) } self.acknowledgeStatusUpdate(statusMessage) }
func (self *manager) acknowledgeStatusUpdate(statusUpdate *mesosproto.StatusUpdateMessage) { message := &mesosproto.StatusUpdateAcknowledgementMessage{ FrameworkId: statusUpdate.GetUpdate().FrameworkId, SlaveId: statusUpdate.GetUpdate().Status.SlaveId, TaskId: statusUpdate.GetUpdate().Status.TaskId, Uuid: statusUpdate.GetUpdate().Uuid, } messagePackage := communication.NewMessage(self.masterUPID, message, nil) if err := communication.SendMessageToMesos(self.selfUPID, messagePackage); err != nil { glog.Errorf("Failed to send StatusAccept message: %v\n", err) } }