(env cliconfig.Environment, apiName string, jobID string)
| 138 | } |
| 139 | |
| 140 | func getTaskJob(env cliconfig.Environment, apiName string, jobID string) (string, error) { |
| 141 | resp, err := cluster.GetTaskJob(MustGetOperatorConfig(env.Name), apiName, jobID) |
| 142 | if err != nil { |
| 143 | return "", err |
| 144 | } |
| 145 | |
| 146 | var bytes []byte |
| 147 | if _flagOutput == flags.JSONOutputType { |
| 148 | bytes, err = libjson.Marshal(resp) |
| 149 | } else if _flagOutput == flags.YAMLOutputType { |
| 150 | bytes, err = yaml.Marshal(resp) |
| 151 | } |
| 152 | if err != nil { |
| 153 | return "", err |
| 154 | } |
| 155 | if _flagOutput == flags.JSONOutputType || _flagOutput == flags.YAMLOutputType { |
| 156 | return string(bytes), nil |
| 157 | } |
| 158 | |
| 159 | job := resp.JobStatus |
| 160 | |
| 161 | out := "" |
| 162 | |
| 163 | jobIntroTable := table.KeyValuePairs{} |
| 164 | jobIntroTable.Add("job id", job.ID) |
| 165 | jobIntroTable.Add("status", job.Status.Message()) |
| 166 | out += jobIntroTable.String(&table.KeyValuePairOpts{BoldKeys: pointer.Bool(true)}) |
| 167 | |
| 168 | jobTimingTable := table.KeyValuePairs{} |
| 169 | jobTimingTable.Add("start time", job.StartTime.Format(_timeFormat)) |
| 170 | |
| 171 | jobEndTime := time.Now() |
| 172 | if job.EndTime != nil { |
| 173 | jobTimingTable.Add("end time", job.EndTime.Format(_timeFormat)) |
| 174 | jobEndTime = *job.EndTime |
| 175 | } else { |
| 176 | jobTimingTable.Add("end time", "-") |
| 177 | } |
| 178 | duration := jobEndTime.Sub(job.StartTime).Truncate(time.Second).String() |
| 179 | jobTimingTable.Add("duration", duration) |
| 180 | |
| 181 | out += "\n" + jobTimingTable.String(&table.KeyValuePairOpts{BoldKeys: pointer.Bool(true)}) |
| 182 | |
| 183 | if job.Status.IsCompleted() { |
| 184 | out += "\n" + "worker stats are not available because this job is not currently running\n" |
| 185 | } else { |
| 186 | out += titleStr("worker stats") |
| 187 | if job.WorkerCounts != nil { |
| 188 | t := table.Table{ |
| 189 | Headers: []table.Header{ |
| 190 | {Title: "Requested"}, |
| 191 | {Title: "Pending"}, |
| 192 | {Title: "Creating"}, |
| 193 | {Title: "Ready"}, |
| 194 | {Title: "NotReady"}, |
| 195 | {Title: "ErrImagePull", Hidden: job.WorkerCounts.ErrImagePull == 0}, |
| 196 | {Title: "Terminating", Hidden: job.WorkerCounts.Terminating == 0}, |
| 197 | {Title: "Failed", Hidden: job.WorkerCounts.Failed == 0}, |
no test coverage detected