Skip to content
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
5 changes: 3 additions & 2 deletions src/control/cmd/daos/pretty/pool.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// (C) Copyright 2020-2024 Intel Corporation.
// (C) Copyright 2025 Hewlett Packard Enterprise Development LP
// (C) Copyright 2025-2026 Hewlett Packard Enterprise Development LP
// (C) Copyright 2025 Google LLC
//
// SPDX-License-Identifier: BSD-2-Clause-Patent
Expand Down Expand Up @@ -136,7 +136,8 @@ func PrintPoolInfo(pi *daos.PoolInfo, out io.Writer) error {
fmt.Fprintf(w, "- Rebuild %s, %d objs, %d recs\n",
pi.Rebuild.State, pi.Rebuild.Objects, pi.Rebuild.Records)
} else {
fmt.Fprintf(w, "- Rebuild failed, status=%d\n", pi.Rebuild.Status)
fmt.Fprintf(w, "- Rebuild %s (state=%s, status=%d)\n",
pi.Rebuild.DerivedState, pi.Rebuild.State, pi.Rebuild.Status)
}
} else {
fmt.Fprintln(w, "- No rebuild status available.")
Expand Down
153 changes: 146 additions & 7 deletions src/control/cmd/daos/pretty/pool_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// (C) Copyright 2020-2024 Intel Corporation.
// (C) Copyright 2025 Hewlett Packard Enterprise Development LP
// (C) Copyright 2025-2026 Hewlett Packard Enterprise Development LP
//
// SPDX-License-Identifier: BSD-2-Clause-Patent
//
Expand Down Expand Up @@ -262,7 +262,7 @@ Pool space info:
Free: 1 B, min:0 B, max:0 B, mean:0 B
`, poolUUID.String()),
},
"rebuild failed": {
"rebuild failing": {
pi: &daos.PoolInfo{
QueryMask: daos.DefaultPoolQueryMask,
State: daos.PoolServiceStateTargetsExcluded,
Expand All @@ -275,10 +275,11 @@ Pool space info:
PoolLayoutVer: 1,
UpgradeLayoutVer: 2,
Rebuild: &daos.PoolRebuildStatus{
Status: 2,
State: daos.PoolRebuildStateBusy,
Objects: 42,
Records: 21,
Status: -2,
State: daos.PoolRebuildStateBusy,
DerivedState: daos.PoolRebuildStateFailing,
Objects: 42,
Records: 21,
},
TierStats: []*daos.StorageUsageStats{
{
Expand All @@ -298,7 +299,7 @@ Pool space info:
Pool %s, ntarget=2, disabled=1, leader=42, version=100, state=TargetsExcluded
Pool layout out of date (1 < 2) -- see `+backtickStr+` for details.
Pool health info:
- Rebuild failed, status=2
- Rebuild failing (state=busy, status=-2)
Pool space info:
- Target count:1
- Storage tier 0 (SCM):
Expand Down Expand Up @@ -355,6 +356,144 @@ Pool space info:
- Data storage:
Total size: 4 B
Free: 2 B, min:0 B, max:0 B, mean:0 B
`, poolUUID.String()),
},
"rebuild state idle": {
pi: &daos.PoolInfo{
UUID: poolUUID,
TotalTargets: 8,
ActiveTargets: 8,
State: daos.PoolServiceStateReady,
Rebuild: &daos.PoolRebuildStatus{
State: daos.PoolRebuildStateIdle,
DerivedState: daos.PoolRebuildStateIdle,
Status: 0,
Objects: 0,
Records: 0,
},
},
expPrintStr: fmt.Sprintf(`
Pool %s, ntarget=8, disabled=0, leader=0, version=0, state=Ready
Pool health info:
- Rebuild idle, 0 objs, 0 recs
`, poolUUID.String()),
},
"rebuild state stopped": {
pi: &daos.PoolInfo{
UUID: poolUUID,
TotalTargets: 8,
ActiveTargets: 8,
State: daos.PoolServiceStateReady,
Rebuild: &daos.PoolRebuildStatus{
State: daos.PoolRebuildStateDone,
DerivedState: daos.PoolRebuildStateStopped,
Status: int32(daos.OpCanceled),
Objects: 0,
Records: 0,
},
},
expPrintStr: fmt.Sprintf(`
Pool %s, ntarget=8, disabled=0, leader=0, version=0, state=Ready
Pool health info:
- Rebuild stopped (state=done, status=-2027)
`, poolUUID.String()),
},
"rebuild state done": {
pi: &daos.PoolInfo{
UUID: poolUUID,
TotalTargets: 8,
ActiveTargets: 8,
State: daos.PoolServiceStateReady,
Rebuild: &daos.PoolRebuildStatus{
State: daos.PoolRebuildStateDone,
DerivedState: daos.PoolRebuildStateDone,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this case need a DerivedState? I suppose if it is not needed, there is no harm to have it here though?

Copy link
Contributor Author

@tanabarr tanabarr Jan 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have to test for the value because it will be included in the structure returned. The value should always either match State or be one of the additional states.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I definitely trust your conclusion here, since you are much more familiar with the implementation & test infrastructure. I asked since I see only a test of the expected human-readable string output versus expected string. And in PrintPoolInfo() the pi.Rebuild.DerivedState is only printed when pi.Rebuild.Status != 0 . Does not seem worth changing even if technically the test case could get away without specifying DerivedState .

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do see your point and we don't need to specify, the main reason I've included it is to represent what would be expected in poolInfo responses from the control API but there is not a practical necessity.

Status: 0,
Objects: 200,
Records: 1000,
},
},
expPrintStr: fmt.Sprintf(`
Pool %s, ntarget=8, disabled=0, leader=0, version=0, state=Ready
Pool health info:
- Rebuild done, 200 objs, 1000 recs
`, poolUUID.String()),
},
"rebuild state failed": {
pi: &daos.PoolInfo{
UUID: poolUUID,
TotalTargets: 8,
ActiveTargets: 8,
State: daos.PoolServiceStateReady,
Rebuild: &daos.PoolRebuildStatus{
State: daos.PoolRebuildStateDone,
DerivedState: daos.PoolRebuildStateFailed,
Status: -1,
},
},
expPrintStr: fmt.Sprintf(`
Pool %s, ntarget=8, disabled=0, leader=0, version=0, state=Ready
Pool health info:
- Rebuild failed (state=done, status=-1)
`, poolUUID.String()),
},
"rebuild state busy": {
pi: &daos.PoolInfo{
UUID: poolUUID,
TotalTargets: 8,
ActiveTargets: 8,
State: daos.PoolServiceStateReady,
Rebuild: &daos.PoolRebuildStatus{
State: daos.PoolRebuildStateBusy,
DerivedState: daos.PoolRebuildStateBusy,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DerivedState may not be needed here either?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as above

Status: 0,
Objects: 150,
Records: 750,
},
},
expPrintStr: fmt.Sprintf(`
Pool %s, ntarget=8, disabled=0, leader=0, version=0, state=Ready
Pool health info:
- Rebuild busy, 150 objs, 750 recs
`, poolUUID.String()),
},
"rebuild state stopping": {
pi: &daos.PoolInfo{
UUID: poolUUID,
TotalTargets: 8,
ActiveTargets: 8,
State: daos.PoolServiceStateReady,
Rebuild: &daos.PoolRebuildStatus{
State: daos.PoolRebuildStateBusy,
DerivedState: daos.PoolRebuildStateStopping,
Status: int32(daos.OpCanceled),
Objects: 100,
Records: 500,
},
},
expPrintStr: fmt.Sprintf(`
Pool %s, ntarget=8, disabled=0, leader=0, version=0, state=Ready
Pool health info:
- Rebuild stopping (state=busy, status=-2027)
`, poolUUID.String()),
},
"rebuild state failing": {
pi: &daos.PoolInfo{
UUID: poolUUID,
TotalTargets: 8,
ActiveTargets: 8,
State: daos.PoolServiceStateReady,
Rebuild: &daos.PoolRebuildStatus{
State: daos.PoolRebuildStateBusy,
DerivedState: daos.PoolRebuildStateFailing,
Status: -1,
Objects: 75,
Records: 300,
},
},
expPrintStr: fmt.Sprintf(`
Pool %s, ntarget=8, disabled=0, leader=0, version=0, state=Ready
Pool health info:
- Rebuild failing (state=busy, status=-1)
`, poolUUID.String()),
},
} {
Expand Down
Loading
Loading