Skip to content

Commit

Permalink
DAOS-14419 control: Display disabled ranks by default
Browse files Browse the repository at this point in the history
Always display the disabled targets and remove the old associated options.

Features: control
Allow-unstable-test: true
Required-githooks: true
Signed-off-by: Cedric Koch-Hofer <cedric.koch-hofer@intel.com>
  • Loading branch information
kanard38 authored and knard-intel committed Sep 24, 2024
1 parent 226e283 commit 21a246f
Show file tree
Hide file tree
Showing 11 changed files with 20 additions and 100 deletions.
12 changes: 3 additions & 9 deletions src/control/cmd/daos/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,8 @@ type poolCmd struct {

type poolQueryCmd struct {
poolBaseCmd
ShowEnabledRanks bool `short:"e" long:"show-enabled" description:"Show engine unique identifiers (ranks) which are enabled"`
ShowDisabledRanks bool `short:"b" long:"show-disabled" description:"Show engine unique identifiers (ranks) which are disabled"`
HealthOnly bool `short:"t" long:"health-only" description:"Only perform pool health related queries"`
ShowEnabledRanks bool `short:"e" long:"show-enabled" description:"Show engine unique identifiers (ranks) which are enabled"`
HealthOnly bool `short:"t" long:"health-only" description:"Only perform pool health related queries"`
}

func convertPoolSpaceInfo(in *C.struct_daos_pool_space, mt C.uint) *daos.StorageUsageStats {
Expand Down Expand Up @@ -340,15 +339,10 @@ func (cmd *poolQueryCmd) Execute(_ []string) error {
if cmd.HealthOnly {
queryMask = daos.HealthOnlyPoolQueryMask
}
if cmd.ShowEnabledRanks && cmd.ShowDisabledRanks {
return errors.New("show-enabled and show-disabled can't be used at the same time.")
}
if cmd.ShowEnabledRanks {
queryMask.SetOptions(daos.PoolQueryOptionEnabledEngines)
}
if cmd.ShowDisabledRanks {
queryMask.SetOptions(daos.PoolQueryOptionDisabledEngines)
}
queryMask.SetOptions(daos.PoolQueryOptionDisabledEngines)

cleanup, err := cmd.resolveAndConnect(C.DAOS_PC_RO, nil)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion src/control/cmd/daos/pretty/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func PrintPoolInfo(pi *daos.PoolInfo, out io.Writer) error {
if pi.EnabledRanks != nil && pi.EnabledRanks.Count() > 0 {
fmt.Fprintf(w, "- Enabled ranks: %s\n", pi.EnabledRanks)
}
if pi.DisabledRanks != nil && pi.DisabledRanks.Count() > 0 {
if pi.DisabledRanks.Count() > 0 {
fmt.Fprintf(w, "- Disabled ranks: %s\n", pi.DisabledRanks)
}
if pi.Rebuild != nil {
Expand Down
9 changes: 3 additions & 6 deletions src/control/cmd/dmg/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -590,9 +590,8 @@ func (cmd *PoolReintegrateCmd) Execute(args []string) error {
// 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"`
ShowDisabledRanks bool `short:"b" long:"show-disabled" description:"Show engine unique identifiers (ranks) which are disabled"`
HealthOnly bool `short:"t" long:"health-only" description:"Only perform pool health related queries"`
ShowEnabledRanks bool `short:"e" long:"show-enabled" description:"Show engine unique identifiers (ranks) which are enabled"`
HealthOnly bool `short:"t" long:"health-only" description:"Only perform pool health related queries"`
}

// Execute is run when PoolQueryCmd subcommand is activated
Expand All @@ -608,9 +607,7 @@ func (cmd *PoolQueryCmd) Execute(args []string) error {
if cmd.ShowEnabledRanks {
req.QueryMask.SetOptions(daos.PoolQueryOptionEnabledEngines)
}
if cmd.ShowDisabledRanks {
req.QueryMask.SetOptions(daos.PoolQueryOptionDisabledEngines)
}
req.QueryMask.SetOptions(daos.PoolQueryOptionDisabledEngines)

resp, err := control.PoolQuery(cmd.MustLogCtx(), cmd.ctlInvoker, req)
if cmd.JSONOutputEnabled() {
Expand Down
48 changes: 0 additions & 48 deletions src/control/cmd/dmg/pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -994,54 +994,6 @@ func TestPoolCommands(t *testing.T) {
}, " "),
nil,
},
{
"Query pool with UUID and disabled ranks",
"pool query --show-disabled 12345678-1234-1234-1234-1234567890ab",
strings.Join([]string{
printRequest(t, &control.PoolQueryReq{
ID: "12345678-1234-1234-1234-1234567890ab",
QueryMask: setQueryMask(func(qm *daos.PoolQueryMask) { qm.SetOptions(daos.PoolQueryOptionDisabledEngines) }),
}),
}, " "),
nil,
},
{
"Query pool with UUID and disabled ranks",
"pool query -b 12345678-1234-1234-1234-1234567890ab",
strings.Join([]string{
printRequest(t, &control.PoolQueryReq{
ID: "12345678-1234-1234-1234-1234567890ab",
QueryMask: setQueryMask(func(qm *daos.PoolQueryMask) { qm.SetOptions(daos.PoolQueryOptionDisabledEngines) }),
}),
}, " "),
nil,
},
{
"Query pool with UUID, enabled ranks and disabled ranks",
"pool query --show-disabled --show-enabled 12345678-1234-1234-1234-1234567890ab",
strings.Join([]string{
printRequest(t, &control.PoolQueryReq{
ID: "12345678-1234-1234-1234-1234567890ab",
QueryMask: setQueryMask(func(qm *daos.PoolQueryMask) {
qm.SetOptions(daos.PoolQueryOptionEnabledEngines, daos.PoolQueryOptionDisabledEngines)
}),
}),
}, " "),
nil,
},
{
"Query pool with UUID, enabled ranks and disabled ranks",
"pool query -b -e 12345678-1234-1234-1234-1234567890ab",
strings.Join([]string{
printRequest(t, &control.PoolQueryReq{
ID: "12345678-1234-1234-1234-1234567890ab",
QueryMask: setQueryMask(func(qm *daos.PoolQueryMask) {
qm.SetOptions(daos.PoolQueryOptionEnabledEngines, daos.PoolQueryOptionDisabledEngines)
}),
}),
}, " "),
nil,
},
{
"Query pool for health only",
"pool query --health-only 12345678-1234-1234-1234-1234567890ab",
Expand Down
4 changes: 2 additions & 2 deletions src/control/lib/control/pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -805,7 +805,7 @@ func TestControl_PoolQueryResp_MarshalJSON(t *testing.T) {
UpgradeLayoutVer: 8,
},
},
exp: `{"query_mask":"rebuild,space","state":"Ready","uuid":"` + poolUUID.String() + `","total_targets":1,"active_targets":2,"total_engines":3,"disabled_targets":4,"version":5,"svc_ldr":6,"svc_reps":[0,1,2],"rebuild":null,"tier_stats":null,"pool_layout_ver":7,"upgrade_layout_ver":8,"status":42}`,
exp: `{"query_mask":"disabled_engines,rebuild,space","state":"Ready","uuid":"` + poolUUID.String() + `","total_targets":1,"active_targets":2,"total_engines":3,"disabled_targets":4,"version":5,"svc_ldr":6,"svc_reps":[0,1,2],"rebuild":null,"tier_stats":null,"pool_layout_ver":7,"upgrade_layout_ver":8,"status":42}`,
},
"valid rankset": {
pqr: &PoolQueryResp{
Expand All @@ -827,7 +827,7 @@ func TestControl_PoolQueryResp_MarshalJSON(t *testing.T) {
UpgradeLayoutVer: 8,
},
},
exp: `{"query_mask":"rebuild,space","state":"Ready","uuid":"` + poolUUID.String() + `","total_targets":1,"active_targets":2,"total_engines":3,"disabled_targets":4,"version":5,"svc_ldr":6,"svc_reps":[0,1,2],"rebuild":null,"tier_stats":null,"enabled_ranks":[0,1,2,3,5],"disabled_ranks":[],"pool_layout_ver":7,"upgrade_layout_ver":8,"status":42}`,
exp: `{"query_mask":"disabled_engines,rebuild,space","state":"Ready","uuid":"` + poolUUID.String() + `","total_targets":1,"active_targets":2,"total_engines":3,"disabled_targets":4,"version":5,"svc_ldr":6,"svc_reps":[0,1,2],"rebuild":null,"tier_stats":null,"enabled_ranks":[0,1,2,3,5],"disabled_ranks":[],"pool_layout_ver":7,"upgrade_layout_ver":8,"status":42}`,
},
} {
t.Run(name, func(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion src/control/lib/daos/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ type (

const (
// DefaultPoolQueryMask defines the default pool query mask.
DefaultPoolQueryMask = PoolQueryMask(^uint64(0) &^ (C.DPI_ENGINES_ENABLED | C.DPI_ENGINES_DISABLED))
DefaultPoolQueryMask = PoolQueryMask(^uint64(0) &^ C.DPI_ENGINES_ENABLED)
// HealthOnlyPoolQueryMask defines the mask for health-only queries.
HealthOnlyPoolQueryMask = PoolQueryMask(^uint64(0) &^ (C.DPI_ENGINES_ENABLED | C.DPI_SPACE))

Expand Down
2 changes: 1 addition & 1 deletion src/control/lib/daos/pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ func TestDaos_PoolQueryMask(t *testing.T) {
testMask: genTestMask(func(pqm *PoolQueryMask) {
*pqm = DefaultPoolQueryMask
}),
expString: genOptsStr(PoolQueryOptionRebuild, PoolQueryOptionSpace),
expString: genOptsStr(PoolQueryOptionDisabledEngines, PoolQueryOptionRebuild, PoolQueryOptionSpace),
},
"health-only query mask": {
testMask: genTestMask(func(pqm *PoolQueryMask) {
Expand Down
31 changes: 4 additions & 27 deletions src/tests/ftest/control/dmg_pool_query_ranks.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,28 +40,6 @@ def test_pool_query_ranks_basic(self):

self.log.debug("Checking without ranks state information")
data = self.dmg.pool_query(self.pool.identifier)
self.assertIsNone(
data['response'].get('enabled_ranks'),
"Invalid enabled_ranks field: want=None, got={}".format(
data['response'].get('enabled_ranks')))
self.assertIsNone(
data['response'].get('disabled_ranks'),
"Invalid disabled_ranks field: want=None, got={}".format(
data['response'].get('disabled_ranks')))

self.log.debug("Checking enabled ranks state information")
data = self.dmg.pool_query(self.pool.identifier, show_enabled=True)
self.assertListEqual(
data['response'].get('enabled_ranks'), [0, 1, 2],
"Invalid enabled_ranks field: want=[0, 1, 2], got={}".format(
data['response'].get('enabled_ranks')))
self.assertIsNone(
data['response'].get('disabled_ranks'),
"Invalid disabled_ranks field: want=None, got={}".format(
data['response'].get('disabled_ranks')))

self.log.debug("Checking disabled ranks state information")
data = self.dmg.pool_query(self.pool.identifier, show_disabled=True)
self.assertIsNone(
data['response'].get('enabled_ranks'),
"Invalid enabled_ranks field: want=None, got={}".format(
Expand All @@ -71,8 +49,8 @@ def test_pool_query_ranks_basic(self):
"Invalid disabled_ranks field: want=[], got={}".format(
data['response'].get('disabled_ranks')))

self.log.debug("Checking enabled and disabled ranks state information")
data = self.dmg.pool_query(self.pool.identifier, show_enabled=True, show_disabled=True)
self.log.debug("Checking enabled ranks state information")
data = self.dmg.pool_query(self.pool.identifier, show_enabled=True)
self.assertListEqual(
data['response'].get('enabled_ranks'), [0, 1, 2],
"Invalid enabled_ranks field: want=[0, 1, 2], got={}".format(
Expand Down Expand Up @@ -110,8 +88,7 @@ def test_pool_query_ranks_mgmt(self):
disabled_ranks = sorted(disabled_ranks + [rank])

self.log.debug("Checking enabled ranks state information")
data = self.dmg.pool_query(
self.pool.identifier, show_enabled=True, show_disabled=True)
data = self.dmg.pool_query(self.pool.identifier, show_enabled=True)
self.assertListEqual(
data['response'].get('enabled_ranks'), enabled_ranks,
"Invalid enabled_ranks field: want={}, got={}".format(
Expand Down Expand Up @@ -145,7 +122,7 @@ def test_pool_query_ranks_mgmt(self):
disabled_ranks.remove(rank)

self.log.debug("Checking enabled ranks state information")
data = self.dmg.pool_query(self.pool.identifier, show_enabled=True, show_disabled=True)
data = self.dmg.pool_query(self.pool.identifier, show_enabled=True)
self.assertListEqual(
data['response'].get('enabled_ranks'), enabled_ranks,
"Invalid enabled_ranks field: want={}, got={}".format(
Expand Down
1 change: 1 addition & 0 deletions src/tests/ftest/control/dmg_pool_query_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ def test_pool_query_basic(self):
"uuid": self.pool.uuid.lower(),
"total_targets": self.params.get("total_targets", path="/run/exp_vals/*"),
"active_targets": self.params.get("active_targets", path="/run/exp_vals/*"),
"disabled_ranks": self.params.get("disabled_ranks", path="/run/exp_vals/*"),
"total_engines": self.params.get("total_engines", path="/run/exp_vals/*"),
"disabled_targets": self.params.get("disabled_targets", path="/run/exp_vals/*"),
"version": self.params.get("version", path="/run/exp_vals/*"),
Expand Down
3 changes: 2 additions & 1 deletion src/tests/ftest/control/dmg_pool_query_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,13 @@ exp_vals:
pool_state: "Ready"
total_targets: 4
active_targets: 4
disabled_ranks: []
total_engines: 1
disabled_targets: 0
version: 1
leader: 0
replicas: [0]
query_mask: "rebuild,space"
query_mask: "disabled_engines,rebuild,space"
scm:
total: 16000008192
nvme:
Expand Down
6 changes: 2 additions & 4 deletions src/tests/ftest/util/dmg_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -623,13 +623,12 @@ def pool_create(self, scm_size, uid=None, gid=None, nvme_size=None,

return data

def pool_query(self, pool, show_enabled=False, show_disabled=False):
def pool_query(self, pool, show_enabled=False):
"""Query a pool with the dmg command.
Args:
pool (str): Pool UUID or label to query.
show_enabled (bool, optional): Display enabled ranks.
show_disabled (bool, optional): Display disabled ranks.
Raises:
CommandFailure: if the dmg pool query command fails.
Expand Down Expand Up @@ -675,8 +674,7 @@ def pool_query(self, pool, show_enabled=False, show_disabled=False):
# "error": null,
# "status": 0
# }
return self._get_json_result(("pool", "query"), pool=pool,
show_enabled=show_enabled, show_disabled=show_disabled)
return self._get_json_result(("pool", "query"), pool=pool, show_enabled=show_enabled)

def pool_query_targets(self, pool, rank=None, target_idx=None):
"""Call dmg pool query-targets.
Expand Down

0 comments on commit 21a246f

Please sign in to comment.