Skip to content

Commit

Permalink
DAOS-14422 control: Update pool query UX for MD-on-SSD phase2
Browse files Browse the repository at this point in the history
Features: control
Allow-unstable-test: true
Required-githooks: true

Signed-off-by: Tom Nabarro <[email protected]>
  • Loading branch information
tanabarr committed Aug 8, 2024
1 parent cb11ae8 commit 02681f6
Show file tree
Hide file tree
Showing 12 changed files with 217 additions and 156 deletions.
39 changes: 18 additions & 21 deletions src/control/cmd/daos/pretty/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,24 @@ import (

const msgNoPools = "No pools in system"

func printPoolTiers(suss []*daos.StorageUsageStats, w *txtfmt.ErrWriter, fullStats bool) {
mdOnSSD := false
func printPoolTiers(memFileBytes uint64, suss []*daos.StorageUsageStats, w *txtfmt.ErrWriter, fullStats bool) {
mdOnSSD := memFileBytes != 0
for tierIdx, tierStats := range suss {
if tierIdx >= int(daos.StorageMediaTypeMax) {
tierStats.MediaType = daos.StorageMediaTypeMax // Print unknown type tier.
}

switch {
case tierIdx == 0 && tierStats.MediaType == daos.StorageMediaTypeNvme:
// MD-on-SSD mode.
// TODO: Print VOS index aggregate file size across pool as distinct from
// Meta-blob aggregate size.
if fullStats {
fmt.Fprintf(w, "- Total memory-file size: %s\n",
humanize.Bytes(tierStats.Total))
if mdOnSSD {
if tierIdx == 0 {
if fullStats {
fmt.Fprintf(w, "- Total memory-file size: %s\n",
humanize.Bytes(memFileBytes))
}
fmt.Fprintf(w, "- Metadata storage:\n")
} else {
fmt.Fprintf(w, "- Data storage:\n")
}
} else {
if tierIdx >= int(daos.StorageMediaTypeMax) {
// Print unknown type tiers.
tierStats.MediaType = daos.StorageMediaTypeMax
}
fmt.Fprintf(w, "- Metadata storage:\n")
mdOnSSD = true
case mdOnSSD:
fmt.Fprintf(w, "- Data storage:\n")
default:
fmt.Fprintf(w, "- Storage tier %d (%s):\n", tierIdx,
strings.ToUpper(tierStats.MediaType.String()))
}
Expand Down Expand Up @@ -93,7 +90,7 @@ func PrintPoolInfo(pi *daos.PoolInfo, out io.Writer) error {
if pi.QueryMask.HasOption(daos.PoolQueryOptionSpace) && pi.TierStats != nil {
fmt.Fprintln(w, "Pool space info:")
fmt.Fprintf(w, "- Target count:%d\n", pi.ActiveTargets)
printPoolTiers(pi.TierStats, w, true)
printPoolTiers(pi.MemFileBytes, pi.TierStats, w, true)
}
return w.Err
}
Expand All @@ -109,7 +106,7 @@ func PrintPoolQueryTargetInfo(pqti *daos.PoolQueryTargetInfo, out io.Writer) err
// Maintain output compatibility with the `daos pool query-targets` output.
fmt.Fprintf(w, "Target: type %s, state %s\n", pqti.Type, pqti.State)
if pqti.Space != nil {
printPoolTiers(pqti.Space, w, false)
printPoolTiers(pqti.MemFileBytes, pqti.Space, w, false)
}

return w.Err
Expand Down
8 changes: 5 additions & 3 deletions src/control/cmd/daos/pretty/pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,14 +289,15 @@ Pool space info:
{
Total: 2,
Free: 1,
MediaType: daos.StorageMediaTypeNvme,
MediaType: daos.StorageMediaTypeScm,
},
{
Total: 2,
Free: 1,
MediaType: daos.StorageMediaTypeNvme,
},
},
MemFileBytes: 1,
},
expPrintStr: fmt.Sprintf(`
Pool %s, ntarget=2, disabled=1, leader=42, version=100, state=Degraded
Expand All @@ -305,7 +306,7 @@ Pool health info:
- Rebuild busy, 42 objs, 21 recs
Pool space info:
- Target count:1
- Total memory-file size: 2 B
- Total memory-file size: 1 B
- Metadata storage:
Total size: 2 B
Free: 1 B, min:0 B, max:0 B, mean:0 B
Expand Down Expand Up @@ -507,14 +508,15 @@ Target: type unknown, state drain
{
Total: 6000000000,
Free: 5000000000,
MediaType: daos.StorageMediaTypeNvme,
MediaType: daos.StorageMediaTypeScm,
},
{
Total: 100000000000,
Free: 90000000000,
MediaType: daos.StorageMediaTypeNvme,
},
},
MemFileBytes: 3000000000,
},
expPrintStr: `
Target: type unknown, state down_out
Expand Down
4 changes: 2 additions & 2 deletions src/control/cmd/dmg/pretty/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func printTierBytesRow(fmtName string, tierBytes uint64, numRanks int) txtfmt.Ta
}
}

func getPoolRespStorageRows(mdOnSSD bool, tierBytes []uint64, tierRatios []float64, numRanks int) (title string, rows []txtfmt.TableRow) {
func getPoolCreateRespRows(mdOnSSD bool, tierBytes []uint64, tierRatios []float64, numRanks int) (title string, rows []txtfmt.TableRow) {
title = "Pool created with "
tierName := "SCM"
if mdOnSSD {
Expand Down Expand Up @@ -124,7 +124,7 @@ func PrintPoolCreateResponse(pcr *control.PoolCreateResp, out io.Writer, opts ..

mdOnSsdEnabled := pcr.MemFileBytes > 0

title, tierRows := getPoolRespStorageRows(mdOnSsdEnabled, pcr.TierBytes, tierRatios,
title, tierRows := getPoolCreateRespRows(mdOnSsdEnabled, pcr.TierBytes, tierRatios,
numRanks)

// Print memory-file to meta-blob ratio for MD-on-SSD.
Expand Down
216 changes: 118 additions & 98 deletions src/control/common/proto/mgmt/pool.pb.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/control/lib/control/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ type (
SvcReps []uint32 `json:"svc_reps"`
TgtRanks []uint32 `json:"tgt_ranks"`
TierBytes []uint64 `json:"tier_bytes"` // Per-rank storage tier sizes.
MemFileBytes uint64 `json:"mem_file_bytes"` // MD-on-SSD mode only.
MemFileBytes uint64 `json:"mem_file_bytes"` // Per-rank. MD-on-SSD mode only.
}
)

Expand Down
8 changes: 5 additions & 3 deletions src/control/lib/control/pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -807,7 +807,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":"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,"mem_file_bytes":0,"status":42}`,
},
"valid rankset": {
pqr: &PoolQueryResp{
Expand All @@ -827,9 +827,10 @@ func TestControl_PoolQueryResp_MarshalJSON(t *testing.T) {
DisabledRanks: &ranklist.RankSet{},
PoolLayoutVer: 7,
UpgradeLayoutVer: 8,
MemFileBytes: 1000,
},
},
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":"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,"mem_file_bytes":1000,"status":42}`,
},
} {
t.Run(name, func(t *testing.T) {
Expand Down Expand Up @@ -871,7 +872,7 @@ func TestControl_PoolQueryResp_UnmarshalJSON(t *testing.T) {
},
},
"valid rankset": {
data: `{"enabled_ranks":"[0,1-3,5]","disabled_ranks":"[]","status":0,"uuid":"` + poolUUID.String() + `","total_targets":1,"active_targets":2,"total_engines":3,"disabled_targets":4,"version":5,"svc_ldr":6,"svc_reps":null,"rebuild":null,"tier_stats":null,"pool_layout_ver":7,"upgrade_layout_ver":8}`,
data: `{"enabled_ranks":"[0,1-3,5]","disabled_ranks":"[]","status":0,"uuid":"` + poolUUID.String() + `","total_targets":1,"active_targets":2,"total_engines":3,"disabled_targets":4,"version":5,"svc_ldr":6,"svc_reps":null,"rebuild":null,"tier_stats":null,"pool_layout_ver":7,"upgrade_layout_ver":8,"mem_file_bytes":1000}`,
expResp: PoolQueryResp{
Status: 0,
PoolInfo: daos.PoolInfo{
Expand All @@ -886,6 +887,7 @@ func TestControl_PoolQueryResp_UnmarshalJSON(t *testing.T) {
DisabledRanks: &ranklist.RankSet{},
PoolLayoutVer: 7,
UpgradeLayoutVer: 8,
MemFileBytes: 1000,
},
},
},
Expand Down
8 changes: 5 additions & 3 deletions src/control/lib/daos/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,18 @@ type (
DisabledRanks *ranklist.RankSet `json:"disabled_ranks,omitempty"`
PoolLayoutVer uint32 `json:"pool_layout_ver"`
UpgradeLayoutVer uint32 `json:"upgrade_layout_ver"`
MemFileBytes uint64 `json:"mem_file_bytes"`
}

PoolQueryTargetType int32
PoolQueryTargetState int32

// PoolQueryTargetInfo contains information about a single target
PoolQueryTargetInfo struct {
Type PoolQueryTargetType `json:"target_type"`
State PoolQueryTargetState `json:"target_state"`
Space []*StorageUsageStats `json:"space"`
Type PoolQueryTargetType `json:"target_type"`
State PoolQueryTargetState `json:"target_state"`
Space []*StorageUsageStats `json:"space"`
MemFileBytes uint64 `json:"mem_file_bytes"`
}

// StorageTargetUsage represents DAOS target storage usage
Expand Down
21 changes: 8 additions & 13 deletions src/control/server/mgmt_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -957,14 +957,11 @@ func (svc *mgmtSvc) PoolQuery(ctx context.Context, req *mgmtpb.PoolQueryReq) (*m
// Preserve compatibility with pre-2.6 callers.
resp.Leader = resp.SvcLdr

// Update media type of storage tier #0 if MD-on-SSD is enabled.
// TODO DAOS-14223: Do we need this if we are returning memory_file_bytes?
// TODO DAOS-16209: After VOS query API is updated, zero-value mem_file_bytes will be
// returned in non-MD-on-SSD mode and this hack can be removed.
storage := svc.harness.Instances()[0].GetStorage()
if storage.ControlMetadataPathConfigured() {
if len(resp.TierStats) > 0 {
svc.log.Debugf("md-on-ssd pool query, set tier-0 to NVMe")
resp.TierStats[0].MediaType = mgmtpb.StorageMediaType_NVME
}
if !storage.ControlMetadataPathConfigured() {
resp.MemFileBytes = 0
}

return resp, nil
Expand All @@ -986,14 +983,12 @@ func (svc *mgmtSvc) PoolQueryTarget(ctx context.Context, req *mgmtpb.PoolQueryTa
return nil, errors.Wrap(err, "unmarshal PoolQueryTarget response")
}

// Update media type of storage tier #0 if MD-on-SSD is enabled.
// TODO DAOS-16209: After VOS query API is updated, zero-value mem_file_bytes will be
// returned in non-MD-on-SSD mode and this hack can be removed.
storage := svc.harness.Instances()[0].GetStorage()
if storage.ControlMetadataPathConfigured() {
svc.log.Debugf("md-on-ssd pool query-target, set tier-0 to NVMe")
if !storage.ControlMetadataPathConfigured() {
for _, tgtInfo := range resp.Infos {
if len(tgtInfo.Space) > 0 {
tgtInfo.Space[0].MediaType = mgmtpb.StorageMediaType_NVME
}
tgtInfo.MemFileBytes = 0
}
}

Expand Down
38 changes: 32 additions & 6 deletions src/mgmt/pool.pb-c.c
Original file line number Diff line number Diff line change
Expand Up @@ -3305,7 +3305,7 @@ const ProtobufCMessageDescriptor mgmt__pool_rebuild_status__descriptor =
(ProtobufCMessageInit) mgmt__pool_rebuild_status__init,
NULL,NULL,NULL /* reserved[123] */
};
static const ProtobufCFieldDescriptor mgmt__pool_query_resp__field_descriptors[19] =
static const ProtobufCFieldDescriptor mgmt__pool_query_resp__field_descriptors[20] =
{
{
"status",
Expand Down Expand Up @@ -3535,6 +3535,18 @@ static const ProtobufCFieldDescriptor mgmt__pool_query_resp__field_descriptors[1
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
},
{
"mem_file_bytes",
21,
PROTOBUF_C_LABEL_NONE,
PROTOBUF_C_TYPE_UINT64,
0, /* quantifier_offset */
offsetof(Mgmt__PoolQueryResp, mem_file_bytes),
NULL,
NULL,
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
},
};
static const unsigned mgmt__pool_query_resp__field_indices_by_name[] = {
4, /* field[4] = active_targets */
Expand All @@ -3543,6 +3555,7 @@ static const unsigned mgmt__pool_query_resp__field_indices_by_name[] = {
10, /* field[10] = enabled_ranks */
2, /* field[2] = label */
9, /* field[9] = leader */
19, /* field[19] = mem_file_bytes */
13, /* field[13] = pool_layout_ver */
18, /* field[18] = query_mask */
6, /* field[6] = rebuild */
Expand All @@ -3561,7 +3574,7 @@ static const ProtobufCIntRange mgmt__pool_query_resp__number_ranges[2 + 1] =
{
{ 1, 0 },
{ 10, 8 },
{ 0, 19 }
{ 0, 20 }
};
const ProtobufCMessageDescriptor mgmt__pool_query_resp__descriptor =
{
Expand All @@ -3571,7 +3584,7 @@ const ProtobufCMessageDescriptor mgmt__pool_query_resp__descriptor =
"Mgmt__PoolQueryResp",
"mgmt",
sizeof(Mgmt__PoolQueryResp),
19,
20,
mgmt__pool_query_resp__field_descriptors,
mgmt__pool_query_resp__field_indices_by_name,
2, mgmt__pool_query_resp__number_ranges,
Expand Down Expand Up @@ -4213,7 +4226,7 @@ const ProtobufCEnumDescriptor mgmt__pool_query_target_info__target_state__descri
mgmt__pool_query_target_info__target_state__value_ranges,
NULL,NULL,NULL,NULL /* reserved[1234] */
};
static const ProtobufCFieldDescriptor mgmt__pool_query_target_info__field_descriptors[3] =
static const ProtobufCFieldDescriptor mgmt__pool_query_target_info__field_descriptors[4] =
{
{
"type",
Expand Down Expand Up @@ -4251,16 +4264,29 @@ static const ProtobufCFieldDescriptor mgmt__pool_query_target_info__field_descri
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
},
{
"mem_file_bytes",
4,
PROTOBUF_C_LABEL_NONE,
PROTOBUF_C_TYPE_UINT64,
0, /* quantifier_offset */
offsetof(Mgmt__PoolQueryTargetInfo, mem_file_bytes),
NULL,
NULL,
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
},
};
static const unsigned mgmt__pool_query_target_info__field_indices_by_name[] = {
3, /* field[3] = mem_file_bytes */
2, /* field[2] = space */
1, /* field[1] = state */
0, /* field[0] = type */
};
static const ProtobufCIntRange mgmt__pool_query_target_info__number_ranges[1 + 1] =
{
{ 1, 0 },
{ 0, 3 }
{ 0, 4 }
};
const ProtobufCMessageDescriptor mgmt__pool_query_target_info__descriptor =
{
Expand All @@ -4270,7 +4296,7 @@ const ProtobufCMessageDescriptor mgmt__pool_query_target_info__descriptor =
"Mgmt__PoolQueryTargetInfo",
"mgmt",
sizeof(Mgmt__PoolQueryTargetInfo),
3,
4,
mgmt__pool_query_target_info__field_descriptors,
mgmt__pool_query_target_info__field_indices_by_name,
1, mgmt__pool_query_target_info__number_ranges,
Expand Down
12 changes: 10 additions & 2 deletions src/mgmt/pool.pb-c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 11 additions & 3 deletions src/mgmt/srv_drpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -517,9 +517,10 @@ ds_mgmt_drpc_pool_create(Drpc__Call *drpc_req, Drpc__Response *drpc_resp)
d_rank_list_free(svc);

/**
* FIXME DAOS-16209: Populate per-rank VOS-file sizes. For now just calculate here based on
* the supplied input values but really should be returned from ds_mgmt_pool_query() through
* the VOS query API and set in pool_create_fill_resp(). Return zero for non-MD-on-SSD mode.
* TODO DAOS-16209: Populate per-rank VOS-file sizes. For now just calculate here based on
* the supplied input values but really should be returned from
* ds_mgmt_pool_query() through the VOS query API and set in
* pool_create_fill_resp(). Return zero for non-MD-on-SSD mode.
*/
resp.mem_file_bytes = req->tier_bytes[DAOS_MEDIA_SCM] * req->mem_ratio;

Expand Down Expand Up @@ -1845,6 +1846,13 @@ ds_mgmt_drpc_pool_query(Drpc__Call *drpc_req, Drpc__Response *drpc_resp)
pool_rebuild_status_from_info(&rebuild, &pool_info.pi_rebuild_st);
resp.rebuild = &rebuild;

/**
* TODO DAOS-16209: Populate VOS-file sizes in response. For now just return the meta-blob
* size until VOS query API is updated. When updated, zero-value should
* be returned in non-MD-on-SSD mode.
*/
resp.mem_file_bytes = scm.Total;

error:
resp.status = rc;

Expand Down
Loading

0 comments on commit 02681f6

Please sign in to comment.