Skip to content

Commit

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

Signed-off-by: Cedric Koch-Hofer <[email protected]>
  • Loading branch information
knard-intel authored Oct 3, 2024
1 parent a60906f commit 54c969f
Show file tree
Hide file tree
Showing 15 changed files with 26 additions and 109 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 @@ -840,7 +840,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 @@ -862,7 +862,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 @@ -27,12 +27,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
2 changes: 1 addition & 1 deletion src/tests/ftest/deployment/network_failure.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ def verify_network_failure(self, ior_namespace, container_namespace):

# 6. Call dmg pool query -b to find the disabled ranks.
self.log_step("Find the disabled ranks.")
output = dmg_cmd.pool_query(pool=self.pool.identifier, show_disabled=True)
output = dmg_cmd.pool_query(pool=self.pool.identifier)
disabled_ranks = output["response"].get("disabled_ranks")
self.log.info("Disabled ranks = %s", disabled_ranks)

Expand Down
2 changes: 1 addition & 1 deletion src/tests/ftest/deployment/server_rank_failure.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ def verify_rank_failure(self, ior_namespace):
errors.append("Server rank {} state isn't joined!".format(member["rank"]))

# 9. Call dmg pool query -b to find the disabled ranks.
output = self.get_dmg_command().pool_query(pool=self.pool.identifier, show_disabled=True)
output = self.get_dmg_command().pool_query(pool=self.pool.identifier)
disabled_ranks = output["response"].get("disabled_ranks")
self.log.info("Disabled ranks = %s", disabled_ranks)

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 @@ -625,13 +625,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 @@ -677,8 +676,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
1 change: 0 additions & 1 deletion src/tests/ftest/util/dmg_utils_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,6 @@ def __init__(self):
super().__init__("/run/dmg/pool/query/*", "query")
self.pool = BasicParameter(None, position=1)
self.show_enabled = FormattedParameter("--show-enabled", False)
self.show_disabled = FormattedParameter("--show-disabled", False)

class QueryTargetsSubCommand(CommandWithParameters):
"""Defines an object for the dmg pool query-targets command."""
Expand Down
10 changes: 4 additions & 6 deletions src/tests/ftest/util/test_utils_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -700,12 +700,11 @@ def overwrite_acl(self):
self.log.error("self.acl_file isn't defined!")

@fail_on(CommandFailure)
def query(self, show_enabled=False, show_disabled=False):
def query(self, show_enabled=False):
"""Execute dmg pool query.
Args:
show_enabled (bool, optional): Display enabled ranks.
show_disabled (bool, optional): Display disabled ranks.
Returns:
dict: the dmg json command output converted to a python dictionary
Expand All @@ -720,7 +719,7 @@ def query(self, show_enabled=False, show_disabled=False):

while True:
try:
return self.dmg.pool_query(self.identifier, show_enabled, show_disabled)
return self.dmg.pool_query(self.identifier, show_enabled)

except CommandFailure as error:
if end_time is None:
Expand Down Expand Up @@ -1119,19 +1118,18 @@ def pool_percentage_used(self):
}
return pool_percent

def set_query_data(self, show_enabled=False, show_disabled=False):
def set_query_data(self, show_enabled=False):
"""Execute dmg pool query and store the results.
Args:
show_enabled (bool, optional): Display enabled ranks.
show_disabled (bool, optional): Display disabled ranks.
Raises:
TestFail: if the dmg pool query command failed
"""
self.query_data = {}
self.query_data = self.query(show_enabled, show_disabled)
self.query_data = self.query(show_enabled)

def _get_query_data_keys(self, *keys, refresh=False):
"""Get the pool version from the dmg pool query output.
Expand Down

0 comments on commit 54c969f

Please sign in to comment.