From 0451566159546425524cf966f57d4f86d43f4db8 Mon Sep 17 00:00:00 2001 From: bay1ts Date: Mon, 4 Dec 2017 18:12:48 +0800 Subject: [PATCH] [FIX] Fix not enough arguments problem --- pkg/grctl/cmd/init.go | 4 +- pkg/grctl/cmd/installStatus.go | 89 ++++++++++++++++------------------ 2 files changed, 43 insertions(+), 50 deletions(-) diff --git a/pkg/grctl/cmd/init.go b/pkg/grctl/cmd/init.go index baa1145b0..72b243038 100644 --- a/pkg/grctl/cmd/init.go +++ b/pkg/grctl/cmd/init.go @@ -86,14 +86,14 @@ func NewCmdInstallStatus() cli.Command { for _,v:=range tasks { for _,vs:=range v.Status{ if vs.Status=="start"||vs.Status=="create"{ - Status(v.ID,nil) + Status(v.ID) return nil } } } }else { - Status(taskID,nil) + Status(taskID) } return nil }, diff --git a/pkg/grctl/cmd/installStatus.go b/pkg/grctl/cmd/installStatus.go index bd4026657..af80dacb5 100644 --- a/pkg/grctl/cmd/installStatus.go +++ b/pkg/grctl/cmd/installStatus.go @@ -193,7 +193,7 @@ func NewCmdInstall() cli.Command { // return c //} -func Status(task string,nodes []string) { +func Status(task string) { taskE:=clients.NodeClient.Tasks().Get(task) lastState:="" checkFail:=0 @@ -208,54 +208,47 @@ func Status(task string,nodes []string) { } continue } - for k,v:=range status.Status{ - for _,nid:=range nodes { - if k==nid { - - if strings.Contains(v.Status, "error")||strings.Contains(v.CompleStatus,"Failure")||strings.Contains(v.CompleStatus,"Unknow") { - checkFail+=1 - fmt.Errorf("error executing task %s",task) - taskE:=clients.NodeClient.Tasks().Get(task) - for _,v:=range taskE.Task.OutPut{ - fmt.Printf("on %s :\n %s",v.NodeID,v.Body) - } - os.Exit(1) - } - if v.Status!="complete"&&v.CompleStatus!="Success" { - if lastState!=v.Status{ - fmt.Printf("task %s is %s\n",task,v.Status) - }else{ - fmt.Print("..") - } - lastState=v.Status - }else { - fmt.Printf("task %s is %s %s\n",task,v.Status,v.CompleStatus) - lastState=v.Status - taskFinished:=clients.NodeClient.Tasks().Get(task) - var nextTasks []string - for _,v:=range taskFinished.Task.OutPut{ - for _,sv:=range v.Status{ - if sv.NextTask == nil ||len(sv.NextTask)==0{ - continue - }else{ - for _,v:=range sv.NextTask{ - nextTasks=append(nextTasks,v) - } - } - } - } - if len(nextTasks) > 0 { - fmt.Printf("next will install %v \n",nextTasks) - for _,v:=range nextTasks{ - Status(v,nodes) - } - } - return - } - + for _,v:=range status.Status{ + if strings.Contains(v.Status, "error")||strings.Contains(v.CompleStatus,"Failure")||strings.Contains(v.CompleStatus,"Unknow") { + checkFail+=1 + fmt.Errorf("error executing task %s",task) + taskE:=clients.NodeClient.Tasks().Get(task) + for _,v:=range taskE.Task.OutPut{ + fmt.Printf("on %s :\n %s",v.NodeID,v.Body) } + os.Exit(1) + } + if v.Status!="complete"&&v.CompleStatus!="Success" { + if lastState!=v.Status{ + fmt.Printf("task %s is %s\n",task,v.Status) + }else{ + fmt.Print("..") + } + lastState=v.Status + }else { + fmt.Printf("task %s is %s %s\n",task,v.Status,v.CompleStatus) + lastState=v.Status + taskFinished:=clients.NodeClient.Tasks().Get(task) + var nextTasks []string + for _,v:=range taskFinished.Task.OutPut{ + for _,sv:=range v.Status{ + if sv.NextTask == nil ||len(sv.NextTask)==0{ + continue + }else{ + for _,v:=range sv.NextTask{ + nextTasks=append(nextTasks,v) + } + } + } + } + if len(nextTasks) > 0 { + fmt.Printf("next will install %v \n",nextTasks) + for _,v:=range nextTasks{ + Status(v) + } + } + return } - } checkFail=0 } @@ -274,7 +267,7 @@ func Task(c *cli.Context,task string,status bool) error { logrus.Errorf("error exec task:%s,details %s",task,err.Error()) return err } - Status(task,nodes) + Status(task) return nil }