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

fix: immediately flush data to client for event-stream response #3375

Merged
merged 8 commits into from
Jul 29, 2024

Conversation

mchtech
Copy link
Contributor

@mchtech mchtech commented Jul 12, 2024

Description

When content type is text/event-stream, proxy.handleHTTP should flush data to client immediately.

Related Issue

Fix #3386

same reason: golang/go#2012

Motivation and Context

MinIO client support watching and synchronizing changes from MinIO server to local fs.
It makes a "watch" request to minio server and waits server to push events when objects changed. (server also periodicly send events to client to keep connection alive, even if watched objects are not changed.)

export http_proxy=http://127.0.0.1:65001
mc mirror --watch --overwrite --debug [alias]/[bucket]/[watched-path]/ /path/to/local/

When using dfdaemon as a http proxy, MinIO client cannot receive event from dfdaemon immediately, ultil server pushes enough data to buffer.

This patch can make MinIO client watch feature to work as expected and then download objects via dragonfly P2P network.
Related codes are copied from golang standard library.

Screenshots (if appropriate)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation Update (if none of the other choices apply)

Checklist

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.

@mchtech mchtech requested a review from a team as a code owner July 12, 2024 02:59
Copy link

codecov bot commented Jul 12, 2024

Codecov Report

Attention: Patch coverage is 72.34043% with 13 lines in your changes missing coverage. Please review.

Project coverage is 52.76%. Comparing base (29ab308) to head (3ddf3e8).
Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3375      +/-   ##
==========================================
+ Coverage   52.64%   52.76%   +0.11%     
==========================================
  Files         192      193       +1     
  Lines       20439    20485      +46     
==========================================
+ Hits        10761    10808      +47     
+ Misses       8877     8869       -8     
- Partials      801      808       +7     
Flag Coverage Δ
unittests 52.76% <72.34%> (+0.11%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
client/daemon/proxy/proxy.go 21.53% <84.21%> (+6.24%) ⬆️
client/daemon/proxy/proxy_writter.go 64.28% <64.28%> (ø)

... and 3 files with indirect coverage changes

Copy link
Member

@jim3ma jim3ma left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@gaius-qi gaius-qi left a comment

Choose a reason for hiding this comment

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

LGTM

@gaius-qi gaius-qi merged commit 83450d5 into dragonflyoss:main Jul 29, 2024
29 checks passed
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.

dfdaemon does not immediately flush data to client for event-stream response
3 participants