Skip to content

Commit

Permalink
Merge branch 'master' into release-0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
k82cn authored May 14, 2019
2 parents b4a75bd + f92becb commit 7ea9e76
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions pkg/apis/batch/v1alpha1/labels.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ const (
JobNamespaceKey = "volcano.sh/job-namespace"
DefaultTaskSpec = "default"
JobVersion = "volcano.sh/job-version"
JobTypeKey = "volcano.sh/job-type"
)
13 changes: 9 additions & 4 deletions pkg/cli/job/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const (
Succeeded string = "Succeeded"
Failed string = "Failed"
RetryCount string = "RetryCount"
JobType string = "JobType"
)

var listJobFlags = &listFlags{}
Expand Down Expand Up @@ -78,8 +79,8 @@ func ListJobs() error {

func PrintJobs(jobs *v1alpha1.JobList, writer io.Writer) {
maxNameLen := getMaxNameLen(jobs)
_, err := fmt.Fprintf(writer, fmt.Sprintf("%%-%ds%%-25s%%-12s%%-12s%%-6s%%-10s%%-10s%%-12s%%-10s%%-12s\n", maxNameLen),
Name, Creation, Phase, Replicas, Min, Pending, Running, Succeeded, Failed, RetryCount)
_, err := fmt.Fprintf(writer, fmt.Sprintf("%%-%ds%%-25s%%-12s%%-12s%%-12s%%-6s%%-10s%%-10s%%-12s%%-10s%%-12s\n", maxNameLen),
Name, Creation, Phase, JobType, Replicas, Min, Pending, Running, Succeeded, Failed, RetryCount)
if err != nil {
fmt.Printf("Failed to print list command result: %s.\n", err)
}
Expand All @@ -89,8 +90,12 @@ func PrintJobs(jobs *v1alpha1.JobList, writer io.Writer) {
for _, ts := range job.Spec.Tasks {
replicas += ts.Replicas
}
_, err = fmt.Fprintf(writer, fmt.Sprintf("%%-%ds%%-25s%%-12s%%-12d%%-6d%%-10d%%-10d%%-12d%%-10d%%-12d\n", maxNameLen),
job.Name, job.CreationTimestamp.Format("2006-01-02 15:04:05"), job.Status.State.Phase, replicas,
jobType := job.ObjectMeta.Labels[v1alpha1.JobTypeKey]
if jobType == "" {
jobType = "Batch"
}
_, err = fmt.Fprintf(writer, fmt.Sprintf("%%-%ds%%-25s%%-12s%%-12s%%-12d%%-6d%%-10d%%-10d%%-12d%%-10d%%-12d\n", maxNameLen),
job.Name, job.CreationTimestamp.Format("2006-01-02 15:04:05"), job.Status.State.Phase, jobType, replicas,
job.Status.MinAvailable, job.Status.Pending, job.Status.Running, job.Status.Succeeded, job.Status.Failed, job.Status.RetryCount)
if err != nil {
fmt.Printf("Failed to print list command result: %s.\n", err)
Expand Down

0 comments on commit 7ea9e76

Please sign in to comment.