Skip to content

DAOS-16311 control: Add C bindings for control API#17550

Draft
mjmac wants to merge 3 commits into
masterfrom
mjmac/DAOS-16311
Draft

DAOS-16311 control: Add C bindings for control API#17550
mjmac wants to merge 3 commits into
masterfrom
mjmac/DAOS-16311

Conversation

@mjmac

@mjmac mjmac commented Feb 11, 2026

Copy link
Copy Markdown
Contributor

Use Go's c-shared-library mode to build a .so that
exposes a C API for the Go Control API. The initial
use case for this library is to replace the problematic
dmg helpers test library that uses fork/exec to allow
tests to drive dmg commands.

Signed-off-by: Michael MacDonald github@macdonald.cx

@github-actions

Copy link
Copy Markdown

Ticket title is 'C bindings for DAOS control API'
Status is 'In Progress'
Labels: 'ci_2.6_daily,ci_2.6_provider,ci_master_daily,ci_master_provider'
https://daosio.atlassian.net/browse/DAOS-16311

@daosbuild3

Copy link
Copy Markdown
Collaborator

@daosbuild3

Copy link
Copy Markdown
Collaborator

Test stage Unit Test with memcheck on EL 8.8 completed with status UNSTABLE. https://jenkins-3.daos.hpc.amslabs.hpecorp.net/job/daos-stack/job/daos//view/change-requests/job/PR-17550/2/testReport/

@daosbuild3

Copy link
Copy Markdown
Collaborator

Test stage Unit Test bdev with memcheck on EL 8.8 completed with status UNSTABLE. https://jenkins-3.daos.hpc.amslabs.hpecorp.net/job/daos-stack/job/daos//view/change-requests/job/PR-17550/2/testReport/

@daosbuild3

Copy link
Copy Markdown
Collaborator

@daosbuild3

Copy link
Copy Markdown
Collaborator

Test stage Functional on EL 8.8 completed with status FAILURE. https://jenkins-3.daos.hpc.amslabs.hpecorp.net/job/daos-stack/job/daos/job/PR-17550/2/display/redirect

1 similar comment
@daosbuild3

Copy link
Copy Markdown
Collaborator

Test stage Functional on EL 8.8 completed with status FAILURE. https://jenkins-3.daos.hpc.amslabs.hpecorp.net/job/daos-stack/job/daos/job/PR-17550/2/display/redirect

@daosbuild3

Copy link
Copy Markdown
Collaborator

@daosbuild3

Copy link
Copy Markdown
Collaborator

Test stage Unit Test with memcheck on EL 8.8 completed with status UNSTABLE. https://jenkins-3.daos.hpc.amslabs.hpecorp.net/job/daos-stack/job/daos//view/change-requests/job/PR-17550/3/testReport/

@daosbuild3

Copy link
Copy Markdown
Collaborator

Test stage Unit Test bdev with memcheck on EL 8.8 completed with status UNSTABLE. https://jenkins-3.daos.hpc.amslabs.hpecorp.net/job/daos-stack/job/daos//view/change-requests/job/PR-17550/3/testReport/

@daosbuild3

Copy link
Copy Markdown
Collaborator

@daosbuild3

Copy link
Copy Markdown
Collaborator

Test stage Unit Test with memcheck on EL 8.8 completed with status UNSTABLE. https://jenkins-3.daos.hpc.amslabs.hpecorp.net/job/daos-stack/job/daos//view/change-requests/job/PR-17550/4/testReport/

@daosbuild3

Copy link
Copy Markdown
Collaborator

Test stage Unit Test bdev with memcheck on EL 8.8 completed with status UNSTABLE. https://jenkins-3.daos.hpc.amslabs.hpecorp.net/job/daos-stack/job/daos//view/change-requests/job/PR-17550/4/testReport/

@daosbuild3

Copy link
Copy Markdown
Collaborator

@daosbuild3

Copy link
Copy Markdown
Collaborator

Test stage Functional on EL 8.8 completed with status FAILURE. https://jenkins-3.daos.hpc.amslabs.hpecorp.net/job/daos-stack/job/daos/job/PR-17550/4/display/redirect

1 similar comment
@daosbuild3

Copy link
Copy Markdown
Collaborator

Test stage Functional on EL 8.8 completed with status FAILURE. https://jenkins-3.daos.hpc.amslabs.hpecorp.net/job/daos-stack/job/daos/job/PR-17550/4/display/redirect

@daosbuild3

Copy link
Copy Markdown
Collaborator

Test stage Unit Test bdev with memcheck on EL 8.8 completed with status UNSTABLE. https://jenkins-3.daos.hpc.amslabs.hpecorp.net/job/daos-stack/job/daos//view/change-requests/job/PR-17550/5/testReport/

@daosbuild3

Copy link
Copy Markdown
Collaborator

Test stage Unit Test with memcheck on EL 8.8 completed with status UNSTABLE. https://jenkins-3.daos.hpc.amslabs.hpecorp.net/job/daos-stack/job/daos//view/change-requests/job/PR-17550/5/testReport/

@daosbuild3

Copy link
Copy Markdown
Collaborator

@daosbuild3

Copy link
Copy Markdown
Collaborator

@daosbuild3

Copy link
Copy Markdown
Collaborator

Test stage Unit Test with memcheck on EL 8.8 completed with status UNSTABLE. https://jenkins-3.daos.hpc.amslabs.hpecorp.net/job/daos-stack/job/daos//view/change-requests/job/PR-17550/6/testReport/

@daosbuild3

Copy link
Copy Markdown
Collaborator

Test stage Unit Test bdev with memcheck on EL 8.8 completed with status UNSTABLE. https://jenkins-3.daos.hpc.amslabs.hpecorp.net/job/daos-stack/job/daos//view/change-requests/job/PR-17550/6/testReport/

@daosbuild3

Copy link
Copy Markdown
Collaborator

@daosbuild3

Copy link
Copy Markdown
Collaborator

Test stage Functional on EL 8.8 completed with status FAILURE. https://jenkins-3.daos.hpc.amslabs.hpecorp.net/job/daos-stack/job/daos/job/PR-17550/6/display/redirect

1 similar comment
@daosbuild3

Copy link
Copy Markdown
Collaborator

Test stage Functional on EL 8.8 completed with status FAILURE. https://jenkins-3.daos.hpc.amslabs.hpecorp.net/job/daos-stack/job/daos/job/PR-17550/6/display/redirect

@daosbuild3

Copy link
Copy Markdown
Collaborator

Test stage Functional Hardware Medium MD on SSD completed with status FAILURE. https://jenkins-3.daos.hpc.amslabs.hpecorp.net//job/daos-stack/job/daos/view/change-requests/job/PR-17550/41/execution/node/1284/log

@daosbuild3

Copy link
Copy Markdown
Collaborator

Test stage Functional Hardware Medium MD on SSD completed with status UNSTABLE. https://jenkins-3.daos.hpc.amslabs.hpecorp.net/job/daos-stack/job/daos//view/change-requests/job/PR-17550/42/testReport/

@daosbuild3

Copy link
Copy Markdown
Collaborator

Test stage Functional Hardware Medium Verbs Provider MD on SSD completed with status UNSTABLE. https://jenkins-3.daos.hpc.amslabs.hpecorp.net/job/daos-stack/job/daos//view/change-requests/job/PR-17550/42/testReport/

@mjmac mjmac force-pushed the mjmac/DAOS-16311 branch from a7a74e4 to 5d68fed Compare June 2, 2026 14:46
@mjmac mjmac requested a review from kjacque June 2, 2026 15:27
@daosbuild3

Copy link
Copy Markdown
Collaborator

@daosbuild3

Copy link
Copy Markdown
Collaborator

@mjmac mjmac force-pushed the mjmac/DAOS-16311 branch from 5d68fed to 9abc728 Compare June 4, 2026 14:46
@daosbuild3

Copy link
Copy Markdown
Collaborator

@kjacque kjacque left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall I like the approach. I gave it a fairly superficial look over, my comments are mostly on the tests.

I don't like the callProductionCode type test wrappers if they aren't really saving us a lot of repetition--they make it harder to understand what the tests are doing, since I have to keep jumping between files to remember what the wrapper is hiding.

Comment on lines +57 to +60
if rc == 0 {
callFini(handle)
t.Fatal("expected error for non-existent config file, got success")
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can probably expect a specific error rc here, right?

In general these test cases might be a good fit for table-formatted tests.

func recoverExport(rc *C.int) {
if r := recover(); r != nil {
fmt.Fprintf(os.Stderr, "panic in libdaos_control export: %v\n%s\n", r, debug.Stack())
*rc = C.int(daos.MiscError)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be worth creating a new error code for this scenario.

/**
* Arguments for daos_control_pool_create.
*/
struct daos_control_pool_create_args {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wonder if this would be better to split into two structs, with in-args and out-args.

Comment thread src/include/daos/control_types.h Outdated
Comment on lines +95 to +101
/**
* Maximum number of interactive action choices per check report. The server
* currently caps this at CHK_INTERACT_OPTION_MAX (src/chk/chk_internal.h);
* this value must be >= the server cap. check.go truncates extra choices if
* the server ever sends more than fit here.
*/
#define DAOS_CHECK_MAX_ACT_OPTIONS 4

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like we don't have the advantage of a file that sees both of these, if it's coming from an internal header. I don't love having to maintain something like this in both places. Is there a public file the internal definition could be moved to?

* DAOS checker pool information.
*/
struct daos_check_pool_info {
uuid_t dcpi_uuid;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some structs are using this prefix style, while others just have bare names for member variables. IMO we should stick to one or the other.

return errorToRC(validatePoolCreateArgs(&args))
}

func callPoolDestroy(handle cgo.Handle, poolUUID uuid.UUID, force bool) int {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't love how these helpers hide the function actually being tested. Can't most of these go into the body of the tests? Or at the very least, the test file where they're relevant?

Comment on lines +180 to +197
func TestSystemExcludeRank(t *testing.T) {
for name, tc := range map[string]struct {
mic *control.MockInvokerConfig
rank uint32
expRC int
}{
"success": {
mic: &control.MockInvokerConfig{
UnaryResponse: control.MockMSResponse("host1", nil, &mgmtpb.SystemExcludeResp{
Results: []*sharedpb.RankResult{
{Rank: 0, State: "excluded"},
},
}),
},
rank: 0,
expRC: 0,
},
} {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Going to add an error case for this one?

Comment on lines +22 to +33
} {
t.Run(name, func(t *testing.T) {
if got := testCopyStringToCharArray(tc.input, tc.bufSize); got != tc.want {
t.Fatalf("got %q, want %q", got, tc.want)
}
})
}
}

func TestCopyStringToCharArrayNilDest(t *testing.T) {
testCopyStringToNil()
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like helper functions but this is a little painful to read and understand. Are these helpers even re-used anywhere else?

Comment on lines +46 to +52
rpcFn := func(rpcCtx context.Context, conn *grpc.ClientConn) (proto.Message, error) {
if mgmtSvc != 0 {
return mgmtpb.NewMgmtSvcClient(conn).FaultInjectMgmtPoolFault(rpcCtx, payload)
}
return mgmtpb.NewMgmtSvcClient(conn).FaultInjectPoolFault(rpcCtx, payload)
}
_, err = control.InvokeFaultRPC(ctx.ctx(), ctx.client, rpcFn)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't have a control endpoint for this, I guess?


// propsFromC converts a daos_prop_t to Go PoolProperty values for a
// pool-create request.
func propsFromC(cProps *C.daos_prop_t) ([]*daos.PoolProperty, error) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the daos API (going in the other direction) have an existing utility function for this that could be re-used? Or no?

@daosbuild3

Copy link
Copy Markdown
Collaborator

Test stage Functional Hardware Medium Verbs Provider MD on SSD completed with status FAILURE. https://jenkins-3.daos.hpc.amslabs.hpecorp.net//job/daos-stack/job/daos/view/change-requests/job/PR-17550/44/execution/node/1434/log

@daosbuild3

Copy link
Copy Markdown
Collaborator

Test stage Functional Hardware Medium MD on SSD completed with status FAILURE. https://jenkins-3.daos.hpc.amslabs.hpecorp.net//job/daos-stack/job/daos/view/change-requests/job/PR-17550/44/execution/node/1424/log

@mjmac mjmac force-pushed the mjmac/DAOS-16311 branch from 9abc728 to 21c4fc3 Compare June 26, 2026 20:02
@daosbuild3

Copy link
Copy Markdown
Collaborator

Test stage Unit Test with memcheck completed with status UNSTABLE. https://jenkins-3.daos.hpc.amslabs.hpecorp.net/job/daos-stack/job/daos//view/change-requests/job/PR-17550/45/testReport/

@daosbuild3

Copy link
Copy Markdown
Collaborator

Test stage Unit Test bdev with memcheck completed with status UNSTABLE. https://jenkins-3.daos.hpc.amslabs.hpecorp.net/job/daos-stack/job/daos//view/change-requests/job/PR-17550/45/testReport/

@daosbuild3

Copy link
Copy Markdown
Collaborator

Test stage Functional Hardware Large MD on SSD completed with status FAILURE. https://jenkins-3.daos.hpc.amslabs.hpecorp.net//job/daos-stack/job/daos/view/change-requests/job/PR-17550/45/execution/node/1341/log

@daosbuild3

Copy link
Copy Markdown
Collaborator

Test stage Functional Hardware Medium MD on SSD completed with status FAILURE. https://jenkins-3.daos.hpc.amslabs.hpecorp.net//job/daos-stack/job/daos/view/change-requests/job/PR-17550/45/execution/node/1421/log

@daosbuild3

Copy link
Copy Markdown
Collaborator

Test stage Functional Hardware Medium Verbs Provider MD on SSD completed with status FAILURE. https://jenkins-3.daos.hpc.amslabs.hpecorp.net//job/daos-stack/job/daos/view/change-requests/job/PR-17550/45/execution/node/1462/log

@mjmac mjmac force-pushed the mjmac/DAOS-16311 branch from 21c4fc3 to a7cbd33 Compare June 29, 2026 18:03
@daosbuild3

Copy link
Copy Markdown
Collaborator

Test stage Unit Test with memcheck completed with status UNSTABLE. https://jenkins-3.daos.hpc.amslabs.hpecorp.net/job/daos-stack/job/daos//view/change-requests/job/PR-17550/46/testReport/

@daosbuild3

Copy link
Copy Markdown
Collaborator

Test stage Functional Hardware Medium Verbs Provider MD on SSD completed with status FAILURE. https://jenkins-3.daos.hpc.amslabs.hpecorp.net//job/daos-stack/job/daos/view/change-requests/job/PR-17550/46/execution/node/1620/log

@daosbuild3

Copy link
Copy Markdown
Collaborator

Test stage Functional Hardware Medium MD on SSD completed with status FAILURE. https://jenkins-3.daos.hpc.amslabs.hpecorp.net//job/daos-stack/job/daos/view/change-requests/job/PR-17550/46/execution/node/1610/log

@mjmac mjmac force-pushed the mjmac/DAOS-16311 branch from a7cbd33 to cc49cbb Compare June 30, 2026 19:47
@daosbuild3

Copy link
Copy Markdown
Collaborator

Test stage Functional Hardware Large MD on SSD completed with status FAILURE. https://jenkins-3.daos.hpc.amslabs.hpecorp.net//job/daos-stack/job/daos/view/change-requests/job/PR-17550/47/execution/node/1797/log

@daosbuild3

Copy link
Copy Markdown
Collaborator

Test stage Functional Hardware Medium Verbs Provider MD on SSD completed with status FAILURE. https://jenkins-3.daos.hpc.amslabs.hpecorp.net//job/daos-stack/job/daos/view/change-requests/job/PR-17550/47/execution/node/1777/log

@daosbuild3

Copy link
Copy Markdown
Collaborator

Test stage Functional Hardware Medium MD on SSD completed with status FAILURE. https://jenkins-3.daos.hpc.amslabs.hpecorp.net//job/daos-stack/job/daos/view/change-requests/job/PR-17550/47/execution/node/1787/log

mjmac added 3 commits July 4, 2026 10:17
Use Go's c-shared-library mode to build a .so that
exposes a C API for the Go Control API. The initial
use case for this library is to replace the problematic
dmg helpers test library that uses fork/exec to allow
tests to drive dmg commands.

Skip-hw-medium-ucx-provider: false
Features: cat_recov
Signed-off-by: Michael MacDonald <github@macdonald.cx>
  * daos_pool: Don't escape self_heal prop value
  * control/server.go: Raw %v logging panics on nil; just remove it

Signed-off-by: Michael MacDonald <github@macdonald.cx>
Update the cat_recov suite to work better with the new
libdaos_control bindings, which operate more quickly and
correctly than the old fork/exec dmg wrappers.

- Check repair takes the CIA_ action value directly, where the old
  dmg CLI translated a selection index into the action.
- The bindings answer queries in milliseconds where the fork/exec dmg
  helpers took 1-2s, which throws off some of the timing assumptions
  in the tests. Adjust to use a wall-clock budget instead of counting
  query iterations.
- Pool-not-found now maps to DER_NONEXIST instead of DER_MISC, so
  cr_cleanup no longer needs to tolerate DER_MISC.

Skip-hw-medium-ucx-provider: false
Features: cat_recov daos_core_test_nvme
Signed-off-by: Michael MacDonald <github@macdonald.cx>
@mjmac mjmac force-pushed the mjmac/DAOS-16311 branch from cc49cbb to 4031a1a Compare July 4, 2026 14:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants