Skip to content
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

kvs: move "wait_version" API into "kvsroot" API #6628

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

chu11
Copy link
Member

@chu11 chu11 commented Feb 12, 2025

Built on top of #6627

The "wait_version" convenience functions sit in their own file / API mostly due to legacy of their original implementation from old KVS watchers. It's only 3 convenience functions operating on kvsroot.

Move them and tests into the "kvsroot" API, therefore removing the kvs_wait_version files and tests.

chu11 added 12 commits February 12, 2025 12:36
Problem: In kvsroot and kvs_wait_version tests we should bail out
if a call to cache_create() fails.  This is missed in some cases.

Call BAIL_OUT if cache_create() fails.
Problem: The kvsroot convenience tests are scattered around in
one function.

Split out convenience function tests into new functions.
Problem: Some test functions in test/kvsroot.c are poorly name.

Add more descriptive function names.
Problem: A count is initialized to zero but the variable is never used.

Remove the dead line of code.
Problem: Some unit tests in test/kvs_wait_version.c use a global
variable for counting.  Instead, a counter should be passed as
an argument to the callback.

Remove the global counting variable.  Pass a local variable as an
argument to a callback instead.
Problem: The internal function kvsroot_destroy() does not preserve
errno.  Callers must do it themselves.  This is not the common
code pattern in flux-core.

Have kvsroot_destroy() preserve errno.  Remove "saving errno" that
callers are doing.
Problem: The internal function kvs_wait_version_destroy() does not
preserve errno when it is called.

Preserve errno when kvs_wait_version_destroy() is called.
Problem: In the kvsroot data structure, a zhash_t is used for
transaction requests.  A zhashx_t is preferred in flux-core
nowadays because it does not have as large of a initial memory
footprint.

Convert transaction_requests from a zhash_t to zhashx_t.
Problem: The primary roothash is a zhash_t, however it is more
common to use a zhashx_t in flux-core since the initial memory
footprint is much smaller.

Convert roothash to use a zhashx_t over a zhash_t.
Problem: The kvs wait_version API is mostly a set of convenience
functions on the kvsroot.  The API is quite small and exists as
a separate file mostly due to the legacy implementation of KVS
"watchers" in the KVS.

Move the wait_version API functions into kvsroot, which ends up
only being 3 new convenience functions.  Move over the kvs wait_version
unit tests into the kvsroot ones.  Remove the old wait_version API
files and test files.
Problem: The wait_version_list is a zlist_t, which does not allow
users to remove items from the list while iterating through the list.
A zlistx_t would allow removal of items while iterating through the list.

Solution: Convert wait_version_list to a zlistx_t.  In kvs_wait_version_remove_msg()
adjust code to no longer need a temporary list of messages to be removed.
Problem: In the kvsroot code a removelist is a zlist_t.  It is
the only zlist or zhash that has not been converted into a
"x" equivalent in the kvsroot.

For consistency, update removelist from zlist_t to zlistx_t.
Copy link

codecov bot commented Feb 12, 2025

Codecov Report

Attention: Patch coverage is 88.88889% with 11 lines in your changes missing coverage. Please review.

Project coverage is 83.86%. Comparing base (27f4390) to head (8803786).

Files with missing lines Patch % Lines
src/modules/kvs/kvsroot.c 90.32% 9 Missing ⚠️
src/modules/kvs/kvs.c 66.66% 2 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master    #6628   +/-   ##
=======================================
  Coverage   83.86%   83.86%           
=======================================
  Files         534      533    -1     
  Lines       88358    88340   -18     
=======================================
- Hits        74100    74086   -14     
+ Misses      14258    14254    -4     
Files with missing lines Coverage Δ
src/modules/kvs/kvs.c 73.96% <66.66%> (ø)
src/modules/kvs/kvsroot.c 84.18% <90.32%> (+10.53%) ⬆️

... and 6 files with indirect coverage changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant