From a04047b5a01918b72925a39e15c0047541cc45ed Mon Sep 17 00:00:00 2001 From: goodrain Date: Mon, 20 Nov 2017 15:24:24 +0800 Subject: [PATCH] [FIX] Adjust the dependent task state judgment strategy and increase the dynamic change static task --- pkg/node/api/controller/task_controller.go | 6 ++++++ pkg/node/api/router/router.go | 4 ++++ pkg/node/core/service/task_service.go | 5 +++++ pkg/node/masterserver/nodecluster.go | 1 - pkg/node/masterserver/task_engine.go | 2 +- 5 files changed, 16 insertions(+), 2 deletions(-) diff --git a/pkg/node/api/controller/task_controller.go b/pkg/node/api/controller/task_controller.go index e383797b1..ce70afbc7 100644 --- a/pkg/node/api/controller/task_controller.go +++ b/pkg/node/api/controller/task_controller.go @@ -115,3 +115,9 @@ func DeleteTask(w http.ResponseWriter, r *http.Request) { } httputil.ReturnSuccess(r, w, nil) } + +//ReloadStaticTasks 重新加载静态文件 +func ReloadStaticTasks(w http.ResponseWriter, r *http.Request) { + taskService.ReloadStaticTasks() + httputil.ReturnSuccess(r, w, nil) +} diff --git a/pkg/node/api/router/router.go b/pkg/node/api/router/router.go index e0f53dc0a..a8dcfa93a 100644 --- a/pkg/node/api/router/router.go +++ b/pkg/node/api/router/router.go @@ -105,6 +105,10 @@ func Routers(mode string) *chi.Mux { }) } }) + //重新加载task文件 + if mode == "master" { + r.Put("/-/taskreload", controller.ReloadStaticTasks) + } return r } diff --git a/pkg/node/core/service/task_service.go b/pkg/node/core/service/task_service.go index 4cd8ff9dd..019a317aa 100644 --- a/pkg/node/core/service/task_service.go +++ b/pkg/node/core/service/task_service.go @@ -183,6 +183,11 @@ func (ts *TaskService) ExecTask(taskID string, nodes []string) *utils.APIHandleE return nil } +//ReloadStaticTasks reload task +func (ts *TaskService) ReloadStaticTasks() { + ts.ms.TaskEngine.LoadStaticTask() +} + //TaskTempService 任务模版 type TaskTempService struct { SavePath string diff --git a/pkg/node/masterserver/nodecluster.go b/pkg/node/masterserver/nodecluster.go index 9cf06086a..daf647e78 100644 --- a/pkg/node/masterserver/nodecluster.go +++ b/pkg/node/masterserver/nodecluster.go @@ -149,7 +149,6 @@ func (n *NodeCluster) UpdateNode(node *model.HostNode) { n.lock.Lock() defer n.lock.Unlock() n.nodes[node.ID] = node - logrus.Debugf("Update node %s info to etcd", node.ID) n.client.Put(option.Config.NodePath+"/"+node.ID, node.String()) } func (n *NodeCluster) getNodeFromKV(kv *mvccpb.KeyValue) *model.HostNode { diff --git a/pkg/node/masterserver/task_engine.go b/pkg/node/masterserver/task_engine.go index b6c0a626a..abfc1846c 100644 --- a/pkg/node/masterserver/task_engine.go +++ b/pkg/node/masterserver/task_engine.go @@ -659,7 +659,7 @@ func (t *TaskEngine) waitScheduleTask(taskSchedulerInfo *TaskSchedulerInfo, task if nodestatus, ok := depTask.Status[taskSchedulerInfo.Node]; ok && nodestatus.CompleStatus == "Success" { result[i] = true continue - } else if ok && nodestatus.CompleStatus != "Success" { + } else if ok && nodestatus.CompleStatus != "" { taskSchedulerInfo.Status.Message = fmt.Sprintf("depend task %s Condition cannot be satisfied", depTask.ID) taskSchedulerInfo.Status.Status = "Failure" task.Scheduler.Status[taskSchedulerInfo.Node] = taskSchedulerInfo.Status