Beispiel #1
0
// KillTask is called when the executor receives a request to kill a task.
func (k *KubernetesExecutor) KillTask(driver mesos.ExecutorDriver, taskId *mesos.TaskID) {
	log.Infof("Kill task %v\n", taskId)

	if !k.registered {
		log.Warningf("Ignore kill task because the executor is disconnected\n")
		return
	}

	tid := taskId.GetValue()
	if _, ok := k.tasks[tid]; !ok {
		log.Infof("Failed to kill task, unknown task %v\n", tid)
		return
	}
	delete(k.tasks, tid)

	// Send the pod updates to the channel.
	// TODO(yifan): Replace SET with REMOVE when it's implemented.
	update := kubelet.PodUpdate{
		Pods: []kubelet.Pod{},
		Op:   kubelet.SET,
	}
	k.updateChan <- update
	// TODO(yifan): Check the result of the kill event.

	k.sendStatusUpdate(taskId, mesos.TaskState_TASK_KILLED, "Task killed")
}
Beispiel #2
0
func (self *ShellExecutor) OnKillTask(driver *mesos.ExecutorDriver, tid mesos.TaskID) {
	taskId := tid.GetValue()
	log.Warningf("OnKillTask %s", taskId)
	self.lock.Lock()
	defer self.lock.Unlock()
	if contex, ok := self.process[taskId]; ok {
		ret, _ := exec.Command("pgrep", "-P", strconv.Itoa(contex.cmd.Process.Pid)).Output()
		log.Debug("children process", string(ret))
		log.Debug("pid", contex.cmd.Process.Pid)
		ret, err := exec.Command("pkill", "-P", strconv.Itoa(contex.cmd.Process.Pid)).Output()
		if err != nil {
			log.Errorf("kill taskId %s failed, err:%v", taskId, err)
		}
		log.Debugf("kill taskId %s result %v", taskId, ret)
		contex.statusFile.Stop()
	}

	//log.Error("send kill state")
	//self.sendStatusUpdate(tid.GetValue(), mesos.TaskState_TASK_KILLED, "")
}