Skip to content

Commit

Permalink
handle fetch retries on pool count changes
Browse files Browse the repository at this point in the history
Signed-off-by: Michael MacDonald <mjmac@google.com>
  • Loading branch information
mjmac committed Jun 26, 2024
1 parent b4a14de commit 41ac85d
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 25 deletions.
54 changes: 34 additions & 20 deletions src/control/cmd/daos/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -599,34 +599,48 @@ func (cmd *poolAutoTestCmd) Execute(_ []string) error {
}

func getPoolList(log logging.Logger, sysName string, queryEnabled bool) ([]*daos.PoolInfo, error) {
var rc C.int
bufSize := C.size_t(0)

// First, fetch the total number of pools in the system.
// We may not have access to all of them, so this is an upper bound.
rc = C.daos_mgmt_list_pools(nil, &bufSize, nil, nil)
if err := daosError(rc); err != nil {
return nil, err
}

if bufSize < 1 {
return nil, nil
}

var cSysName *C.char
if sysName != "" {
cSysName := C.CString(sysName)
defer freeString(cSysName)
}

// Now, we actually fetch the pools into the buffer that we've created.
cPools := make([]C.daos_mgmt_pool_info_t, bufSize)
rc = C.daos_mgmt_list_pools(nil, &bufSize, &cPools[0], nil)
if err := daosError(rc); err != nil {
var cPools []C.daos_mgmt_pool_info_t
for {
var rc C.int
var poolCount C.size_t

// First, fetch the total number of pools in the system.
// We may not have access to all of them, so this is an upper bound.
rc = C.daos_mgmt_list_pools(cSysName, &poolCount, nil, nil)
if err := daosError(rc); err != nil {
return nil, err
}
log.Debugf("pools in system: %d", poolCount)

if poolCount < 1 {
return nil, nil
}

// Now, we actually fetch the pools into the buffer that we've created.
cPools = make([]C.daos_mgmt_pool_info_t, poolCount)
rc = C.daos_mgmt_list_pools(cSysName, &poolCount, &cPools[0], nil)
err := daosError(rc)
if err == nil {
cPools = cPools[:poolCount] // adjust the slice to the number of pools retrieved
log.Debugf("fetched %d pools", len(cPools))
break
}
if err == daos.StructTooSmall {
log.Notice("server-side pool list changed; re-fetching")
continue
}
log.Errorf("failed to fetch pool list: %s", err)
return nil, err
}
pools := make([]*daos.PoolInfo, 0, bufSize)
for i := 0; i < int(bufSize); i++ {

pools := make([]*daos.PoolInfo, 0, len(cPools))
for i := 0; i < len(cPools); i++ {
cPool := &cPools[i]

svcRanks, err := rankSetFromC(cPool.mgpi_svc)
Expand Down
4 changes: 2 additions & 2 deletions src/engine/drpc_client.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* (C) Copyright 2019-2021 Intel Corporation.
* (C) Copyright 2019-2024 Intel Corporation.
*
* SPDX-License-Identifier: BSD-2-Clause-Patent
*/
Expand Down Expand Up @@ -459,7 +459,7 @@ ds_get_pool_list(uint64_t *npools, daos_mgmt_pool_info_t *pools)
if (*npools > 0 && lp_resp->n_pools > *npools) {
D_ERROR("pool list exceeds request buffer (req: %lu, actual: %lu)", *npools,
lp_resp->n_pools);
D_GOTO(out_resp, rc = -DER_TRUNC);
D_GOTO(out_resp, rc = -DER_OVERFLOW);
}

*npools = lp_resp->n_pools;
Expand Down
4 changes: 1 addition & 3 deletions src/mgmt/cli_mgmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -1374,10 +1374,8 @@ dc_mgmt_pool_list(tse_task_t *task)
}

rc = out->plo_op.mo_rc;
if (rc != 0) {
DL_ERROR(rc, "failed to list pools");
if (rc != 0)
D_GOTO(out_put_req, rc);
}

*args->npools = out->plo_npools;

Expand Down
9 changes: 9 additions & 0 deletions src/mgmt/srv.c
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,15 @@ ds_mgmt_pool_list_hdlr(crt_rpc_t *rpc)
send_resp:
out->plo_op.mo_rc = rc;

if (rc == 0) {
if (n_rpc > 0)
D_DEBUG(DB_MGMT, "returning %zu/%zu pools\n", n_rpc, n_mgmt);
else
D_DEBUG(DB_MGMT, "returning %zu pools\n", n_mgmt);
} else {
DL_ERROR(rc, "failed to list pools");
}

rc = crt_reply_send(rpc);
if (rc != 0)
DL_ERROR(rc, "crt_reply_send() failed");
Expand Down

0 comments on commit 41ac85d

Please sign in to comment.