-
Notifications
You must be signed in to change notification settings - Fork 306
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DAOS-10028 client: Add Go bindings for libdaos (Pool) #15659
base: master
Are you sure you want to change the base?
Conversation
Ticket title is 'Update golang binding for the DAOS API' |
20e923c
to
68a15e1
Compare
Test stage Build RPM on EL 9 completed with status FAILURE. https://build.hpdd.intel.com//job/daos-stack/job/daos/view/change-requests/job/PR-15659/2/execution/node/345/log |
Test stage Build RPM on EL 8 completed with status FAILURE. https://build.hpdd.intel.com//job/daos-stack/job/daos/view/change-requests/job/PR-15659/2/execution/node/346/log |
Test stage Build RPM on Leap 15.5 completed with status FAILURE. https://build.hpdd.intel.com//job/daos-stack/job/daos/view/change-requests/job/PR-15659/2/execution/node/337/log |
Test stage Build DEB on Ubuntu 20.04 completed with status FAILURE. https://build.hpdd.intel.com//job/daos-stack/job/daos/view/change-requests/job/PR-15659/2/execution/node/340/log |
Test stage Build on EL 8 completed with status FAILURE. https://build.hpdd.intel.com//job/daos-stack/job/daos/view/change-requests/job/PR-15659/2/execution/node/469/log |
Test stage Build on Leap 15.5 with Intel-C and TARGET_PREFIX completed with status FAILURE. https://build.hpdd.intel.com//job/daos-stack/job/daos/view/change-requests/job/PR-15659/2/execution/node/508/log |
785f5c7
to
d94cc38
Compare
Test stage Functional Hardware Large completed with status FAILURE. https://build.hpdd.intel.com//job/daos-stack/job/daos/view/change-requests/job/PR-15659/4/execution/node/1483/log |
Test stage Functional Hardware Large completed with status FAILURE. https://build.hpdd.intel.com//job/daos-stack/job/daos/view/change-requests/job/PR-15659/5/execution/node/544/log |
Test stage Functional Hardware Medium completed with status FAILURE. https://build.hpdd.intel.com//job/daos-stack/job/daos/view/change-requests/job/PR-15659/5/execution/node/560/log |
5a76de4
to
628f3ce
Compare
Test stage NLT on EL 8.8 completed with status UNSTABLE. https://build.hpdd.intel.com/job/daos-stack/job/daos//view/change-requests/job/PR-15659/7/testReport/ |
510d64b
to
90ef6d7
Compare
Test stage Functional Hardware Large completed with status FAILURE. https://build.hpdd.intel.com//job/daos-stack/job/daos/view/change-requests/job/PR-15659/9/execution/node/1405/log |
Test stage Functional Hardware Medium completed with status FAILURE. https://build.hpdd.intel.com//job/daos-stack/job/daos/view/change-requests/job/PR-15659/9/execution/node/1415/log |
90ef6d7
to
ad55ebd
Compare
6d9b688
to
5f28018
Compare
7a1ccde
to
aae584f
Compare
aae584f
to
cf8ef8a
Compare
Start the work of converting the raw cgo in the daos tool into proper Go bindings for libdaos. This patch covers pool functionality and adds some new infrastructure common to both pools and containers. Features: daos_cmd Required-githooks: true Signed-off-by: Michael MacDonald <[email protected]>
cf8ef8a
to
9b0d824
Compare
Note to reviewers... Yeah, this is big. It's the first of several patches, though, and contains a lot of the infrastructure needed to start the change over to using the client API instead of raw cgo in the daos tool. There is no new functionality here, and my focus will be on maintaining parity with the existing implementation for now. Most of the "new" code is just the existing cgo moved over into the API, along with extensive unit tests. Imagine that, unit tests! For context, this is the first follow-on PR (still a WIP): #15721 |
Features: daos_cmd Required-githooks: true Signed-off-by: Michael MacDonald <[email protected]>
Test stage NLT on EL 8.8 completed with status UNSTABLE. https://build.hpdd.intel.com/job/daos-stack/job/daos//view/change-requests/job/PR-15659/23/testReport/ |
If it's helpful, it may be easiest to focus on the changes to the Starting with those changes should give reviewers a sense of how the new API works, e.g.
The code under |
Signed-off-by: Michael MacDonald <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A nice cleanup overall. I do find myself worrying about the rapidly-expanding stubs, though. I'm also curious how people are supposed to mock the API without the stubs, given that they are functions and not interfaces.
/*case contAttr: | ||
rc = daos_cont_list_attr(hdl, nil, &totalSize, nil)*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this need to be enabled? Or removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was code moved over from the tool... The next PR (#15721) migrates a lot of the container logic into the API, and these are uncommented.
/*case contAttr: | ||
rc = daos_cont_list_attr(hdl, (*C.char)(buf), &totalSize, nil)*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same question
/*case contAttr: | ||
rc = daos_cont_get_attr(hdl, C.int(numAttr), &attrNames[0], nil, &attrSizes[0], nil)*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same question -- if these are being left as placeholders, it would be better to add a TODO with a ticket number.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Next PR (#15721) is coming in hot right behind this one. :) Trying to make them a little easier to review in chunks.
// Next, create a slice of C.size_t entries to hold the sizes of the values, | ||
// and a slice of pointers to the actual values. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason this step couldn't be done at the same time as the previous one? I understand why we couldn't do that for the getter, but the setter should be able to build all of these arrays at the same time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code has been working as-is for a couple of years now. My inclination is to get it all moved inside the API with proper unit tests first, and then work on cleaning up inefficiencies with confidence that the unit tests will find any mistakes.
// this handle -- use of this method should be discouraged as | ||
// it is provided for compatibility with older code that calls | ||
// into libdaos directly. | ||
func (ch *connHandle) FillHandle(cHandle unsafe.Pointer) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The caller is a CGo function, right? Any reason cHandle
shouldn't explicitly be a *C.daos_handle_t
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, this function is for users outside of the API boundary (e.g. the daos tool). Can't use C types in public function signatures. Eventually we should be able to remove this entirely once the API is complete and all of the tool code is cleaned up.
// Long-term, this should be phased out as API users should mock | ||
// the API instead of relying on the stubs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO we probably need a task to change any existing code at the higher level so people don't imitate it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, good point. I see these as temporary scaffolding for the construction of the API. I'll update the comment to make that more explicit.
/*static inline uint32_t | ||
get_rebuild_state(struct daos_rebuild_status *drs) | ||
{ | ||
if (drs == NULL) | ||
return 0; | ||
|
||
return drs->rs_state; | ||
}*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be commented out?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I think that's cruft that I missed. I'll remove it if I need to make changes to this PR, or in the next one.
I really don't see a better way to make the code testable, but I'm open to suggestions. Personally, I think it's fine for the long term because all of the stub stuff should eventually be hidden behind the API, so API users and external tests don't need to deal with them.
I was thinking about this the other day. I started playing around with the api.Provider thing when I added the health check stuff. One option would be to expand that to include methods for all of the API functions. At the moment, though, I think that would be a maintenance headache. I think a better way to do this is to delegate mocking to users of the API. So, e.g. out in the daos tool we can define interfaces for the parts of the API that we want to stub, and just create wrappers to implement those interfaces. This seems like a more maintainable and cleaner solution. I think it will be clearer as more of the tool code is moved into the API, and the code that remains under There's already some precedent for this kind of thing in the http.HandlerFunc pattern. Basically you can wrap a function in a struct with a method to implement an interface. We use it in the server: https://github.com/daos-stack/daos/blob/master/src/control/server/server_utils.go#L692 |
Start the work of converting the raw cgo in the daos
tool into proper Go bindings for libdaos. This patch
covers pool functionality and adds some new infrastructure
common to both pools and containers.
Features: daos_cmd pool
Required-githooks: true
Signed-off-by: Michael MacDonald [email protected]