Skip to content

Commit

Permalink
Converge on svc_ldr for JSON field name
Browse files Browse the repository at this point in the history
Some responses used "leader", and others used "svc_ldr".
As we already have a "svc_reps" precedent, and much of
the code was expecting "svc_ldr" from the old control.Pool
type, just use that.

Features: pool
Required-githooks: true
Change-Id: Iee8bda89de8be47a0c4884014de352340e5a032f
Signed-off-by: Michael MacDonald <[email protected]>
  • Loading branch information
mjmac committed Apr 18, 2024
1 parent 44e9b9c commit 8ef0b8d
Show file tree
Hide file tree
Showing 16 changed files with 1,147 additions and 1,906 deletions.
2 changes: 1 addition & 1 deletion src/control/cmd/daos/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ func convertPoolInfo(pinfo *C.daos_pool_info_t) (*daos.PoolInfo, error) {
poolInfo.DisabledTargets = uint32(pinfo.pi_ndisabled)
poolInfo.ActiveTargets = uint32(pinfo.pi_space.ps_ntargets)
poolInfo.TotalEngines = uint32(pinfo.pi_nnodes)
poolInfo.Leader = uint32(pinfo.pi_leader)
poolInfo.ServiceLeader = uint32(pinfo.pi_leader)
poolInfo.Version = uint32(pinfo.pi_map_ver)

poolInfo.TierStats = []*daos.StorageUsageStats{
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 @@ -40,7 +40,7 @@ func PrintPoolInfo(pi *daos.PoolInfo, out io.Writer) error {

// Maintain output compatibility with the `daos pool query` output.
fmt.Fprintf(w, "Pool %s, ntarget=%d, disabled=%d, leader=%d, version=%d, state=%s\n",
pi.UUID, pi.TotalTargets, pi.DisabledTargets, pi.Leader, pi.Version, pi.State)
pi.UUID, pi.TotalTargets, pi.DisabledTargets, pi.ServiceLeader, pi.Version, pi.State)

if pi.PoolLayoutVer != pi.UpgradeLayoutVer {
fmt.Fprintf(w, "Pool layout out of date (%d < %d) -- see `dmg pool upgrade` for details.\n",
Expand Down
10 changes: 5 additions & 5 deletions src/control/cmd/daos/pretty/pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Pool space info:
TotalTargets: 2,
DisabledTargets: 1,
ActiveTargets: 1,
Leader: 42,
ServiceLeader: 42,
Version: 100,
PoolLayoutVer: 1,
UpgradeLayoutVer: 2,
Expand Down Expand Up @@ -83,7 +83,7 @@ Rebuild busy, 42 objs, 21 recs
TotalTargets: 2,
DisabledTargets: 1,
ActiveTargets: 1,
Leader: 42,
ServiceLeader: 42,
Version: 100,
PoolLayoutVer: 1,
UpgradeLayoutVer: 2,
Expand Down Expand Up @@ -126,7 +126,7 @@ Rebuild busy, 42 objs, 21 recs
TotalTargets: 2,
DisabledTargets: 1,
ActiveTargets: 1,
Leader: 42,
ServiceLeader: 42,
Version: 100,
PoolLayoutVer: 1,
UpgradeLayoutVer: 2,
Expand Down Expand Up @@ -169,7 +169,7 @@ Rebuild busy, 42 objs, 21 recs
TotalTargets: 2,
DisabledTargets: 1,
ActiveTargets: 1,
Leader: 42,
ServiceLeader: 42,
Version: 100,
PoolLayoutVer: 1,
UpgradeLayoutVer: 2,
Expand Down Expand Up @@ -212,7 +212,7 @@ Rebuild unknown, 42 objs, 21 recs
TotalTargets: 2,
DisabledTargets: 1,
ActiveTargets: 1,
Leader: 42,
ServiceLeader: 42,
Version: 100,
PoolLayoutVer: 1,
UpgradeLayoutVer: 2,
Expand Down
210 changes: 110 additions & 100 deletions src/control/common/proto/mgmt/pool.pb.go

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions src/control/lib/control/pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -805,12 +805,12 @@ func TestControl_PoolQueryResp_MarshalJSON(t *testing.T) {
TotalEngines: 3,
DisabledTargets: 4,
Version: 5,
Leader: 6,
ServiceLeader: 6,
PoolLayoutVer: 7,
UpgradeLayoutVer: 8,
},
},
exp: `{"enabled_ranks":null,"disabled_ranks":null,"status":0,"state":"Ready","uuid":"` + poolUUID.String() + `","total_targets":1,"active_targets":2,"total_engines":3,"disabled_targets":4,"version":5,"leader":6,"svc_reps":null,"rebuild":null,"tier_stats":null,"pool_layout_ver":7,"upgrade_layout_ver":8}`,
exp: `{"enabled_ranks":null,"disabled_ranks":null,"status":0,"state":"Ready","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}`,
},
"valid rankset": {
pqr: &PoolQueryResp{
Expand All @@ -823,14 +823,14 @@ func TestControl_PoolQueryResp_MarshalJSON(t *testing.T) {
TotalEngines: 3,
DisabledTargets: 4,
Version: 5,
Leader: 6,
ServiceLeader: 6,
EnabledRanks: ranklist.MustCreateRankSet("[0-3,5]"),
DisabledRanks: &ranklist.RankSet{},
PoolLayoutVer: 7,
UpgradeLayoutVer: 8,
},
},
exp: `{"enabled_ranks":[0,1,2,3,5],"disabled_ranks":[],"status":0,"state":"Ready","uuid":"` + poolUUID.String() + `","total_targets":1,"active_targets":2,"total_engines":3,"disabled_targets":4,"version":5,"leader":6,"svc_reps":null,"rebuild":null,"tier_stats":null,"pool_layout_ver":7,"upgrade_layout_ver":8}`,
exp: `{"enabled_ranks":[0,1,2,3,5],"disabled_ranks":[],"status":0,"state":"Ready","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}`,
},
} {
t.Run(name, func(t *testing.T) {
Expand All @@ -855,7 +855,7 @@ func TestControl_PoolQueryResp_UnmarshalJSON(t *testing.T) {
expErr error
}{
"null rankset": {
data: `{"enabled_ranks":null,"disabled_ranks":null,"status":0,"uuid":"` + poolUUID.String() + `","total_targets":1,"active_targets":2,"total_engines":3,"disabled_targets":4,"version":5,"leader":6,"svc_reps":null,"rebuild":null,"tier_stats":null,"pool_layout_ver":7,"upgrade_layout_ver":8}`,
data: `{"enabled_ranks":null,"disabled_ranks":null,"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}`,
expResp: PoolQueryResp{
Status: 0,
PoolInfo: daos.PoolInfo{
Expand All @@ -865,14 +865,14 @@ func TestControl_PoolQueryResp_UnmarshalJSON(t *testing.T) {
TotalEngines: 3,
DisabledTargets: 4,
Version: 5,
Leader: 6,
ServiceLeader: 6,
PoolLayoutVer: 7,
UpgradeLayoutVer: 8,
},
},
},
"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,"leader":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}`,
expResp: PoolQueryResp{
Status: 0,
PoolInfo: daos.PoolInfo{
Expand All @@ -882,7 +882,7 @@ func TestControl_PoolQueryResp_UnmarshalJSON(t *testing.T) {
TotalEngines: 3,
DisabledTargets: 4,
Version: 5,
Leader: 6,
ServiceLeader: 6,
EnabledRanks: ranklist.MustCreateRankSet("[0-3,5]"),
DisabledRanks: &ranklist.RankSet{},
PoolLayoutVer: 7,
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 @@ -60,7 +60,7 @@ type (
TotalEngines uint32 `json:"total_engines"`
DisabledTargets uint32 `json:"disabled_targets"`
Version uint32 `json:"version"`
Leader uint32 `json:"leader"`
ServiceLeader uint32 `json:"svc_ldr"`
ServiceReplicas []ranklist.Rank `json:"svc_reps"`
Rebuild *PoolRebuildStatus `json:"rebuild"`
TierStats []*StorageUsageStats `json:"tier_stats"`
Expand Down
5 changes: 4 additions & 1 deletion src/control/server/mgmt_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ func (svc *mgmtSvc) poolCreate(parent context.Context, req *mgmtpb.PoolCreateReq
return nil, errors.Wrap(err, "query on already-created pool failed")
}

resp.SvcLdr = qr.Leader
resp.SvcLdr = qr.SvcLdr
resp.SvcReps = ranklist.RanksToUint32(ps.Replicas)
resp.TgtRanks = ranklist.RanksToUint32(ps.Storage.CreationRanks())
resp.TierBytes = ps.Storage.PerRankTierStorage
Expand Down Expand Up @@ -926,6 +926,9 @@ func (svc *mgmtSvc) PoolQuery(ctx context.Context, req *mgmtpb.PoolQueryReq) (*m
return nil, errors.Wrap(err, "unmarshal PoolQuery response")
}

// Preserve compatibility with pre-2.6 callers.
resp.Leader = resp.SvcLdr

return resp, nil
}

Expand Down
21 changes: 20 additions & 1 deletion src/control/server/mgmt_pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func TestServer_MgmtSvc_PoolCreateAlreadyExists(t *testing.T) {
"ready": {
state: system.PoolServiceStateReady,
queryResp: &mgmtpb.PoolQueryResp{
Leader: 1,
SvcLdr: 1,
},
expResp: &mgmtpb.PoolCreateResp{
SvcLdr: 1,
Expand Down Expand Up @@ -2066,6 +2066,25 @@ func TestServer_MgmtSvc_PoolQuery(t *testing.T) {
Uuid: mockUUID,
},
},
"successful query (includes pre-2.6 Leader field)": {
req: &mgmtpb.PoolQueryReq{
Id: mockUUID,
},
setupMockDrpc: func(svc *mgmtSvc, err error) {
resp := &mgmtpb.PoolQueryResp{
State: mgmtpb.PoolServiceState_Ready,
Uuid: mockUUID,
SvcLdr: 42,
}
setupMockDrpcClient(svc, resp, nil)
},
expResp: &mgmtpb.PoolQueryResp{
State: mgmtpb.PoolServiceState_Ready,
Uuid: mockUUID,
SvcLdr: 42,
Leader: 42,
},
},
} {
t.Run(name, func(t *testing.T) {
buf.Reset()
Expand Down
Loading

0 comments on commit 8ef0b8d

Please sign in to comment.