diff --git a/src/control/cmd/daos/pretty/health.go b/src/control/cmd/daos/pretty/health.go index 3d3f8ca035d..865f8ade316 100644 --- a/src/control/cmd/daos/pretty/health.go +++ b/src/control/cmd/daos/pretty/health.go @@ -132,12 +132,16 @@ func printPoolHealth(out io.Writer, pi *daos.PoolInfo, verbose bool) { fmt.Fprintf(out, "%s: %s\n", pi.Name(), strings.Join(healthStrings, ",")) } -func printContainerHealth(out io.Writer, ci *daos.ContainerInfo, verbose bool) { +func printContainerHealth(out io.Writer, pi *daos.PoolInfo, ci *daos.ContainerInfo, verbose bool) { if ci == nil { return } - fmt.Fprintf(out, "%s: %s\n", ci.Name(), txtfmt.Title(ci.Health)) + healthStr := txtfmt.Title(ci.Health) + if pi != nil && pi.DisabledTargets > 0 { + healthStr += " (Pool Degraded)" + } + fmt.Fprintf(out, "%s: %s\n", ci.Name(), healthStr) } // PrintSystemHealthInfo pretty-prints the supplied system health struct. @@ -180,7 +184,7 @@ func PrintSystemHealthInfo(out io.Writer, shi *daos.SystemHealthInfo, verbose bo iiiw := txtfmt.NewIndentWriter(iiw) if len(shi.Containers[pool.UUID]) > 0 { for _, cont := range shi.Containers[pool.UUID] { - printContainerHealth(iiiw, cont, verbose) + printContainerHealth(iiiw, pool, cont, verbose) } } else { fmt.Fprintln(iiiw, "No containers in pool.") diff --git a/src/control/cmd/daos/pretty/health_test.go b/src/control/cmd/daos/pretty/health_test.go index 909becb2b0f..19abf0cf9b7 100644 --- a/src/control/cmd/daos/pretty/health_test.go +++ b/src/control/cmd/daos/pretty/health_test.go @@ -291,12 +291,47 @@ var healthyContainer = &daos.ContainerInfo{ func TestPretty_printContainerHealth(t *testing.T) { for name, tc := range map[string]struct { + pi *daos.PoolInfo ci *daos.ContainerInfo verbose bool expPrintStr string }{ "nil ContainerInfo": {}, - "healthy": { + "unhealthy pool, healthy container": { + pi: &daos.PoolInfo{ + DisabledTargets: 1, + }, + ci: healthyContainer, + expPrintStr: fmt.Sprintf(` +%s: Healthy (Pool Degraded) +`, healthyContainer.ContainerLabel), + }, + "unhealthy pool, unhealthy container": { + pi: &daos.PoolInfo{ + DisabledTargets: 1, + }, + ci: func() *daos.ContainerInfo { + clone := *healthyContainer + clone.Health = "UNHEALTHY" + return &clone + }(), + expPrintStr: fmt.Sprintf(` +%s: Unhealthy (Pool Degraded) +`, healthyContainer.ContainerLabel), + }, + "healthy pool, unhealthy container": { + pi: healthyPool, + ci: func() *daos.ContainerInfo { + clone := *healthyContainer + clone.Health = "UNHEALTHY" + return &clone + }(), + expPrintStr: fmt.Sprintf(` +%s: Unhealthy +`, healthyContainer.ContainerLabel), + }, + "healthy pool, healthy container": { + pi: healthyPool, ci: healthyContainer, expPrintStr: fmt.Sprintf(` %s: Healthy @@ -305,7 +340,7 @@ func TestPretty_printContainerHealth(t *testing.T) { } { t.Run(name, func(t *testing.T) { var bld strings.Builder - printContainerHealth(&bld, tc.ci, tc.verbose) + printContainerHealth(&bld, tc.pi, tc.ci, tc.verbose) if diff := cmp.Diff(strings.TrimLeft(tc.expPrintStr, "\n"), bld.String()); diff != "" { t.Fatalf("unexpected pretty-printed string (-want, +got):\n%s\n", diff)