-
Notifications
You must be signed in to change notification settings - Fork 50
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
libkvs: cleanup, deprecate old functions, update users #1233
Conversation
Hmm, getting some travis failures and I'm having a hard time spotting the root cause. Best I can tell is things are going wrong with distcheck in the python bindings... [edited: it's pylint unhappy with a long line]
|
Codecov Report
@@ Coverage Diff @@
## master #1233 +/- ##
==========================================
- Coverage 78.12% 78.03% -0.09%
==========================================
Files 154 154
Lines 28812 28936 +124
==========================================
+ Hits 22508 22581 +73
- Misses 6304 6355 +51
|
16d135b
to
80eb26a
Compare
80eb26a
to
447bcdb
Compare
Pylint problem solved. Still todo: add some tests to cover missing bits, and put together a patch to update sched. |
return NULL; | ||
} | ||
} | ||
return dir->dirobj_string; |
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 the change from using dirobj_string
to json_str
be in a different commit, b/c this doesn't seem to be mapped to this commit message. It appears this also fixes a mem-leak.
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.
Yes that looks like a rebase error. I'll fix...
src/common/libkvs/kvs_lookup.c
Outdated
}; | ||
|
||
static const char *auxkey = "flux::lookup_ctx"; | ||
|
||
static void free_ctx (struct lookup_ctx *ctx) | ||
{ | ||
if (ctx) { | ||
free (ctx->key); | ||
free (ctx->treeobj_str); |
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 we free atref
too? Can't see where else it is freed.
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.
Yes good catch! I'll fix that.
@@ -254,8 +254,11 @@ static int l_flux_new (lua_State *L) | |||
static int l_flux_kvsdir_new (lua_State *L) |
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.
commit seems to do more than just update to use flux_kvs_lookup_get_dir
. Perhaps commit message should just be enhanced.
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.
oh yeah, this specific line is not relevant, just didn't know how to comment on a commit message.
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.
Yes that was pretty vague. Changed to
bindings/lua: use flux_kvs_lookup()
Replace use of soon to be deprecated flux_kvs_get()
and flux_kvs_get_dir() with modern flux_kvs_lookup()
equivalents.
447bcdb
to
892b1e2
Compare
src/common/libkvs/kvs_watch.h
Outdated
*/ | ||
int flux_kvs_watch_once (flux_t *h, const char *key, char **json_str); | ||
|
||
/* Same as above except value is a direcory pointed to by 'dirp'. |
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.
typo directory
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.
raced on comments/old commit and github is showing my comment as outdated. typo directory
just finished skimming over everything. Overall looks good. Lots of lines of code, so hopefully I didn't miss anything. I think @grondo should look over the wreck and job areas that were updated, as I don't know that code as well. |
892b1e2
to
f2cdd98
Compare
Thanks - fixed the "directory" typo, squashed and pushed. |
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.
Looks fine to me. Just a couple comments on flux_kvs_lookup_get_dir
-- not sure if they were appropriate for this PR, but just wanted to feel like I was contributing ;-)
@@ -53,6 +55,9 @@ the returned JSON is parsed according to variable arguments in Jansson | |||
`flux_kvs_lookup_get_raw()` is identical to `flux_kvs_lookup_get()` except | |||
the raw value is returned without decoding. | |||
|
|||
`flux_kvs_lookup_get_dir()` is identical to `flux_kvs_lookup_get()` except | |||
a directory object is returned. | |||
|
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.
I know you are considering removal of the kvsdir
abstraction, but in the context of the addition of flux_kvs_lookup_get_dir
it might be useful to consider addition of a refcount to kvsdir objects. This would avoid the necessary copies in the common case where we want the kvsdir to persist, but we're done with the future.
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.
We do have flux_kvsdir_incref()
but since the object returned from the lookup is const (indicating that it still belongs to the future), it seems a bit wrong to allow its reference count to be modified? This is why I added flux_kvsdir_copy()
, but I intended that to be short lived until the various places where flux_kvsdir_t
was used for purposes other than "list of names in directory" were converted to something else TBD.
As we just discussed offline, possibly we need to come up with a new object that serves as a handle to the KVS, and contains things like a "current working directory", a snapshot reference, or a namespace handle, as well as the broker handle, and then all KVS functions would take one of those instead of the broker handle... I'll open an issue on that idea.
|| !(f = flux_kvs_lookup (h, FLUX_KVS_READDIR, key)) | ||
|| flux_kvs_lookup_get_dir (f, &dir) < 0 | ||
|| !(t->kvs = flux_kvsdir_copy (dir))) { | ||
if (errno != ENOENT) |
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 chunk of code is repeated twice at least in this source file, maybe it could be its own static function? In general, the lookup->get_dir->copy_dir seems to be common enough idiom that I'm wondering why there isn't a function in the API for it, but it isn't quite common enough for me to care (especially if the flux_kvsdir_t is going to go away.)
One other thing. Looks like Maybe we can just drop that part of wrexecd and remove |
I'm good with that - let me see if I can do that really quick. o/w I will add a test. |
f2cdd98
to
06cd847
Compare
Dropped |
06cd847
to
8101399
Compare
Problem: "struct kvsdir_struct" and "struct kvsitr_struct" do not comply with RFC 7. Drop the "_struct" suffix.
A minor refactoring eliminated an extra flux_kvs_commit() on job creation - previously, one commit was used to set the initial job state, and another commit populated the initial contents of the job directory using JSON data from the request.
Drop wrexecd's code that handles the flux-wreckrun(1) and flux-submit() --no-aggregate-task-exit option which is described as Do not use aggregator for task exit messages. This option will result in each task's exit status being committed separately into the kvs. This was the only user of flux_kvs_put_int(), and @grondo thought we could safely get rid of it.
Replace use of soon to be deprecated flux_kvs_get() and flux_kvs_get_dir() with modern flux_kvs_lookup() equivalents.
Modernize some aspects of libkz's KVS API usage. I held back converting the "anonymous" transactions to explicit ones, as doing so seemed to hang up the wreck tests. My best guess is that something in wrexecd that is written to the anonymous transaction is actually being committed by an anonymous commit/fence in libkz. Since this code is due to be replaced it didn't seem like time well spent right now to run this down.
Expose a version of flux_kvs_txn_pack() that accepts a va_list argument, so it can easily be wrapped. Tweak python Makefile to allow va_list to appear in a kvs header. Doh! The python header parser doesn't like line breaks in function prototypes containing va_list (opened flux-framework#1221).
Add a function that can replace the individual typed flux_kvsdir_put_*() functions, thus reducing the number of functions to be deprecated a little bit.
Drop flux_kvs_put_string() flux_kvs_put_int() flux_kvs_put_int64() These functions have no users
Drop flux_kvsdir_put_string() flux_kvsdir_put_int() flux_kvsdir_put_int64() flux_kvsdir_put_double() flux_kvsdir_put_boolean() Switch wrexecd, dtree, and lua bindings over to flux_kvsdir_pack().
Problem: several "classic" KVS API functions accept flux_kvsdir_t parameters which they do not modify. Tag these parameters const to make that clearer.
Reimplement flux_kvs_get_dir() and flux_kvsdir_get_dir() internally in terms of flux_kvs_lookup_get_dir().
Problem: there is no current documentation for classic KVS functions, yet they have not been deprecated. Add some inline documentation to the header, with pointers to the newer functions that replace them.
Add __attribute__ ((deprecated)) to all kvs_classic functions.
Problem: There is no documentation for flux_kvsdir_t. The flux_kvsdir_t probably won't be deprecated although it may be slimmed down in the future. Meanwhile there are still users. Start with some inline documentation in the header.
Problem: there is no current documentation for flux_kvs_watch functions. These functions are liable to change, so it is probably not a good use of time to create a manual page at this point. Update the inline header documentation as a stop gap measure.
This PR is an attempt at some long overdue KVS API cleanup. Not ready for merge consideration until a PR is submitted to update sched.
All KVS API components are prefixed with
flux_
now, and thekvs_*
,kvsitr_*
, andkvsdir_*
prefixes are dropped from flux-core symbol exports.The older API functions defined in kvs_classic.h are marked with
__attribute__ ((deprecated))
. I stopped short of moving these functions to libcompat, which would take them out of the exported namespace, due to difficulties with the python bindings. The old "typed" get/put functions that remain were replaced with jansson pack/unpack style equivalents to reduce the deprecated API footprint somewhat.The kvs_dir.h functions, while still not quite right, were cleaned up a bit, including making some
flux_kvsdir_t *
parametersconst
that ought to have been.Some new functions were introduced:
Finally, inline (header) documentation was added/updated for kvs_dir.h, kvs_watch.h, and kvs_classic.h which are still not quite stable IMHO. Man pages were added for the new lookup and txn functions.
I did not fully modernize the API usage of wreck, libkz, and the lua bindings since some of that code is going to be replaced and it was pretty involved. There will be a few more deprecated function warnings when building those for now.
The kvs_watch.h API is still the old one and in dire need of redesign, but not dealt with here.