[CLIPPER-57] Read existing configuration from Redis on startup#123
[CLIPPER-57] Read existing configuration from Redis on startup#123dcrankshaw merged 7 commits intoucbrise:developfrom
Conversation
* Create two functions get_all_model_names() and get_all_application_names() which call the KEYS command with a wildcard (*) argument on the model and application table * Update query frontend to (1) add existing applications and (2) fill internal state with current model name and versions on startup
|
Can one of the admins verify this patch? |
|
jenkins test this please |
|
Test FAILed. |
dcrankshaw
left a comment
There was a problem hiding this comment.
This looks good. I tested it locally and it seems to work. We should add unit tests for this though.
Add some tests to the query_frontend that first populate the application/model tables using Redis then create a new query frontend RequestHandler object and make sure it reads Redis correctly and adds the right models/versions and applications.
Note that when adding models you'll need explicitly set the current model version as well because the management frontend does that (https://github.com/ucbrise/clipper/blob/develop/src/management/src/management_frontend.hpp#L282-L314).
Make sure to have separate tests for models and applications.
src/frontends/src/query_frontend.hpp
Outdated
| // (1) Iterate through applications and set up predict/update endpoints. | ||
| for (std::string app_name : | ||
| clipper::redis::get_all_application_names(redis_connection_)) { | ||
| // Is there a way/need to not repeat these function calls? (from above) |
There was a problem hiding this comment.
Repeating them is fine. There's not much duplicate code.
| std::vector<std::string> candidate_model_names = | ||
| clipper::redis::str_to_model_names(app_info["candidate_model_names"]); | ||
| InputType input_type = clipper::parse_input_type(app_info["input_type"]); | ||
| std::string policy = app_info["policy"]; |
There was a problem hiding this comment.
This PR is based on an old commit. Update to the latest version. You'll notice that applications no longer have a policy field and now have a default_output field that needs to be set.
There was a problem hiding this comment.
Updated to include default_output.
src/frontends/src/query_frontend.hpp
Outdated
| clipper::redis::get_all_model_names(redis_connection_)) { | ||
| auto model_version = clipper::redis::get_current_model_version( | ||
| redis_connection_, model_name); | ||
| // Error handle model_version being < 0? |
There was a problem hiding this comment.
Yeah you should check for it. If it is < 0, log an error then throw a runtime exception.
There was a problem hiding this comment.
Checked in new implementation with corresponding test.
src/frontends/src/query_frontend.hpp
Outdated
| // Read from Redis configuration tables and update models/applications | ||
| // (1) Iterate through applications and set up predict/update endpoints. | ||
| for (std::string app_name : | ||
| clipper::redis::get_all_application_names(redis_connection_)) { |
There was a problem hiding this comment.
Can you save the vector of existing app names and log them in a useful message. Something like "Found 3 existing applications registered in Clipper: app_name_1, app_name_2, app_name_3."
| // Error handle model_version being < 0? | ||
| std::unique_lock<std::mutex> l(current_model_versions_mutex_); | ||
| current_model_versions_[model_name] = model_version; | ||
| } |
There was a problem hiding this comment.
After you've initialized the current_model_versions_ map in this for loop, can you log the results similar to the existing applications log message: "Found 3 models deployed to Clipper: model_a@v4, model_b@v7, model_c@v1"
|
jenkins test this please |
|
Test FAILed. |
|
jenkins test this please |
|
Test PASSed. |
Currently Clipper uses SimpleWebServer([Oct 25, 2016](https://github.com/eidheim/Simple-Web-Server/tree/8e0d3142bfd3c4932d9c7a9b9fcd517b7a4ec05b)) for http serving. We need to upgrade this module to resolve some bugs and support keep-alive connection. So we applied all patches except of below to reach [version 2.1.1 (May 27, 2017)](https://github.com/eidheim/Simple-Web-Server/blob/v2.1.1/server_http.hpp). Diff between SimpleWebServer v2.1.1(left). and SimpleWebServer(right) in this PR is [here](https://www.diffchecker.com/PI1eJFwo). * applied patch list * Nov 7, 2016: [Fixes ucbrise#82: wrong reset method called in ::start](eidheim/Simple-Web-Server@8da3ad4) * Nov 10, 2016: [Fixed crash if server instance gets deleted after the call to io_serv](eidheim/Simple-Web-Server@743785b) * Nov 23, 2016: [Fixes ucbrise#86: can now set timeout on client requests](eidheim/Simple-Web-Server@8a73cb3) * Nov 23, 2016: [Minor timeout source cleanups](eidheim/Simple-Web-Server@7d95360) * Nov 23: 2016: [Simplified Server::parse_request](eidheim/Simple-Web-Server@0d8052d) * Dec 4, 2016: [string::substr comparisons replaced by string::compare](eidheim/Simple-Web-Server@14d848b) * Dec 13, 2016: [compile clean with gcc 4.6.3](eidheim/Simple-Web-Server@dc74f77) * Dec 19, 2016: [Added client verification when a verify file is passed to Server<HTTP](eidheim/Simple-Web-Server@7a97f82) * Dec 19, 2016: [Added error reporting through on_error std::function](eidheim/Simple-Web-Server@eef8a10) * Dec 19, 2016: [Minor cleanup](eidheim/Simple-Web-Server@d19244e) * Dec 19, 2016: [Minor cleanup](eidheim/Simple-Web-Server@db95a64) * Dec 29, 2016: [Cleanup of server-constructors. Previous constructors have been marked](eidheim/Simple-Web-Server@6c3a59d) * Dec 29, 2016: [Bugfix for last commit: config.timeout_content now correctly set in old constructor](eidheim/Simple-Web-Server@175d4dd#diff-be05a8666afdaf0bcadd9499d09cf33c) * Dec 30, 2016: [Fixed DEPRECATED macro in cases where it is already defined](eidheim/Simple-Web-Server@8c8ef39#diff-be05a8666afdaf0bcadd9499d09cf33c) * Dec 31, 2016: [Case insensitive header cleanup. Also cleanup and additions to parse_test](eidheim/Simple-Web-Server@549bc64#diff-be05a8666afdaf0bcadd9499d09cf33c) * Jan 1, 2017: [Added on_upgrade for cases where one wants to handle connection upgrades](eidheim/Simple-Web-Server@bfcb325#diff-be05a8666afdaf0bcadd9499d09cf33c) * Jan 11, 2017: [Fixed Boost.Regex workaround in regex_orderable. Fixes ucbrise#100](eidheim/Simple-Web-Server@19627bb#diff-be05a8666afdaf0bcadd9499d09cf33c) * Jan 24, 2017: [Possible implementation for fixing ucbrise#106](eidheim/Simple-Web-Server@600fbe3#diff-be05a8666afdaf0bcadd9499d09cf33c) * Jan 24, 2017: [Renamed close_connection_after_send to close_connection_after_response](eidheim/Simple-Web-Server@de560e8#diff-be05a8666afdaf0bcadd9499d09cf33c) * Feb 5, 2017: [Added query string parsing and member to request](eidheim/Simple-Web-Server@a4dd2e6#diff-be05a8666afdaf0bcadd9499d09cf33c) * Feb 5, 2017: [Travis CI build failed](eidheim/Simple-Web-Server@d554c13#diff-be05a8666afdaf0bcadd9499d09cf33c) * Feb 14, 2017: [remove locale dependent stof()](eidheim/Simple-Web-Server@50ce751#diff-be05a8666afdaf0bcadd9499d09cf33c) * Feb 27, 2017: [If query string is present then cut it from the reqeust path so find](eidheim/Simple-Web-Server@e585a7a#diff-be05a8666afdaf0bcadd9499d09cf33c) * May 6, 2017: [Added support for request header Connection: keep-alive (see ucbrise#123)](eidheim/Simple-Web-Server@cfafbcb#diff-be05a8666afdaf0bcadd9499d09cf33c) * May 27, 2017: [Finished query string parsing implementation (PR ucbrise#109)](eidheim/Simple-Web-Server@550bbfe#diff-be05a8666afdaf0bcadd9499d09cf33c) * May 27, 2017: [Fixed g++ error in Server::Request::parse_query_string](eidheim/Simple-Web-Server@4469de1#diff-be05a8666afdaf0bcadd9499d09cf33c) * excluded patch list * Jan 2, 2017: [Code simplification: got rid of opt_resource at minimal cost](eidheim/Simple-Web-Server@8cdebfb) * Jan 2, 2017: [Added warning to Server::resource](eidheim/Simple-Web-Server@fa8c381) * Jan 3, 2017: [Removed unnecessary public](eidheim/Simple-Web-Server@f5e65bf)
Currently Clipper uses SimpleWebServer([Oct 25, 2016](https://github.com/eidheim/Simple-Web-Server/tree/8e0d3142bfd3c4932d9c7a9b9fcd517b7a4ec05b)) for http serving. We need to upgrade this module to resolve some bugs and support keep-alive connection. So we applied all patches except of some to reach [version 2.1.1 (May 27, 2017)](https://github.com/eidheim/Simple-Web-Server/blob/v2.1.1/server_http.hpp). Diff between SimpleWebServer v2.1.1(left). and SimpleWebServer(right) in this PR is [here](https://www.diffchecker.com/PI1eJFwo). * applied patch list * Nov 7, 2016: [Fixes ucbrise#82: wrong reset method called in ::start](eidheim/Simple-Web-Server@8da3ad4) * Nov 10, 2016: [Fixed crash if server instance gets deleted after the call to io_serv](eidheim/Simple-Web-Server@743785b) * Nov 23, 2016: [Fixes ucbrise#86: can now set timeout on client requests](eidheim/Simple-Web-Server@8a73cb3) * Nov 23, 2016: [Minor timeout source cleanups](eidheim/Simple-Web-Server@7d95360) * Nov 23: 2016: [Simplified Server::parse_request](eidheim/Simple-Web-Server@0d8052d) * Dec 4, 2016: [string::substr comparisons replaced by string::compare](eidheim/Simple-Web-Server@14d848b) * Dec 13, 2016: [compile clean with gcc 4.6.3](eidheim/Simple-Web-Server@dc74f77) * Dec 19, 2016: [Added client verification when a verify file is passed to Server<HTTP](eidheim/Simple-Web-Server@7a97f82) * Dec 19, 2016: [Added error reporting through on_error std::function](eidheim/Simple-Web-Server@eef8a10) * Dec 19, 2016: [Minor cleanup](eidheim/Simple-Web-Server@d19244e) * Dec 19, 2016: [Minor cleanup](eidheim/Simple-Web-Server@db95a64) * Dec 29, 2016: [Cleanup of server-constructors. Previous constructors have been marked](eidheim/Simple-Web-Server@6c3a59d) * Dec 29, 2016: [Bugfix for last commit: config.timeout_content now correctly set in old constructor](eidheim/Simple-Web-Server@175d4dd#diff-be05a8666afdaf0bcadd9499d09cf33c) * Dec 30, 2016: [Fixed DEPRECATED macro in cases where it is already defined](eidheim/Simple-Web-Server@8c8ef39#diff-be05a8666afdaf0bcadd9499d09cf33c) * Dec 31, 2016: [Case insensitive header cleanup. Also cleanup and additions to parse_test](eidheim/Simple-Web-Server@549bc64#diff-be05a8666afdaf0bcadd9499d09cf33c) * Jan 1, 2017: [Added on_upgrade for cases where one wants to handle connection upgrades](eidheim/Simple-Web-Server@bfcb325#diff-be05a8666afdaf0bcadd9499d09cf33c) * Jan 11, 2017: [Fixed Boost.Regex workaround in regex_orderable. Fixes ucbrise#100](eidheim/Simple-Web-Server@19627bb#diff-be05a8666afdaf0bcadd9499d09cf33c) * Jan 24, 2017: [Possible implementation for fixing ucbrise#106](eidheim/Simple-Web-Server@600fbe3#diff-be05a8666afdaf0bcadd9499d09cf33c) * Jan 24, 2017: [Renamed close_connection_after_send to close_connection_after_response](eidheim/Simple-Web-Server@de560e8#diff-be05a8666afdaf0bcadd9499d09cf33c) * Feb 5, 2017: [Added query string parsing and member to request](eidheim/Simple-Web-Server@a4dd2e6#diff-be05a8666afdaf0bcadd9499d09cf33c) * Feb 5, 2017: [Travis CI build failed](eidheim/Simple-Web-Server@d554c13#diff-be05a8666afdaf0bcadd9499d09cf33c) * Feb 14, 2017: [remove locale dependent stof()](eidheim/Simple-Web-Server@50ce751#diff-be05a8666afdaf0bcadd9499d09cf33c) * Feb 27, 2017: [If query string is present then cut it from the reqeust path so find](eidheim/Simple-Web-Server@e585a7a#diff-be05a8666afdaf0bcadd9499d09cf33c) * May 6, 2017: [Added support for request header Connection: keep-alive (see ucbrise#123)](eidheim/Simple-Web-Server@cfafbcb#diff-be05a8666afdaf0bcadd9499d09cf33c) * May 27, 2017: [Finished query string parsing implementation (PR ucbrise#109)](eidheim/Simple-Web-Server@550bbfe#diff-be05a8666afdaf0bcadd9499d09cf33c) * May 27, 2017: [Fixed g++ error in Server::Request::parse_query_string](eidheim/Simple-Web-Server@4469de1#diff-be05a8666afdaf0bcadd9499d09cf33c) * excluded patch list * Jan 2, 2017: [Code simplification: got rid of opt_resource at minimal cost](eidheim/Simple-Web-Server@8cdebfb) * Jan 2, 2017: [Added warning to Server::resource](eidheim/Simple-Web-Server@fa8c381) * Jan 3, 2017: [Removed unnecessary public](eidheim/Simple-Web-Server@f5e65bf)
* Upgrade SimpleWebServer to version 2.1.1 Currently Clipper uses SimpleWebServer([Oct 25, 2016](https://github.com/eidheim/Simple-Web-Server/tree/8e0d3142bfd3c4932d9c7a9b9fcd517b7a4ec05b)) for http serving. We need to upgrade this module to resolve some bugs and support keep-alive connection. So we applied all patches except of some to reach [version 2.1.1 (May 27, 2017)](https://github.com/eidheim/Simple-Web-Server/blob/v2.1.1/server_http.hpp). Diff between SimpleWebServer v2.1.1(left). and SimpleWebServer(right) in this PR is [here](https://www.diffchecker.com/PI1eJFwo). * applied patch list * Nov 7, 2016: [Fixes #82: wrong reset method called in ::start](eidheim/Simple-Web-Server@8da3ad4) * Nov 10, 2016: [Fixed crash if server instance gets deleted after the call to io_serv](eidheim/Simple-Web-Server@743785b) * Nov 23, 2016: [Fixes #86: can now set timeout on client requests](eidheim/Simple-Web-Server@8a73cb3) * Nov 23, 2016: [Minor timeout source cleanups](eidheim/Simple-Web-Server@7d95360) * Nov 23: 2016: [Simplified Server::parse_request](eidheim/Simple-Web-Server@0d8052d) * Dec 4, 2016: [string::substr comparisons replaced by string::compare](eidheim/Simple-Web-Server@14d848b) * Dec 13, 2016: [compile clean with gcc 4.6.3](eidheim/Simple-Web-Server@dc74f77) * Dec 19, 2016: [Added client verification when a verify file is passed to Server<HTTP](eidheim/Simple-Web-Server@7a97f82) * Dec 19, 2016: [Added error reporting through on_error std::function](eidheim/Simple-Web-Server@eef8a10) * Dec 19, 2016: [Minor cleanup](eidheim/Simple-Web-Server@d19244e) * Dec 19, 2016: [Minor cleanup](eidheim/Simple-Web-Server@db95a64) * Dec 29, 2016: [Cleanup of server-constructors. Previous constructors have been marked](eidheim/Simple-Web-Server@6c3a59d) * Dec 29, 2016: [Bugfix for last commit: config.timeout_content now correctly set in old constructor](eidheim/Simple-Web-Server@175d4dd#diff-be05a8666afdaf0bcadd9499d09cf33c) * Dec 30, 2016: [Fixed DEPRECATED macro in cases where it is already defined](eidheim/Simple-Web-Server@8c8ef39#diff-be05a8666afdaf0bcadd9499d09cf33c) * Dec 31, 2016: [Case insensitive header cleanup. Also cleanup and additions to parse_test](eidheim/Simple-Web-Server@549bc64#diff-be05a8666afdaf0bcadd9499d09cf33c) * Jan 1, 2017: [Added on_upgrade for cases where one wants to handle connection upgrades](eidheim/Simple-Web-Server@bfcb325#diff-be05a8666afdaf0bcadd9499d09cf33c) * Jan 11, 2017: [Fixed Boost.Regex workaround in regex_orderable. Fixes #100](eidheim/Simple-Web-Server@19627bb#diff-be05a8666afdaf0bcadd9499d09cf33c) * Jan 24, 2017: [Possible implementation for fixing #106](eidheim/Simple-Web-Server@600fbe3#diff-be05a8666afdaf0bcadd9499d09cf33c) * Jan 24, 2017: [Renamed close_connection_after_send to close_connection_after_response](eidheim/Simple-Web-Server@de560e8#diff-be05a8666afdaf0bcadd9499d09cf33c) * Feb 5, 2017: [Added query string parsing and member to request](eidheim/Simple-Web-Server@a4dd2e6#diff-be05a8666afdaf0bcadd9499d09cf33c) * Feb 5, 2017: [Travis CI build failed](eidheim/Simple-Web-Server@d554c13#diff-be05a8666afdaf0bcadd9499d09cf33c) * Feb 14, 2017: [remove locale dependent stof()](eidheim/Simple-Web-Server@50ce751#diff-be05a8666afdaf0bcadd9499d09cf33c) * Feb 27, 2017: [If query string is present then cut it from the reqeust path so find](eidheim/Simple-Web-Server@e585a7a#diff-be05a8666afdaf0bcadd9499d09cf33c) * May 6, 2017: [Added support for request header Connection: keep-alive (see #123)](eidheim/Simple-Web-Server@cfafbcb#diff-be05a8666afdaf0bcadd9499d09cf33c) * May 27, 2017: [Finished query string parsing implementation (PR #109)](eidheim/Simple-Web-Server@550bbfe#diff-be05a8666afdaf0bcadd9499d09cf33c) * May 27, 2017: [Fixed g++ error in Server::Request::parse_query_string](eidheim/Simple-Web-Server@4469de1#diff-be05a8666afdaf0bcadd9499d09cf33c) * excluded patch list * Jan 2, 2017: [Code simplification: got rid of opt_resource at minimal cost](eidheim/Simple-Web-Server@8cdebfb) * Jan 2, 2017: [Added warning to Server::resource](eidheim/Simple-Web-Server@fa8c381) * Jan 3, 2017: [Removed unnecessary public](eidheim/Simple-Web-Server@f5e65bf) * Run format_code.sh * format code * Run run_unittests.sh
get_all_application_names() which call the KEYS command with a
wildcard (*) argument on the model and application table
(2) fill internal state with current model name and versions
on startup