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

Allow dynamic service registration and ability for local processes to register service names #1753

Merged
merged 21 commits into from
Oct 30, 2018

Commits on Oct 30, 2018

  1. broker: add service_get_uuid()

    Add a service_get_uuid() call to the broker's service switch
    module. This will be required to allow service deregistration when
    dynamic service registration is added to the broker.
    grondo committed Oct 30, 2018
    Configuration menu
    Copy the full SHA
    8d2772c View commit details
    Browse the repository at this point in the history
  2. broker: add function to lookup module by uuid

    Add a module_lookup() function to the broker's modhash interface
    to allow a lookup of modules by their uuid. This will be necessary
    for dynamic service registration/deregistration.
    grondo committed Oct 30, 2018
    Configuration menu
    Copy the full SHA
    007a16b View commit details
    Browse the repository at this point in the history
  3. broker: add dynamic service registration

    Add new RPCs service.add and service.remove to the broker, which allow
    modules to dynamically register alternate service names for which they
    will accept requests.
    
    Each of these RPCs take a single member payload with key "service" set
    to the name of the requested service to register (service.add) or
    deregister (service.remove).
    
    This allows a single module to register under more than 2 service names,
    and will eventually allow locally connected API clients to register
    services via the local conneector.
    grondo committed Oct 30, 2018
    Configuration menu
    Copy the full SHA
    eab9dd3 View commit details
    Browse the repository at this point in the history
  4. libflux: add flux_service_register/unregister

    Add flux_service_register and flux_service_unregister to the
    libflux API. These functions call the broker's `service.add` and
    `service.remove` methods on behalf of the caller.
    grondo committed Oct 30, 2018
    Configuration menu
    Copy the full SHA
    ce6f206 View commit details
    Browse the repository at this point in the history
  5. content-sqlite: use service.add RPC

    Instead of using the MOD_SERVICE macro to register the content-sqlite
    module under the "content-backing" service name, use the new service.add
    RPC offered by the broker.
    
    Since the name must be registered before entering the reactor, we use
    a synchronous RPC for `service.add`. This should have the equivalent
    effect of the previous MOD_SERVVICE() usage.
    grondo committed Oct 30, 2018
    Configuration menu
    Copy the full SHA
    b4ab5d0 View commit details
    Browse the repository at this point in the history
  6. broker/module: remove MOD_SERVICE support

    Remove support for the optional "mod_service" symbol in modules.
    Support for this symbol is no longer needed after introduction of
    the service.add/service.remove RPCs.
    grondo committed Oct 30, 2018
    Configuration menu
    Copy the full SHA
    a5b942a View commit details
    Browse the repository at this point in the history
  7. connector-local: move response code out of internal_request

    Abstract the client response code out of internal_request() and
    create a reusable client_repond() function.
    
    This not only makes a new reusable function, but breaks up the
    internal_request() function, which was getting a bit long (and
    will get longer soon.)
    grondo committed Oct 30, 2018
    Configuration menu
    Copy the full SHA
    b0407de View commit details
    Browse the repository at this point in the history
  8. connector-local: allow clients to send responses

    Problem: API connected clients cannot send messages of type
    FLUX_MSGTYPE_RESPONSE. In order to allow these clients to register
    services, we must allow responses to flow through the connector
    to the broker.
    grondo committed Oct 30, 2018
    Configuration menu
    Copy the full SHA
    a63ef42 View commit details
    Browse the repository at this point in the history
  9. connector-local: enable service registration

    This commit enables service registration from connector-local connected
    clients via the `service.add` RPC.
    
    Since the broker isn't currently capable of multi-hop routing of
    request messages, this feature is implemented by adding a service
    lookup hash to the connector-local module, which can then register with
    the broker on behalf of clients, and take care of routing requests to
    the client which has requested registration for the service matching
    those requests.
    
    The connector-local module will intercept both service.add and
    service.remove messages, and handle them appropriately. It will
    additionally automatically deregister all services currently owned
    by a client on disconnect.
    
    Fixes flux-framework#1689.
    grondo committed Oct 30, 2018
    Configuration menu
    Copy the full SHA
    78b9044 View commit details
    Browse the repository at this point in the history
  10. connector-local: enable routes on all api requests

    Problem: The connector-local module throws an error and drops any
    request messages from connected clients which do not have the
    FLUX_MSGFLAG_ROUTE flag. Currently the python flux_send() binding
    does not set this flag for requests, so python scripts are unable
    to use this interface.
    
    It is arguable that the local connector *should* drop requests
    without FLUX_MSG_ROUTE set, because this means that the msg being
    sent via the connector is not a valid request. However, since we
    know all requests will need FLUX_MSGFLAG_ROUTE set, and the connector
    is accepting messages on behalf of clients, is there a harm in
    ensuring the route flag is set on all requests? This reduces the
    burden of "encoding" requests from the API clients to the API
    itself, which may or may not be the correct approach.
    
    Until the python bindings can encode a request, though, add code
    to the connector-local module to enable routes on all request
    messages.
    grondo committed Oct 30, 2018
    Configuration menu
    Copy the full SHA
    3fb7191 View commit details
    Browse the repository at this point in the history
  11. bindings/python: fix bad import for MessageWatchers

    In bindings/pythoon/flux/core/handle.py MessageWatcher was imported
    from flux.core.watchers when the implementation is actually in
    flux.message. Fix the bad path.
    grondo committed Oct 30, 2018
    Configuration menu
    Copy the full SHA
    3b190cc View commit details
    Browse the repository at this point in the history
  12. bindings/python: fix Message payload setter

    Message payload setter should use the set_string method not set_json.
    grondo committed Oct 30, 2018
    Configuration menu
    Copy the full SHA
    7328b13 View commit details
    Browse the repository at this point in the history
  13. bindings/python: ensure destruct is set on Message

    Ensure self.destruct member of Message objects is set properly
    to avoid double-free of flux_msg_t in situations where python
    doesn't have ownership of the msg object.
    
    Fixes flux-framework#1777
    grondo committed Oct 30, 2018
    Configuration menu
    Copy the full SHA
    12345d3 View commit details
    Browse the repository at this point in the history
  14. bindings/python: fix MessageWatcher destructor

    The MessageWatcher destroy() method was calling the incorrect
    C function. Update the name to `flux_msg_handler_destroy` to
    avoid errors when calling watcher.destroy().
    grondo committed Oct 30, 2018
    Configuration menu
    Copy the full SHA
    606f279 View commit details
    Browse the repository at this point in the history
  15. modules/pymod: register service name dynamically

    Add code to pymod to register a service name dynamically based on the
    name of the script being loaded. This allows a python-based module
    to register any service name, not just `pymod` and handle request
    messages for that service.
    
    For example, an echo server may be loaded with
    
      flux module load pymod echo
    
    and process messages matching topic string "echo.*".
    
    Code to *deregister* the automatic `pymod` service name is also
    included in this commit but commented out, because, though now
    theoretically possible, it is not currently safe to load a second
    pymod module with a different python script (and there is no way to
    unload just one of two modules with the same name)
    grondo committed Oct 30, 2018
    Configuration menu
    Copy the full SHA
    1c8ce2e View commit details
    Browse the repository at this point in the history
  16. modules/pymod: update echo.py example

    Update the echo.py example pymod script given the updated pymod
    module's capability to register a service name based on the
    loaded script.
    
    This version starts a simple echo service that accepts echo.* messages
    and replies with the same payload.
    grondo committed Oct 30, 2018
    Configuration menu
    Copy the full SHA
    8484841 View commit details
    Browse the repository at this point in the history
  17. configure.ac: add libpython name to AC_SUBST

    Export the name of the discovered libpython DSO name to config.h
    so that code that may need to know which libpython Flux was built
    against doesn't have to rediscover the name.
    grondo committed Oct 30, 2018
    Configuration menu
    Copy the full SHA
    298f4ff View commit details
    Browse the repository at this point in the history
  18. modules/pymod: ensure libpython syms are global

    Problem: On some distributions (e.g. Ubuntu 18.04) _cffi_backend.so
    is not linked against libpython DSO, and since pymod.so is loaded
    with RTLD_LOCAL, symbols from libpython may not be visble to cffi,
    and thus `import cffi` fails with unresolved symbol errors. (This
    may be a general problem with any python module that is not
    linked with libpython in this scenario)
    
    To fix, promote libpython symbols to global by calling dlopen(3)
    on libpython (as found by configure) with RTLD_GLOBAL.
    grondo committed Oct 30, 2018
    Configuration menu
    Copy the full SHA
    9da4016 View commit details
    Browse the repository at this point in the history
  19. testsuite: avoid relative paths in PYTHONPATH

    Problem: python or one of its modules seems to clear relative
    paths from PYTHONPATH, and this is preventing the t9001-pymod.t
    test from working problem with a failure to import the 'flux' module.
    
    The problem seems to be resolved using absolute paths to top_srcdir
    and top_builddir, so just use this as the solution for now.
    grondo committed Oct 30, 2018
    Configuration menu
    Copy the full SHA
    1260784 View commit details
    Browse the repository at this point in the history
  20. testsuite: add sanity test for pymod

    Ensure pymod module can be loaded with the echo.py example,
    and that the example echo server can handle requests.
    grondo committed Oct 30, 2018
    Configuration menu
    Copy the full SHA
    27e3499 View commit details
    Browse the repository at this point in the history
  21. testsuite: add a python test for service.add/remove

    Add python/t1000-service-add-remove.py to the testsuite to test
    the connector-local usage of `service.add` and `service.remove`.
    grondo committed Oct 30, 2018
    Configuration menu
    Copy the full SHA
    39c7f51 View commit details
    Browse the repository at this point in the history