Skip to content

set of fixes/improvements for http proxy #17998

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

Merged
merged 1 commit into from
May 6, 2025

Conversation

adameat
Copy link
Member

@adameat adameat commented May 5, 2025

Changelog entry

...

Changelog category

  • Not for changelog (changelog entry is not required)

Description for reviewers

fixes hanging stored connection after timeout expires.
fixes builtin headers
simplifies request syntax
extends static handler

@adameat adameat requested review from alexvru and Copilot May 5, 2025 09:09
@adameat adameat self-assigned this May 5, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces various improvements and fixes for the HTTP proxy module, addressing issues such as hanging stored connections after timeout expiry, built-in header corrections, and simplifying the request syntax while extending static content handling.

  • Added an overload for the HTTP static content handler using a URL adapter (lambda) to process URL paths.
  • Refactored the outgoing connection actor to integrate the TEvHttpOutgoingRequest event and updated error message handling.
  • Modified header handling in HTTP responses to check for preexisting worker names before setting them.

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.

File Description
ydb/library/actors/http/http_static.h & http_static.cpp Introduced a URL adapter-based overload for the static content handler and adjusted MIME type derivation logic.
ydb/library/actors/http/http_proxy_outgoing.cpp Refactored the connection actor's construction, error reporting, and added a new CheckClose loop for connection reuse handling.
ydb/library/actors/http/http_proxy.h & http_proxy.cpp Updated the outgoing connection actor creation signature and modified event forwarding logic.
ydb/library/actors/http/http.h & http.cpp Added an initializer_list constructor to THeadersBuilder and enhanced header checks for the worker name.
Comments suppressed due to low confidence (3)

ydb/library/actors/http/http_proxy_outgoing.cpp:156

  • [nitpick] Returning an empty error message when 'res' equals 0 could obscure the reason for connection closure; consider logging an explicit message to aid debugging.
ReplyErrorAndPassAway(res == 0 ? "" : strerror(-res));

ydb/library/actors/http/http_static.cpp:56

  • Ensure that using GetName() for MIME type determination correctly extracts the file extension; consider adding a comment to clarify if this behavior is a deliberate improvement over GetExtension().
TString contentType = mimetypeByExt(url.GetName().c_str());

ydb/library/actors/http/http_proxy.cpp:113

  • Verify that the new Forward function preserves all necessary event metadata (e.g., TraceId) to maintain proper event tracing and debugging.
Send(Forward(availableConnection, std::move(event)));

@adameat adameat added area/ui UI/Embedded UI related issues and removed not-for-changelog labels May 5, 2025
Copy link

github-actions bot commented May 5, 2025

🟢 2025-05-05 09:10:51 UTC The validation of the Pull Request description is successful.

Copy link

github-actions bot commented May 5, 2025

2025-05-05 09:11:03 UTC Pre-commit check linux-x86_64-release-asan for e013d7d has started.
2025-05-05 09:11:14 UTC Artifacts will be uploaded here
2025-05-05 09:14:10 UTC ya make is running...
🟡 2025-05-05 11:01:25 UTC Some tests failed, follow the links below. This fail is not in blocking policy yet Going to retry failed tests...

Test history | Ya make output | Test bloat

TESTS PASSED ERRORS FAILED SKIPPED MUTED?
14758 14604 0 93 32 29

2025-05-05 11:02:44 UTC ya make is running... (failed tests rerun, try 2)
🟡 2025-05-05 11:31:56 UTC Some tests failed, follow the links below. This fail is not in blocking policy yet Going to retry failed tests...

Test history | Ya make output | Test bloat | Test bloat

TESTS PASSED ERRORS FAILED SKIPPED MUTED?
911 (only retried tests) 814 0 46 24 27

2025-05-05 11:32:10 UTC ya make is running... (failed tests rerun, try 3)
🟡 2025-05-05 11:56:52 UTC Some tests failed, follow the links below. This fail is not in blocking policy yet

Test history | Ya make output | Test bloat | Test bloat | Test bloat

TESTS PASSED ERRORS FAILED SKIPPED MUTED?
665 (only retried tests) 562 0 43 33 27

🟢 2025-05-05 11:57:02 UTC Build successful.
🟢 2025-05-05 11:57:33 UTC ydbd size 3.8 GiB changed* by +38.9 KiB, which is < 100.0 KiB vs main: OK

ydbd size dash main: 5b564f8 merge: e013d7d diff diff %
ydbd size 4 121 690 776 Bytes 4 121 730 592 Bytes +38.9 KiB +0.001%
ydbd stripped size 1 429 126 808 Bytes 1 429 136 984 Bytes +9.9 KiB +0.001%

*please be aware that the difference is based on comparing your commit and the last completed build from the post-commit, check comparation

alexvru
alexvru previously approved these changes May 5, 2025
Copy link

github-actions bot commented May 5, 2025

2025-05-05 09:16:28 UTC Pre-commit check linux-x86_64-relwithdebinfo for e013d7d has started.
2025-05-05 09:16:39 UTC Artifacts will be uploaded here
2025-05-05 09:19:46 UTC ya make is running...
🟡 2025-05-05 10:57:55 UTC Some tests failed, follow the links below. Going to retry failed tests...

Test history | Ya make output | Test bloat

TESTS PASSED ERRORS FAILED SKIPPED MUTED?
29545 26861 0 6 2641 37

2025-05-05 11:00:19 UTC ya make is running... (failed tests rerun, try 2)
🟡 2025-05-05 11:24:28 UTC Some tests failed, follow the links below. Going to retry failed tests...

Test history | Ya make output | Test bloat | Test bloat

TESTS PASSED ERRORS FAILED SKIPPED MUTED?
180 (only retried tests) 149 0 2 0 29

2025-05-05 11:24:39 UTC ya make is running... (failed tests rerun, try 3)
🔴 2025-05-05 11:50:14 UTC Some tests failed, follow the links below.

Test history | Ya make output | Test bloat | Test bloat | Test bloat

TESTS PASSED ERRORS FAILED SKIPPED MUTED?
107 (only retried tests) 78 0 1 0 28

🟢 2025-05-05 11:50:21 UTC Build successful.
🟢 2025-05-05 11:50:42 UTC ydbd size 2.2 GiB changed* by +26.0 KiB, which is < 100.0 KiB vs main: OK

ydbd size dash main: 5b564f8 merge: e013d7d diff diff %
ydbd size 2 342 846 768 Bytes 2 342 873 400 Bytes +26.0 KiB +0.001%
ydbd stripped size 492 768 192 Bytes 492 776 512 Bytes +8.1 KiB +0.002%

*please be aware that the difference is based on comparing your commit and the last completed build from the post-commit, check comparation

@adameat adameat enabled auto-merge (squash) May 5, 2025 09:38
Copy link

github-actions bot commented May 5, 2025

2025-05-05 12:25:16 UTC Pre-commit check linux-x86_64-release-asan for ae236c9 has started.
2025-05-05 12:26:04 UTC Artifacts will be uploaded here
2025-05-05 12:30:36 UTC ya make is running...
🟡 2025-05-05 14:26:10 UTC Some tests failed, follow the links below. This fail is not in blocking policy yet Going to retry failed tests...

Test history | Ya make output | Test bloat

TESTS PASSED ERRORS FAILED SKIPPED MUTED?
14758 14595 0 100 39 24

2025-05-05 14:27:33 UTC ya make is running... (failed tests rerun, try 2)
🟡 2025-05-05 14:56:29 UTC Some tests failed, follow the links below. This fail is not in blocking policy yet Going to retry failed tests...

Test history | Ya make output | Test bloat | Test bloat

TESTS PASSED ERRORS FAILED SKIPPED MUTED?
947 (only retried tests) 840 0 49 35 23

2025-05-05 14:56:42 UTC ya make is running... (failed tests rerun, try 3)
🟡 2025-05-05 15:22:18 UTC Some tests failed, follow the links below. This fail is not in blocking policy yet

Test history | Ya make output | Test bloat | Test bloat | Test bloat

TESTS PASSED ERRORS FAILED SKIPPED MUTED?
715 (only retried tests) 617 0 46 29 23

🟢 2025-05-05 15:22:29 UTC Build successful.
🔴 2025-05-05 15:23:21 UTC ydbd size 3.8 GiB changed* by +4.6 MiB, which is >= 2.0 MiB vs main: Alert

ydbd size dash main: 71218f4 merge: ae236c9 diff diff %
ydbd size 4 121 683 000 Bytes 4 126 547 008 Bytes +4.6 MiB +0.118%
ydbd stripped size 1 429 119 256 Bytes 1 433 284 440 Bytes +4.0 MiB +0.291%

*please be aware that the difference is based on comparing your commit and the last completed build from the post-commit, check comparation

Copy link

github-actions bot commented May 5, 2025

2025-05-05 12:26:49 UTC Pre-commit check linux-x86_64-relwithdebinfo for ae236c9 has started.
2025-05-05 12:27:16 UTC Artifacts will be uploaded here
2025-05-05 12:30:51 UTC ya make is running...
🟡 2025-05-05 14:10:52 UTC Some tests failed, follow the links below. Going to retry failed tests...

Test history | Ya make output | Test bloat

TESTS PASSED ERRORS FAILED SKIPPED MUTED?
29546 26871 0 4 2631 40

2025-05-05 14:13:25 UTC ya make is running... (failed tests rerun, try 2)
🟢 2025-05-05 14:39:06 UTC Tests successful.

Test history | Ya make output | Test bloat | Test bloat

TESTS PASSED ERRORS FAILED SKIPPED MUTED?
630 (only retried tests) 596 0 0 2 32

🟢 2025-05-05 14:39:17 UTC Build successful.
🟢 2025-05-05 14:39:37 UTC ydbd size 2.2 GiB changed* by +64.1 KiB, which is < 100.0 KiB vs main: OK

ydbd size dash main: a8596d8 merge: ae236c9 diff diff %
ydbd size 2 343 324 672 Bytes 2 343 390 312 Bytes +64.1 KiB +0.003%
ydbd stripped size 493 063 040 Bytes 493 071 872 Bytes +8.6 KiB +0.002%

*please be aware that the difference is based on comparing your commit and the last completed build from the post-commit, check comparation

@adameat adameat requested review from alexvru and Copilot May 6, 2025 03:44
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements several improvements to enhance the HTTP proxy functionality such as addressing hanging connections, improving header handling, streamlining the request syntax, and extending support for static content.

  • Fixes hanging stored connections after timeouts expire
  • Corrects built-in header handling and simplifies request syntax
  • Extends and refactors the static content handler API

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.

Show a summary per file
File Description
ydb/library/actors/http/http_ut.cpp Adjusts assertion ordering for error responses in tests.
ydb/library/actors/http/http_static.h Introduces an overload for static content handler with a URL adapter.
ydb/library/actors/http/http_static.cpp Refactors static content handler to replace the index member with a URL adapter and changes mime type determination.
ydb/library/actors/http/http_proxy_outgoing.cpp Refactors the outgoing connection actor to use bootstrapping and streamlines the request initialization and error handling.
ydb/library/actors/http/http_proxy.h Updates outgoing connection actor API signature.
ydb/library/actors/http/http_proxy.cpp Adapts outgoing connection creation and uses a forwarding helper for event handling.
ydb/library/actors/http/http.h Adds an initializer_list overload for THeadersBuilder.
ydb/library/actors/http/http.cpp Adjusts header injection logic in responses and provides the new THeadersBuilder constructor.
Comments suppressed due to low confidence (2)

ydb/library/actors/http/http_static.cpp:56

  • Using GetName() instead of GetExtension() for mime type determination could result in incorrect content type detection if the file name does not contain the expected extension. Consider reverting to GetExtension() or providing additional logic to extract the file extension reliably.
TString contentType = mimetypeByExt(url.GetName().c_str());

ydb/library/actors/http/http_proxy_outgoing.cpp:160

  • [nitpick] Changing the error message from 'ConnectionClosed' to an empty string for a zero result may be inconsistent with unit tests that expect 'ConnectionClosed'. Verify that the conditional logic in ReplyErrorAndPassAway correctly handles the case when no error string is provided.
ReplyErrorAndPassAway(res == 0 ? "" : strerror(-res));

@adameat adameat merged commit d7474a1 into ydb-platform:main May 6, 2025
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/ui UI/Embedded UI related issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants