-
Notifications
You must be signed in to change notification settings - Fork 849
JSONRPC based interface for administrative API #7478
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
Conversation
d5a7f08 to
9d4b215
Compare
doc/admin-guide/jsonrpc/index.en.rst
Outdated
|
|
||
| .. note:: | ||
|
|
||
| As today, there is only 1 communication mechanism supported. IPC Sockets. |
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.
"As of today"
doc/admin-guide/jsonrpc/index.en.rst
Outdated
| Administrative API | ||
| ------------------ | ||
|
|
||
| This section describe how to interact with the administrative RPC API to interact with |TS| |
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.
"describes"
jrushford
left a comment
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.
Mostly just minor issues in the docs and some includes in the source. Testing looks good so far.
doc/admin-guide/jsonrpc/index.en.rst
Outdated
|
|
||
|
|
||
|
|
||
| We get a valid record that was found base on the passed criteria, ``proxy.config.exec_thread.autoconfig.sca*`` and the ``rec_type`` *1*. |
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.
maybe "was found based on"?
|
|
||
| .. option:: input | ||
|
|
||
| Input mode, traffic_ctl will provide a control input from a stream buffer. Once the content was write the terminal :program:`traffic_ctl` |
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.
Maybe use "content is written"?
|
|
||
| Input mode, traffic_ctl will provide a control input from a stream buffer. Once the content was write the terminal :program:`traffic_ctl` | ||
| will wait for the user to press Control-D to send the request to the rpc endpoint. | ||
| This feature allow you to directly interact with the jsonrpc endpoint and test your API easily and without the need to know the low level |
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.
"allows"
| Using the JSONRPC mechanism | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
|
||
| As a user, currently, :program:`traffic_ctl` exercise this new protocol, please refer to the :ref:`traffic_ctl_jsonrpc` section. |
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.
"exercises"
|
|
||
| .. note:: | ||
|
|
||
| Although most of the protocol specs are granted, we do have implemented some exceptions. All the modifications we have implemented will |
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.
Change "we do have" to "we have"
| ****************************** | ||
|
|
||
| Use this section as a guide for developing new rpc methods inside |TS| and how to expose them through the |RPC| endpoint. | ||
| Before we start is worth mentioning some of the architecture of the current implementation. The whole RPC mechanism is divided in |
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 "start is worth" be "start, it is worth"?
| ^^^^^^^^^^^^^^ | ||
|
|
||
|
|
||
| There are several ways to deal with internal handler errors. Errors are expected to be send back to the client if the API was expressed that way |
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.
"send back" perhaps should be "sent back"
|
|
||
|
|
||
| The way you print and the destination of the message is up to the developer's needs, either a terminal or some other place. If the response | ||
| from the server is a complex object, always can model the response with your own class or structure and use the built-in yamlcpp mechanism |
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.
maybe change to "you can always model the response"
mgmt2/config/AddConfigFilesHere.cc
Outdated
|
|
||
| #include "tscore/ink_platform.h" | ||
| #include "tscore/Filenames.h" | ||
| //#include "MgmtUtils.h" |
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.
remove the include if not needed.
mgmt2/config/AddConfigFilesHere.cc
Outdated
| #include "tscore/Errata.h" | ||
| // #include <string_view> | ||
|
|
||
| // extern FileManager *configFiles; |
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.
Remove this and the #include <string_view> if not needed.
|
[approve ci clang-analyzer] |
|
@brbzull0 the clang analyzer fails building with the same error I got with devtoolset-9. Not sure why it still fails since you committed a fix for that. |
Yes, I'm working on this, thanks. Clang-analyzer seems not happy when |
| { | ||
| std::string text; | ||
| auto my_print = [&text](auto const &disk) { | ||
| std::cout << ts::bwprint(text, "Device: {}\n", disk.path); |
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.
Why not just:
std::cout << "Device: " << disk.path << '\n';
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, for the sake of consistency I did that everywhere(in traffic_ctl), probably for legacy and simple output like this one I can just switch to the classic.
| std::string | ||
| get_method() const | ||
| { | ||
| return "admin_clear_metrics_records"; |
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.
Got this already, shouldn't be admin_clear_metrics_records. Will fix.
|
[approve ci clang-analyzer] |
doc/admin-guide/jsonrpc/index.en.rst
Outdated
| |TS| will start the |RPC| server without any need for configuration. | ||
|
|
||
|
|
||
| In case a special configuration is needed, the following describes the structure. |
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.
Might be clearer to say non-default rather than special.
doc/admin-guide/jsonrpc/index.en.rst
Outdated
|
|
||
| .. note:: | ||
|
|
||
| Traffic Control does support this RPC mechanism for communication with |TS| . Please check :program:`traffic_ctl` documentation for |
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.
Do you mean to say "does not support" or "supports"?
| .. include:: ../../common.defs | ||
|
|
||
| .. highlight:: cpp | ||
| .. default-domain:: cpp |
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.
github at least does not seem to understand default-domain , https://github.com/brbzull0/trafficserver/blob/jsonrpc20/wip/doc/admin-guide/jsonrpc/index.en.rst .
| *********** | ||
|
|
||
|
|
||
|
|
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.
Do multiple blank lines mean something in ReStructured Text? Or are you just missing the wide open spaces of The Pampas?
|
|
||
| Mark down a host with `traffic_ctl` and view the associated host stats:: | ||
|
|
||
| .. code-block:: bash |
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.
Why bash?
| .. |optional| replace:: ``optional`` | ||
|
|
||
| .. |arrayrecord| replace:: ``array[record]`` | ||
| .. |arrayerror| replace:: ``array[errors]`` |
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 these be in .defs include file.
…. This commit includes changes in the jsonrpc manager to allow different kind of handlers being implemented and registered, including handlers from plugins(API not included here). The core part of the manager was changed to use a single table for all the handler(previously one per handler type, method and notifications). Also includes a set of tools to allow writing unit tests around the jsonrpc API.
…ail and print to stderr in case of an error. (apache#560)
traffic.out used to be rotated by traffic_manager. Now that we transitioned to JSONRPC, traffic_manager no longer runs. This transitions log rotation handling to traffic_server if JSONRPC is running.
…a shared foler (apache#577) * [JSONRPC] - Move JSONRPC request/response definitions to a shared folder. - Split base request/response object into base objects and specific ones for traffic_ctl. - Add documentation. - Clean up some code in the RPC client code. * [JSONRPC] - rpc shared client, add invoke function that takes a JSONRPC object. * [JSONRPC] - fix typo * [JSONRPC] - rename namespace. Add default template type. * Fix typo in yaml_codecs.h Co-authored-by: Damian Meden <damian.meden@gmail.com>
…t clients be aware of the update logic. This also includes some tidy up on naming as well as making 'traffic_ctl config get' to display errors if they are back from the server. (apache#580)
…quest api. This change involves removing a hand call to traffic_ctl and using Request.admin_config_reload() instead. Also adjust the scripts to take the runroot file so it can be passed to traffic_ctl when executed.
The idea with this change is to expose the content of the bindings inside the FileManager singleton class. This commit also adds support to query this endpoint using traffic_ctl. Docs are also updated
This was making the build fail on FreeBSD.
…o carry the plugin responses to jsonrpc messages. (apache#614) This needs to be clear up after use otherwise the state may hold the old one which can end up giving the wrong response to rpc requests.
e260f45 to
b96e697
Compare
jrushford
left a comment
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.
Ran regression tests, unit tests and tested traffic_ctl commands. Looks good to me.
|
[approve ci autest] |
|
There seems to be a transient issue when running this test on CI. |
Hello community, we have been talking about this for quite a while, so it's now an official PR.
Before gettint into any details just so you now We(yahoo) have this implementation currently running in production, it's been running for while now and so far no issues. So:
This PR contains several main things
traffic_ctltool that uses jsonrpc as protocol behind the scenes, docs hereSome other important documentation:
Basic Architecture notes(RPC, JSON Parsing, Protocol, Errors, etc) can be found here
Dev notes on how to implementing a new API handler, docs here
Dev notes on how to implementing new
traffic_ctlcommands. This still keeps the old input arguments and output, docs here. Can’t remember all the input args? No worries, you can use this which will give you bash completion for it.A new configuration file is introduced:
jsonrpc.yamlYou can get the details here
Records API
Raw interaction with the RPC server using
traffic_ctl(no specific api), hereAll the documentation is online here I will keep this up to date with any changes.
Now, this draft contains several commits, but some of the newest commits contain significant changes that can invalidate the early ones, so I do not recommend reviewing commit by commit. Just look at it as a whole. We have been iteraing on this internally so (if any)I will keep pushing changes from our repo to this PR.
Few other things to consider:
traffic_managerin this branch. If cloning this branch to play with, just start TS and usetraffic_ctlas usual. 🤞 . Removing the traffic_manager code will be tackle in a different effort.mgmt2which is where I’m putting all the code that is relevant to this new rpc system, also to start clean and avoid issues in the future when removingtraffic_manager. I will be slowly moving what can/should be kept inside this new folder. At some point will revert the name tomgmtor something more relevant.FileManager.cc/hwhich was copy/paste fromtraffic_managersources with some modifications in order to be reused. For instanceFileManagernow combinesFileManagerandConfigManagertogether.yamlcpp) has some limitations when dealing with straightjson.Some known issues that I will be fixing.
Breaking changes
traffic_manageranymore, so if you have scripts that runstraffic_managerthey need to be updated.traffic_ctlhave minimal dependencies with ATS which make traffic_ctl not able to find the socket unless you specify it by either using runroot (--run-root) or using the default build location. It is recommended to useTS_RUNROOTenv variable which make all the binaries use the same layout.traffic_ctl server(restart, start, backtrace, etc) commands do not work because there is notraffic_managerrunning anymore. This may need to involve some scripting that can be executed in a different way or work with the OS system managers, likesystemctl, etc, depending on the OS.Review notes
I know this is a big PR, but a lot of the new code is documentation. I will highlight few things to help understanding the structure of this PR. So basically the entire JSORPC server and admin handler logic is inside the mgmt2/rpc folder where you will find the implementation for:
traffic_ctl.Do not review individual commits, as the idea is to squash them, some newer commits invalidate previous ones.
[Update Oct 7 2021]
traffic_topnow works with the jsonrpc node directly.traffic_crashlogremoves thetraffic_managerconnectivity to work, things like server stack-race will not be included in the report. This may be added latter.[Update Nov 11 2021]
TODOs:
autestand eithertraffic_ctlor a new extension that connects directly to the rpc.Performance test, Improve some code. OngoingYou can find the original Issue created to tackle this effort #6633
Please feel free to clone it and try it out, any feedback would be appreciated.
Warning - I will be rebasing on top of master regularly, which means that I will need to perform a
--forcepush, consider this when cloningThanks,
Damian
This closes #5563