Skip to content

Commit

Permalink
feat: add message column to kubectl get wf and argo list. Fixes #…
Browse files Browse the repository at this point in the history
…8307 (#8353)

Signed-off-by: Rohan Kumar <[email protected]>
  • Loading branch information
rohankmr414 committed Apr 10, 2022
1 parent ae38815 commit ee37656
Show file tree
Hide file tree
Showing 11 changed files with 48 additions and 9 deletions.
5 changes: 5 additions & 0 deletions manifests/base/crds/full/argoproj.io_workflows.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ spec:
jsonPath: .status.startedAt
name: Age
type: date
- description: Human readable message indicating details about why the workflow
is in this condition.
jsonPath: .status.message
name: Message
type: string
name: v1alpha1
schema:
openAPIV3Schema:
Expand Down
5 changes: 5 additions & 0 deletions manifests/base/crds/minimal/argoproj.io_workflows.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ spec:
jsonPath: .status.startedAt
name: Age
type: date
- description: Human readable message indicating details about why the workflow
is in this condition.
jsonPath: .status.message
name: Message
type: string
name: v1alpha1
schema:
openAPIV3Schema:
Expand Down
5 changes: 5 additions & 0 deletions manifests/install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,11 @@ spec:
jsonPath: .status.startedAt
name: Age
type: date
- description: Human readable message indicating details about why the workflow
is in this condition.
jsonPath: .status.message
name: Message
type: string
name: v1alpha1
schema:
openAPIV3Schema:
Expand Down
5 changes: 5 additions & 0 deletions manifests/namespace-install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,11 @@ spec:
jsonPath: .status.startedAt
name: Age
type: date
- description: Human readable message indicating details about why the workflow
is in this condition.
jsonPath: .status.message
name: Message
type: string
name: v1alpha1
schema:
openAPIV3Schema:
Expand Down
5 changes: 5 additions & 0 deletions manifests/quick-start-minimal.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,11 @@ spec:
jsonPath: .status.startedAt
name: Age
type: date
- description: Human readable message indicating details about why the workflow
is in this condition.
jsonPath: .status.message
name: Message
type: string
name: v1alpha1
schema:
openAPIV3Schema:
Expand Down
5 changes: 5 additions & 0 deletions manifests/quick-start-mysql.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,11 @@ spec:
jsonPath: .status.startedAt
name: Age
type: date
- description: Human readable message indicating details about why the workflow
is in this condition.
jsonPath: .status.message
name: Message
type: string
name: v1alpha1
schema:
openAPIV3Schema:
Expand Down
5 changes: 5 additions & 0 deletions manifests/quick-start-postgres.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,11 @@ spec:
jsonPath: .status.startedAt
name: Age
type: date
- description: Human readable message indicating details about why the workflow
is in this condition.
jsonPath: .status.message
name: Message
type: string
name: v1alpha1
schema:
openAPIV3Schema:
Expand Down
1 change: 1 addition & 0 deletions pkg/apis/workflow/v1alpha1/generated.proto

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pkg/apis/workflow/v1alpha1/workflow_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ const (
// +kubebuilder:resource:shortName=wf
// +kubebuilder:printcolumn:name="Status",type="string",JSONPath=".status.phase",description="Status of the workflow"
// +kubebuilder:printcolumn:name="Age",type="date",format="date-time",JSONPath=".status.startedAt",description="When the workflow was started"
// +kubebuilder:printcolumn:name="Message",type="string",JSONPath=".status.message",description="Human readable message indicating details about why the workflow is in this condition."
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
type Workflow struct {
metav1.TypeMeta `json:",inline"`
Expand Down
5 changes: 3 additions & 2 deletions util/printer/workflow-printer.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func printTable(wfList []wfv1.Workflow, out io.Writer, opts PrintOpts) {
if opts.Namespace {
_, _ = fmt.Fprint(w, "NAMESPACE\t")
}
_, _ = fmt.Fprint(w, "NAME\tSTATUS\tAGE\tDURATION\tPRIORITY")
_, _ = fmt.Fprint(w, "NAME\tSTATUS\tAGE\tDURATION\tPRIORITY\tMESSAGE")
if opts.Output == "wide" {
_, _ = fmt.Fprint(w, "\tP/R/C\tPARAMETERS")
}
Expand All @@ -72,14 +72,15 @@ func printTable(wfList []wfv1.Workflow, out io.Writer, opts PrintOpts) {
for _, wf := range wfList {
ageStr := humanize.RelativeDurationShort(wf.ObjectMeta.CreationTimestamp.Time, time.Now())
durationStr := humanize.RelativeDurationShort(wf.Status.StartedAt.Time, wf.Status.FinishedAt.Time)
messageStr := wf.Status.Message
if opts.Namespace {
_, _ = fmt.Fprintf(w, "%s\t", wf.ObjectMeta.Namespace)
}
var priority int
if wf.Spec.Priority != nil {
priority = int(*wf.Spec.Priority)
}
_, _ = fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%d", wf.ObjectMeta.Name, WorkflowStatus(&wf), ageStr, durationStr, priority)
_, _ = fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%d\t%s", wf.ObjectMeta.Name, WorkflowStatus(&wf), ageStr, durationStr, priority, messageStr)
if opts.Output == "wide" {
pending, running, completed := countPendingRunningCompletedNodes(&wf)
_, _ = fmt.Fprintf(w, "\t%d/%d/%d", pending, running, completed)
Expand Down
15 changes: 8 additions & 7 deletions util/printer/workflow-printer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ func TestPrintWorkflows(t *testing.T) {
"n4": {Phase: wfv1.NodeFailed, Type: wfv1.NodeTypePod, TemplateName: "t0"},
"n5": {Phase: wfv1.NodeError, Type: wfv1.NodeTypePod, TemplateName: "t0"},
},
Message: "test-message",
},
},
}
Expand All @@ -54,28 +55,28 @@ func TestPrintWorkflows(t *testing.T) {
t.Run("Default", func(t *testing.T) {
var b bytes.Buffer
assert.NoError(t, PrintWorkflows(workflows, &b, PrintOpts{}))
assert.Equal(t, `NAME STATUS AGE DURATION PRIORITY
my-wf Running 0s 3s 2
assert.Equal(t, `NAME STATUS AGE DURATION PRIORITY MESSAGE
my-wf Running 0s 3s 2 test-message
`, b.String())
})
t.Run("NoHeader", func(t *testing.T) {
var b bytes.Buffer
assert.NoError(t, PrintWorkflows(workflows, &b, PrintOpts{NoHeaders: true}))
assert.Equal(t, `my-wf Running 0s 3s 2
assert.Equal(t, `my-wf Running 0s 3s 2 test-message
`, b.String())
})
t.Run("Namespace", func(t *testing.T) {
var b bytes.Buffer
assert.NoError(t, PrintWorkflows(workflows, &b, PrintOpts{Namespace: true}))
assert.Equal(t, `NAMESPACE NAME STATUS AGE DURATION PRIORITY
my-ns my-wf Running 0s 3s 2
assert.Equal(t, `NAMESPACE NAME STATUS AGE DURATION PRIORITY MESSAGE
my-ns my-wf Running 0s 3s 2 test-message
`, b.String())
})
t.Run("Wide", func(t *testing.T) {
var b bytes.Buffer
assert.NoError(t, PrintWorkflows(workflows, &b, PrintOpts{Output: "wide"}))
assert.Equal(t, `NAME STATUS AGE DURATION PRIORITY P/R/C PARAMETERS
my-wf Running 0s 3s 2 1/2/3 my-param=my-value
assert.Equal(t, `NAME STATUS AGE DURATION PRIORITY MESSAGE P/R/C PARAMETERS
my-wf Running 0s 3s 2 test-message 1/2/3 my-param=my-value
`, b.String())
})
t.Run("Name", func(t *testing.T) {
Expand Down

0 comments on commit ee37656

Please sign in to comment.