Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Toggle Faults filtering #2509

Merged
merged 3 commits into from
Feb 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions internal/dao/workload.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,14 @@ func (a *Workload) List(ctx context.Context, ns string) ([]runtime.Object, error
ts = m.CreationTimestamp
}
}
stat := status(gvr, r, table.ColumnDefinitions)
oo = append(oo, &render.WorkloadRes{Row: metav1.TableRow{Cells: []interface{}{
gvr.String(),
ns,
r.Cells[indexOf("Name", table.ColumnDefinitions)],
diagnose(gvr, r, table.ColumnDefinitions),
status(gvr, r, table.ColumnDefinitions),
stat,
readiness(gvr, r, table.ColumnDefinitions),
validity(stat),
ts,
}}})
}
Expand All @@ -138,7 +140,7 @@ func (a *Workload) List(ctx context.Context, ns string) ([]runtime.Object, error

// Helpers...

func status(gvr client.GVR, r metav1.TableRow, h []metav1.TableColumnDefinition) string {
func readiness(gvr client.GVR, r metav1.TableRow, h []metav1.TableColumnDefinition) string {
switch gvr {
case PodGVR, DpGVR, StsGVR:
return r.Cells[indexOf("Ready", h)].(string)
Expand All @@ -153,7 +155,7 @@ func status(gvr client.GVR, r metav1.TableRow, h []metav1.TableColumnDefinition)
return render.NAValue
}

func diagnose(gvr client.GVR, r metav1.TableRow, h []metav1.TableColumnDefinition) string {
func status(gvr client.GVR, r metav1.TableRow, h []metav1.TableColumnDefinition) string {
switch gvr {
case PodGVR:
if !isReady(r.Cells[indexOf("Ready", h)].(string)) || r.Cells[indexOf("Status", h)] != render.PhaseRunning {
Expand Down Expand Up @@ -187,6 +189,14 @@ func diagnose(gvr client.GVR, r metav1.TableRow, h []metav1.TableColumnDefinitio
return StatusOK
}

func validity(status string) string {
if status != "DEGRADED" {
return ""
}

return status
}

func isReady(s string) bool {
tt := strings.Split(s, "/")
if len(tt) != 2 {
Expand Down
4 changes: 3 additions & 1 deletion internal/render/workload.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ func (Workload) Header(string) Header {
HeaderColumn{Name: "NAME"},
HeaderColumn{Name: "STATUS"},
HeaderColumn{Name: "READY"},
HeaderColumn{Name: "VALID", Wide: true},
derailed marked this conversation as resolved.
Show resolved Hide resolved
HeaderColumn{Name: "AGE", Time: true},
}
}
Expand All @@ -62,7 +63,8 @@ func (n Workload) Render(o interface{}, _ string, r *Row) error {
res.Row.Cells[2].(string),
res.Row.Cells[3].(string),
res.Row.Cells[4].(string),
ToAge(res.Row.Cells[5].(metav1.Time)),
res.Row.Cells[5].(string),
ToAge(res.Row.Cells[6].(metav1.Time)),
}

return nil
Expand Down