Skip to content

Commit d8194a4

Browse files
authored
DAOS-13520 control: Show unchecked pools in dmg check query (#17091)
- Include listing of unchecked pools returned by dmg check query, even in non-verbose mode. Signed-off-by: Kris Jacque <[email protected]>
1 parent 3d8f848 commit d8194a4

File tree

2 files changed

+106
-21
lines changed

2 files changed

+106
-21
lines changed

src/control/cmd/dmg/pretty/check.go

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -50,26 +50,40 @@ func PrintCheckerPolicies(out io.Writer, flags control.SystemCheckFlags, policie
5050
tf.Format(table)
5151
}
5252

53-
func countResultPools(resp *control.SystemCheckQueryResp) int {
53+
func countResultPools(resp *control.SystemCheckQueryResp) (int, int) {
5454
if resp == nil {
55-
return 0
55+
return 0, 0
5656
}
5757

58-
poolMap := make(map[string]struct{})
58+
checkedMap := make(map[string]struct{})
59+
uncheckedMap := make(map[string]struct{})
5960
for _, pool := range resp.Pools {
60-
// Don't include pools that were not checked.
6161
if pool.Unchecked() {
62-
continue
62+
uncheckedMap[pool.UUID] = struct{}{}
63+
} else {
64+
checkedMap[pool.UUID] = struct{}{}
6365
}
64-
poolMap[pool.UUID] = struct{}{}
6566
}
6667
for _, report := range resp.Reports {
6768
if report.IsRemovedPool() && report.PoolUuid != "" {
68-
poolMap[report.PoolUuid] = struct{}{}
69+
checkedMap[report.PoolUuid] = struct{}{}
6970
}
7071
}
7172

72-
return len(poolMap)
73+
return len(checkedMap), len(uncheckedMap)
74+
}
75+
76+
func printSystemCheckPoolInfo(out io.Writer, pools []*control.SystemCheckPoolInfo, verbose bool) {
77+
if verbose {
78+
fmt.Fprintln(out, "\nPer-Pool Checker Info:")
79+
} else {
80+
fmt.Fprintln(out, "\nUnchecked Pools:")
81+
}
82+
for _, pool := range pools {
83+
if verbose || pool.Unchecked() {
84+
fmt.Fprintf(out, " %+v\n", pool)
85+
}
86+
}
7387
}
7488

7589
// PrintCheckQueryResp prints the checker results to the console.
@@ -91,26 +105,23 @@ func PrintCheckQueryResp(out io.Writer, resp *control.SystemCheckQueryResp, verb
91105
// should show the number of pools being checked. If the checker has completed,
92106
// we should show the number of unique pools found in the reports.
93107
action := "Checking"
94-
poolCount := countResultPools(resp)
108+
checkedCount, uncheckedCount := countResultPools(resp)
95109
if resp.Status == control.SystemCheckStatusCompleted {
96110
action = "Checked"
97111
}
98-
if poolCount > 0 {
99-
fmt.Fprintf(out, " %s %s\n", action, english.Plural(poolCount, "pool", ""))
112+
if checkedCount > 0 {
113+
fmt.Fprintf(out, " %s %s\n", action, english.Plural(checkedCount, "pool", ""))
100114
}
101115

102-
if len(resp.Pools) > 0 && verbose {
116+
if len(resp.Pools) > 0 && (verbose || uncheckedCount > 0) {
103117
pools := make([]*control.SystemCheckPoolInfo, 0, len(resp.Pools))
104118
for _, pool := range resp.Pools {
105119
pools = append(pools, pool)
106120
}
107121
sort.Slice(pools, func(i, j int) bool {
108122
return pools[i].UUID < pools[j].UUID
109123
})
110-
fmt.Fprintln(out, "\nPer-Pool Checker Info:")
111-
for _, pool := range pools {
112-
fmt.Fprintf(out, " %+v\n", pool)
113-
}
124+
printSystemCheckPoolInfo(out, pools, verbose)
114125
}
115126

116127
fmt.Fprintln(out)

src/control/cmd/dmg/pretty/check_test.go

Lines changed: 79 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -203,11 +203,6 @@ Inconsistency Reports:
203203
Phase: chkpb.CheckScanPhase_CSP_DONE.String(),
204204
StartTime: checkTime,
205205
},
206-
"pool-5": {
207-
UUID: "pool-5",
208-
Status: chkpb.CheckPoolStatus_CPS_UNCHECKED.String(),
209-
Phase: chkpb.CheckScanPhase_CSP_PREPARE.String(),
210-
},
211206
},
212207
Reports: []*control.SystemCheckReport{
213208
{
@@ -264,6 +259,85 @@ ID Class Pool Resolution
264259
0x3 POOL_LESS_SVC_WITHOUT_QUORUM pool-3 TRUST_PS
265260
0x4 POOL_NONEXIST_ON_ENGINE pool-4 DISCARD (dry run)
266261
262+
`,
263+
},
264+
"non-verbose with unchecked pools": {
265+
resp: &control.SystemCheckQueryResp{
266+
Status: control.SystemCheckStatusCompleted,
267+
ScanPhase: control.SystemCheckScanPhaseDone,
268+
Pools: map[string]*control.SystemCheckPoolInfo{
269+
"pool-1": {
270+
UUID: "pool-1",
271+
Status: chkpb.CheckPoolStatus_CPS_CHECKED.String(),
272+
Phase: chkpb.CheckScanPhase_CSP_DONE.String(),
273+
StartTime: checkTime,
274+
},
275+
"pool-2": {
276+
UUID: "pool-2",
277+
Status: chkpb.CheckPoolStatus_CPS_UNCHECKED.String(),
278+
Phase: chkpb.CheckScanPhase_CSP_DONE.String(),
279+
},
280+
"pool-3": {
281+
UUID: "pool-3",
282+
Status: chkpb.CheckPoolStatus_CPS_CHECKED.String(),
283+
Phase: chkpb.CheckScanPhase_CSP_DONE.String(),
284+
StartTime: checkTime,
285+
},
286+
"pool-5": {
287+
UUID: "pool-5",
288+
Status: chkpb.CheckPoolStatus_CPS_UNCHECKED.String(),
289+
Phase: chkpb.CheckScanPhase_CSP_PREPARE.String(),
290+
},
291+
},
292+
Reports: []*control.SystemCheckReport{
293+
{
294+
CheckReport: chkpb.CheckReport{
295+
Seq: 1,
296+
Class: chkpb.CheckInconsistClass_CIC_POOL_BAD_SVCL,
297+
Action: chkpb.CheckInconsistAction_CIA_IGNORE,
298+
Msg: "message 1",
299+
PoolUuid: "pool-1",
300+
},
301+
},
302+
{
303+
CheckReport: chkpb.CheckReport{
304+
Seq: 3,
305+
Class: chkpb.CheckInconsistClass_CIC_POOL_LESS_SVC_WITHOUT_QUORUM,
306+
Action: chkpb.CheckInconsistAction_CIA_TRUST_PS,
307+
Msg: "message 3",
308+
PoolUuid: "pool-3",
309+
},
310+
},
311+
{
312+
CheckReport: chkpb.CheckReport{
313+
Seq: 4,
314+
Result: int32(chkpb.CheckResult_DRY_RUN),
315+
Class: chkpb.CheckInconsistClass_CIC_POOL_NONEXIST_ON_ENGINE,
316+
Action: chkpb.CheckInconsistAction_CIA_DISCARD,
317+
Msg: "message 4",
318+
PoolUuid: "pool-4",
319+
},
320+
},
321+
},
322+
},
323+
expOut: `
324+
DAOS System Checker Info
325+
Current status: COMPLETED
326+
Current phase: DONE (Check completed)
327+
Checked 3 pools
328+
329+
Unchecked Pools:
330+
Pool pool-2: 0 ranks, status: CPS_UNCHECKED, phase: CSP_DONE
331+
Pool pool-5: 0 ranks, status: CPS_UNCHECKED, phase: CSP_PREPARE
332+
333+
Inconsistency Reports:
334+
- Resolved:
335+
ID Class Pool Resolution
336+
-- ----- ---- ----------
337+
0x1 POOL_BAD_SVCL pool-1 IGNORE
338+
0x3 POOL_LESS_SVC_WITHOUT_QUORUM pool-3 TRUST_PS
339+
0x4 POOL_NONEXIST_ON_ENGINE pool-4 DISCARD (dry run)
340+
267341
`,
268342
},
269343
"non-verbose with container": {

0 commit comments

Comments
 (0)