Skip to content

admin: add API for creating chunked handlers#19831

Merged
jmarantz merged 9 commits intoenvoyproxy:mainfrom
jmarantz:admin-chunked-infra
Feb 11, 2022
Merged

admin: add API for creating chunked handlers#19831
jmarantz merged 9 commits intoenvoyproxy:mainfrom
jmarantz:admin-chunked-infra

Conversation

@jmarantz
Copy link
Copy Markdown
Contributor

@jmarantz jmarantz commented Feb 5, 2022

Commit Message: The admin handler structure uses a single callback that is expected to fill in the entire response body, making it impossible to stream data out as it is generated. This PR refactors the internal admin structures to require a Handler object with a nextChunk method, to enable chunking. It defers to other PRs to

  • actually convert any handlers to use chunking (e.g. admin: Streaming /stats implementation #19693)
  • implement proper flow control in the AdminFilter to avoid generating chunks before clients are ready to receive them (WiP admin: add flow control to admin filter #19898)
    Additional Description:
    Risk Level: medium -- this is a pure refactor but not a trivial one. The same exact admin content should be generated before/after this change
    Testing: //test/...
    Docs Changes: n/a
    Release Notes: n/a
    Platform Specific Features: n/a

Signed-off-by: Joshua Marantz <jmarantz@google.com>
@repokitteh-read-only
Copy link
Copy Markdown

As a reminder, PRs marked as draft will not be automatically assigned reviewers,
or be handled by maintainer-oncall triage.

Please mark your PR as ready when you want it to be reviewed!

🐱

Caused by: #19831 was opened by jmarantz.

see: more, trace.

Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
MAKE_ADMIN_HANDLER(runtime_handler_.handlerRuntimeModify), false, true},
{"/reopen_logs", "reopen access logs",
MAKE_ADMIN_HANDLER(logs_handler_.handlerReopenLogs), false, true},
makeHandler("/", "Admin home page", MAKE_ADMIN_HANDLER(handlerAdminHome), false, false),
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note this block of code is mechanistically transformed from its previous state, as we needed to add Handler wrappers to all the legacy callback-based handlers.

In a future PR, /stats and likely also /cluster_info will be converted to Chunked handlers.

…not have flow-control.

Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
@jmarantz jmarantz marked this pull request as ready for review February 11, 2022 00:37
@jmarantz
Copy link
Copy Markdown
Contributor Author

@krajshiva FYI

Copy link
Copy Markdown
Member

@zuercher zuercher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Couple small comments, but they could be addressed in one of your follow-up PRs, if you'd like.

Http::ResponseHeaderMap& response_headers,
Buffer::Instance& response, AdminStream& admin_stream) {
HandlerPtr handler = findHandler(path_and_query, admin_stream);
Http::Code code = handler->start(/*path_and_query, */ response_headers);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the path_and_query comment?

RELEASE_ASSERT(request_headers_, "");
Http::Code code = admin_server_callback_func_(path, *header_map, response, *this);
Admin::HandlerPtr handler = admin_handler_fn_(path, *this);
Http::Code code = handler->start(/*path, */ *header_map);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove path comment?

* Adds the next chunk of data to the response. Note that nextChunk can
* return 'true' but not add any data to the response, in which case a chunk
* is not sent, and a subsequent call to nextChunk can be made later,
* possibly after a post() or low-watermark callback on the http filter.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I gather this is only true once #19898 lands and until then we spin calling nextChunk. I think it's ok to leave as long as you expect that PR to land soon-ish.

@jmarantz
Copy link
Copy Markdown
Contributor Author

Thanks -- that's right on all counts and I'll clean up the comments in the next PR.

I think the next PR is working but I can't prove it yet; I think I need a test using HttpAsyncHandler or something.

@jmarantz jmarantz merged commit 027d6ca into envoyproxy:main Feb 11, 2022
@jmarantz jmarantz deleted the admin-chunked-infra branch February 11, 2022 18:32
joshperry pushed a commit to joshperry/envoy that referenced this pull request Feb 13, 2022
Commit Message: The admin handler structure uses a single callback that is expected to fill in the entire response body, making it impossible to stream data out as it is generated. This PR refactors the internal admin structures to require a Handler object with a nextChunk method, to enable chunking. It defers to other PRs to
 * actually convert any handlers to use chunking (e.g. WiP stats: Reimplement existing /stats API in a way that can be chunked. envoyproxy#19693)
 * implement proper flow control in the AdminFilter to avoid generating chunks before clients are ready to receive them (WiP admin: add flow control to admin filter envoyproxy#19898)

Additional Description:
Risk Level: medium -- this is a pure refactor but not a trivial one. The same exact admin content should be generated before/after this change
Testing: //test/...
Docs Changes: n/a
Release Notes: n/a
Platform Specific Features: n/a

Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Josh Perry <josh.perry@mx.com>
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.

2 participants