Skip to content
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
16 changes: 11 additions & 5 deletions src/control/cmd/dmg/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,11 @@ type storageFormatCmd struct {
ctlInvokerCmd
hostListCmd
cmdutil.JSONOutputCmd
Verbose bool `short:"v" long:"verbose" description:"Show results of each SCM & NVMe device format operation"`
Force bool `long:"force" description:"Force storage format on a host, stopping any running engines (CAUTION: destructive operation)"`
Replace bool `long:"replace" description:"Replace an excluded rank. Allows a DAOS engine instance to reclaim its old rank number after metadata is lost due to PMem or other storage media failure"`
Rank *uint32 `long:"rank" description:"Specific rank to replace (only valid with --replace)"`
Verbose bool `short:"v" long:"verbose" description:"Show results of each SCM & NVMe device format operation"`
Force bool `long:"force" description:"Force storage format on a host, stopping any running engines (CAUTION: destructive operation)"`
Replace bool `long:"replace" description:"Replace an excluded rank. Allows a DAOS engine instance to reclaim its old rank number after metadata is lost due to PMem or other storage media failure"`
Rank *uint32 `long:"rank" description:"Specific rank to replace (only valid with --replace)"`
EngineIdx *uint32 `long:"engine-idx" description:"Specific engine instance index to format (optional, by default all engines are formatted)"`
}

// Execute is run when storageFormatCmd activates.
Expand All @@ -127,7 +128,12 @@ func (cmd *storageFormatCmd) Execute(args []string) (err error) {
rank = *cmd.Rank
}

req := &control.StorageFormatReq{Reformat: cmd.Force, Replace: cmd.Replace, Rank: rank}
req := &control.StorageFormatReq{
Reformat: cmd.Force,
Replace: cmd.Replace,
Rank: rank,
EngineIdx: cmd.EngineIdx,
}
Comment on lines +131 to +136

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

From my understanding, using cmd.EngineIdx without cmd.Rank defined and cmd.Replace true makes no sense and can even lead to some unexpected behaviour. If I am correct, the same kind of consistency checking done for cmd.Rank should be done for cmd.EngineIdx:

if cmd.EngineIdx != nil && cmd.Rank == nil {
    return errors.New("--engine-idx option is only valid when used with --rank")
}

req.SetHostList(cmd.getHostList())

resp, err := control.StorageFormat(ctx, cmd.ctlInvoker, req)
Expand Down
Loading
Loading