From 1da7f43219e409b936e6a8014c52a8d976aeab22 Mon Sep 17 00:00:00 2001 From: thandayuthapani Date: Mon, 13 May 2019 17:58:40 +0530 Subject: [PATCH] Add JobType in cli command --- pkg/apis/batch/v1alpha1/labels.go | 1 + pkg/cli/job/list.go | 13 +++++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/pkg/apis/batch/v1alpha1/labels.go b/pkg/apis/batch/v1alpha1/labels.go index 99e016f11e..a0fdfbd1f2 100644 --- a/pkg/apis/batch/v1alpha1/labels.go +++ b/pkg/apis/batch/v1alpha1/labels.go @@ -22,4 +22,5 @@ const ( JobNamespaceKey = "volcano.sh/job-namespace" DefaultTaskSpec = "default" JobVersion = "volcano.sh/job-version" + JobTypeKey = "volcano.sh/job-type" ) diff --git a/pkg/cli/job/list.go b/pkg/cli/job/list.go index 7ca63522d8..bf6afac074 100644 --- a/pkg/cli/job/list.go +++ b/pkg/cli/job/list.go @@ -45,6 +45,7 @@ const ( Succeeded string = "Succeeded" Failed string = "Failed" RetryCount string = "RetryCount" + JobType string = "JobType" ) var listJobFlags = &listFlags{} @@ -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) } @@ -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)