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

DAOS-7485 control: Implement system reint to act on all pools #15551

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions src/control/cmd/dmg/command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ func (bci *bridgeConnInvoker) InvokeUnaryRPC(ctx context.Context, uReq control.U
resp = control.MockMSResponse("", nil, &mgmtpb.PoolDrainResp{})
case *control.PoolExtendReq:
resp = control.MockMSResponse("", nil, &mgmtpb.PoolExtendResp{})
case *control.PoolReintegrateReq:
resp = control.MockMSResponse("", nil, &mgmtpb.PoolReintegrateResp{})
case *control.PoolReintReq:
resp = control.MockMSResponse("", nil, &mgmtpb.PoolReintResp{})
case *control.SystemCheckEnableReq:
resp = control.MockMSResponse("", nil, &mgmtpb.DaosResp{})
case *control.SystemCheckDisableReq:
Expand Down
3 changes: 2 additions & 1 deletion src/control/cmd/dmg/json_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ func TestDmg_JsonOutput(t *testing.T) {
testArgs = append(testArgs, "foo:bar")
case "system del-attr":
testArgs = append(testArgs, "foo")
case "system exclude", "system clear-exclude", "system drain":
case "system exclude", "system clear-exclude", "system drain",
"system reintegrate":
testArgs = append(testArgs, "--ranks", "0")
}

Expand Down
46 changes: 23 additions & 23 deletions src/control/cmd/dmg/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ type PoolCmd struct {
Extend poolExtendCmd `command:"extend" description:"Extend a DAOS pool to include new ranks."`
Exclude poolExcludeCmd `command:"exclude" description:"Exclude targets from a rank"`
Drain poolDrainCmd `command:"drain" description:"Drain targets from a rank"`
Reintegrate poolReintegrateCmd `command:"reintegrate" alias:"reint" description:"Reintegrate targets for a rank"`
Reint poolReintCmd `command:"reintegrate" alias:"reint" description:"Reintegrate targets for a rank"`
Query poolQueryCmd `command:"query" description:"Query a DAOS pool"`
QueryTargets poolQueryTargetsCmd `command:"query-targets" description:"Query pool target info"`
GetACL poolGetACLCmd `command:"get-acl" description:"Get a DAOS pool's Access Control List"`
Expand Down Expand Up @@ -162,7 +162,7 @@ func (psf *poolSizeFlag) UnmarshalFlag(fv string) error {
return psf.ByteSizeFlag.UnmarshalFlag(fv)
}

// PoolCreateCmd is the struct representing the command to create a DAOS pool.
// poolCreateCmd is the struct representing the command to create a DAOS pool.
type poolCreateCmd struct {
baseCmd
cfgCmd
Expand Down Expand Up @@ -401,7 +401,7 @@ func (cmd *poolCreateCmd) Execute(args []string) error {
return nil
}

// PoolListCmd represents the command to fetch a list of all DAOS pools in the system.
// poolListCmd represents the command to fetch a list of all DAOS pools in the system.
type poolListCmd struct {
baseCmd
cfgCmd
Expand Down Expand Up @@ -481,7 +481,7 @@ func (cmd *poolCmd) PoolID() *PoolID {
return &cmd.Args.Pool
}

// PoolDestroyCmd is the struct representing the command to destroy a DAOS pool.
// poolDestroyCmd is the struct representing the command to destroy a DAOS pool.
type poolDestroyCmd struct {
poolCmd
Recursive bool `short:"r" long:"recursive" description:"Remove pool with existing containers"`
Expand Down Expand Up @@ -509,7 +509,7 @@ func (cmd *poolDestroyCmd) Execute(args []string) error {
return err
}

// PoolEvictCmd is the struct representing the command to evict a DAOS pool.
// poolEvictCmd is the struct representing the command to evict a DAOS pool.
type poolEvictCmd struct {
poolCmd
}
Expand All @@ -530,7 +530,7 @@ func (cmd *poolEvictCmd) Execute(args []string) error {
return err
}

// PoolExcludeCmd is the struct representing the command to exclude a DAOS target.
// poolExcludeCmd is the struct representing the command to exclude a DAOS target.
type poolExcludeCmd struct {
poolCmd
Rank uint32 `long:"rank" required:"1" description:"Engine rank of the targets to be excluded"`
Expand Down Expand Up @@ -558,7 +558,7 @@ func (cmd *poolExcludeCmd) Execute(args []string) error {
return err
}

// PoolDrainCmd is the struct representing the command to Drain a DAOS target.
// poolDrainCmd is the struct representing the command to Drain a DAOS target.
type poolDrainCmd struct {
poolCmd
Rank uint32 `long:"rank" required:"1" description:"Engine rank of the targets to be drained"`
Expand Down Expand Up @@ -591,7 +591,7 @@ func (cmd *poolDrainCmd) Execute(args []string) error {
return err
}

// PoolExtendCmd is the struct representing the command to Extend a DAOS pool.
// poolExtendCmd is the struct representing the command to Extend a DAOS pool.
type poolExtendCmd struct {
poolCmd
RankList ui.RankSetFlag `long:"ranks" required:"1" description:"Comma-separated list of ranks to add to the pool"`
Expand All @@ -616,15 +616,15 @@ func (cmd *poolExtendCmd) Execute(args []string) error {
return err
}

// PoolReintegrateCmd is the struct representing the command to Add a DAOS target.
type poolReintegrateCmd struct {
// poolReintCmd is the struct representing the command to Add a DAOS target.
type poolReintCmd struct {
poolCmd
Rank uint32 `long:"rank" required:"1" description:"Engine rank of the targets to be reintegrated"`
TargetIdx string `long:"target-idx" description:"Comma-separated list of target idx(s) to be reintegrated into the rank"`
}

// Execute is run when PoolReintegrateCmd subcommand is activated
func (cmd *poolReintegrateCmd) Execute(args []string) error {
// Execute is run when PoolReintCmd subcommand is activated
func (cmd *poolReintCmd) Execute(args []string) error {
msg := "succeeded"

var idxList []uint32
Expand All @@ -633,13 +633,13 @@ func (cmd *poolReintegrateCmd) Execute(args []string) error {
return err
}

req := &control.PoolReintegrateReq{
req := &control.PoolReintReq{
ID: cmd.PoolID().String(),
Rank: ranklist.Rank(cmd.Rank),
TargetIdx: idxList,
}

err := control.PoolReintegrate(cmd.MustLogCtx(), cmd.ctlInvoker, req)
err := control.PoolReint(cmd.MustLogCtx(), cmd.ctlInvoker, req)
if err != nil {
msg = errors.WithMessage(err, "failed").Error()
}
Expand All @@ -649,7 +649,7 @@ func (cmd *poolReintegrateCmd) Execute(args []string) error {
return err
}

// PoolQueryCmd is the struct representing the command to query a DAOS pool.
// poolQueryCmd is the struct representing the command to query a DAOS pool.
type poolQueryCmd struct {
poolCmd
ShowEnabledRanks bool `short:"e" long:"show-enabled" description:"Show engine unique identifiers (ranks) which are enabled"`
Expand Down Expand Up @@ -694,7 +694,7 @@ func (cmd *poolQueryCmd) Execute(args []string) error {
return nil
}

// PoolQueryTargetsCmd is the struct representing the command to query a DAOS pool engine's targets
// poolQueryTargetsCmd is the struct representing the command to query a DAOS pool engine's targets
type poolQueryTargetsCmd struct {
poolCmd

Expand Down Expand Up @@ -752,7 +752,7 @@ func (cmd *poolQueryTargetsCmd) Execute(args []string) error {
return nil
}

// PoolUpgradeCmd is the struct representing the command to update a DAOS pool.
// poolUpgradeCmd is the struct representing the command to update a DAOS pool.
type poolUpgradeCmd struct {
poolCmd
}
Expand All @@ -772,7 +772,7 @@ func (cmd *poolUpgradeCmd) Execute(args []string) error {
return nil
}

// PoolSetPropCmd represents the command to set a property on a pool.
// poolSetPropCmd represents the command to set a property on a pool.
type poolSetPropCmd struct {
poolCmd

Expand Down Expand Up @@ -816,7 +816,7 @@ func (cmd *poolSetPropCmd) Execute(_ []string) error {
return nil
}

// PoolGetPropCmd represents the command to set a property on a pool.
// poolGetPropCmd represents the command to set a property on a pool.
type poolGetPropCmd struct {
poolCmd
Args struct {
Expand Down Expand Up @@ -847,7 +847,7 @@ func (cmd *poolGetPropCmd) Execute(_ []string) error {
return nil
}

// PoolGetACLCmd represents the command to fetch an Access Control List of a
// poolGetACLCmd represents the command to fetch an Access Control List of a
// DAOS pool.
type poolGetACLCmd struct {
poolCmd
Expand Down Expand Up @@ -911,7 +911,7 @@ func (cmd *poolGetACLCmd) writeACLToFile(acl string) error {
return nil
}

// PoolOverwriteACLCmd represents the command to overwrite the Access Control
// poolOverwriteACLCmd represents the command to overwrite the Access Control
// List of a DAOS pool.
type poolOverwriteACLCmd struct {
poolCmd
Expand Down Expand Up @@ -946,7 +946,7 @@ func (cmd *poolOverwriteACLCmd) Execute(args []string) error {
return nil
}

// PoolUpdateACLCmd represents the command to update the Access Control List of
// poolUpdateACLCmd represents the command to update the Access Control List of
// a DAOS pool.
type poolUpdateACLCmd struct {
poolCmd
Expand Down Expand Up @@ -994,7 +994,7 @@ func (cmd *poolUpdateACLCmd) Execute(args []string) error {
return nil
}

// PoolDeleteACLCmd represents the command to delete an entry from the Access
// poolDeleteACLCmd represents the command to delete an entry from the Access
// Control List of a DAOS pool.
type poolDeleteACLCmd struct {
poolCmd
Expand Down
6 changes: 3 additions & 3 deletions src/control/cmd/dmg/pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,7 @@ func TestPoolCommands(t *testing.T) {
"Reintegrate a target with single target idx",
"pool reintegrate 031bcaf8-f0f5-42ef-b3c5-ee048676dceb --rank 0 --target-idx 1",
strings.Join([]string{
printRequest(t, &control.PoolReintegrateReq{
printRequest(t, &control.PoolReintReq{
ID: "031bcaf8-f0f5-42ef-b3c5-ee048676dceb",
Rank: 0,
TargetIdx: []uint32{1},
Expand All @@ -730,7 +730,7 @@ func TestPoolCommands(t *testing.T) {
"Reintegrate a target with multiple idx",
"pool reintegrate 031bcaf8-f0f5-42ef-b3c5-ee048676dceb --rank 0 --target-idx 1,2,3",
strings.Join([]string{
printRequest(t, &control.PoolReintegrateReq{
printRequest(t, &control.PoolReintReq{
ID: "031bcaf8-f0f5-42ef-b3c5-ee048676dceb",
Rank: 0,
TargetIdx: []uint32{1, 2, 3},
Expand All @@ -742,7 +742,7 @@ func TestPoolCommands(t *testing.T) {
"Reintegrate a target with no idx given",
"pool reintegrate 031bcaf8-f0f5-42ef-b3c5-ee048676dceb --rank 0",
strings.Join([]string{
printRequest(t, &control.PoolReintegrateReq{
printRequest(t, &control.PoolReintReq{
ID: "031bcaf8-f0f5-42ef-b3c5-ee048676dceb",
Rank: 0,
TargetIdx: []uint32{},
Expand Down
17 changes: 8 additions & 9 deletions src/control/cmd/dmg/pretty/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,24 +222,23 @@ func PrintSystemCleanupResponse(out io.Writer, resp *control.SystemCleanupResp,
fmt.Fprintln(out, "System Cleanup Success")
}

// PrintSystemDrainResponse generates a human-readable representation of the supplied
// SystemDrainResp struct and writes it to the supplied io.Writer. Result related errors written to
// error io.Writer.
func PrintSystemDrainResponse(out io.Writer, resp *control.SystemDrainResp) {
if len(resp.Results) == 0 {
fmt.Fprintln(out, "No pool ranks drained")
// PrintPoolRankResults generates a table showing results of operations on pool ranks. Each row will
// indicate a result for a group of ranks on a pool.
func PrintPoolRankResults(out io.Writer, results []*control.PoolRankResult) {
if len(results) == 0 {
fmt.Fprintln(out, "No pool ranks processed")
return
}

titles := []string{"Pool", "Ranks", "Result", "Reason"}
formatter := txtfmt.NewTableFormatter(titles...)

var table []txtfmt.TableRow
for _, r := range resp.Results {
for _, r := range results {
result := "OK"
reason := "N/A"
reason := "-"
if r.Status != 0 {
result = "Failed"
result = "FAIL"
reason = r.Msg
}
row := txtfmt.TableRow{
Expand Down
58 changes: 23 additions & 35 deletions src/control/cmd/dmg/pretty/system_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -612,71 +612,59 @@ Unknown 3 hosts: foo[7-9]
}
}

func TestPretty_PrintSystemDrainResp(t *testing.T) {
func TestPretty_printSysOsaResp(t *testing.T) {
for name, tc := range map[string]struct {
resp *control.SystemDrainResp
expOut string
results []*control.PoolRankResult
expOut string
}{
"empty response": {
resp: &control.SystemDrainResp{},
expOut: `
No pool ranks drained
`,
},
"normal response": {
resp: &control.SystemDrainResp{
Results: []*control.DrainResult{
{PoolID: test.MockUUID(1), Ranks: "0-3"},
{PoolID: test.MockUUID(2), Ranks: "1-4"},
},
results: []*control.PoolRankResult{
{PoolID: test.MockUUID(1), Ranks: "0-3"},
{PoolID: test.MockUUID(2), Ranks: "1-4"},
},
expOut: `
Pool Ranks Result Reason
---- ----- ------ ------
00000001-0001-0001-0001-000000000001 0-3 OK N/A
00000002-0002-0002-0002-000000000002 1-4 OK N/A
00000001-0001-0001-0001-000000000001 0-3 OK -
00000002-0002-0002-0002-000000000002 1-4 OK -

`,
},
"normal response; use labels": {
resp: &control.SystemDrainResp{
Results: []*control.DrainResult{
{PoolID: "label1", Ranks: "0-3"},
{PoolID: "label2", Ranks: "1-4"},
},
results: []*control.PoolRankResult{
{PoolID: "label1", Ranks: "0-3"},
{PoolID: "label2", Ranks: "1-4"},
},
expOut: `
Pool Ranks Result Reason
---- ----- ------ ------
label1 0-3 OK N/A
label2 1-4 OK N/A
label1 0-3 OK -
label2 1-4 OK -

`,
},
"response with failures": {
resp: &control.SystemDrainResp{
Results: []*control.DrainResult{
{PoolID: test.MockUUID(1), Ranks: "1-2"},
{PoolID: test.MockUUID(2), Ranks: "0"},
{
PoolID: test.MockUUID(2), Ranks: "1-2",
Status: -1, Msg: "fail1",
},
results: []*control.PoolRankResult{
{PoolID: test.MockUUID(1), Ranks: "1-2"},
{PoolID: test.MockUUID(2), Ranks: "0"},
{
PoolID: test.MockUUID(2), Ranks: "1-2",
Status: -1, Msg: "fail1",
},
},
expOut: `
Pool Ranks Result Reason
---- ----- ------ ------
00000001-0001-0001-0001-000000000001 1-2 OK N/A
00000002-0002-0002-0002-000000000002 0 OK N/A
00000002-0002-0002-0002-000000000002 1-2 Failed fail1
00000001-0001-0001-0001-000000000001 1-2 OK -
00000002-0002-0002-0002-000000000002 0 OK -
00000002-0002-0002-0002-000000000002 1-2 FAIL fail1

`,
},
} {
t.Run(name, func(t *testing.T) {
var out strings.Builder
PrintSystemDrainResponse(&out, tc.resp)
PrintPoolRankResults(&out, tc.results)

if diff := cmp.Diff(strings.TrimLeft(tc.expOut, "\n"), out.String()); diff != "" {
t.Fatalf("unexpected stdout (-want, +got):\n%s\n", diff)
Expand Down
Loading
Loading