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

Implement sidecar streaming read to accommodate the tracking report digest computing #64

Merged
merged 1 commit into from
Feb 10, 2023

Conversation

yma96
Copy link
Member

@yma96 yma96 commented Feb 8, 2023

Update the implementation of ProxyStreamingOutput to handle ProxyService.get. We need bytes to read from the buffer to take on the responsibility for computing digest for the sidecar tracking report.
The buffer reading is different from #31 since we already change HTTP client into okhttp3. The okio BufferedSource could keep a buffer internally so that callers can do small reads without a performance penalty.
We could request the case from PNC to test the large streaming performance, from what I tested locally, it's stable so far.
Related bug: https://issues.redhat.com/browse/MMENG-3532

@yma96 yma96 requested a review from ligangty February 8, 2023 13:09
@yma96
Copy link
Member Author

yma96 commented Feb 8, 2023

Hi, @ligangty could you help to review the code? This is a bug related to sidecar 2.0.0 which blocked the streaming reading. Thanks!

Copy link
Member

@ligangty ligangty left a comment

Choose a reason for hiding this comment

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

Generally looks good.
BTW, do we have a unit test for this ProxyStreamingOutput?

logger.trace( "Copying from: {} to: {}", bodyStream, out );
IOUtils.copy( bodyStream, out );

OutputStream out = cout;
Copy link
Member

Choose a reason for hiding this comment

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

Is this out needed? Why not use cout directly here?

Copy link
Member Author

Choose a reason for hiding this comment

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

@ligangty This is the same with the previously removed code, I think what John considered here might be out is used for writing, cout is used for bytes count.

}
catch ( IOException e )
{
if ( otel.enabled() )
Copy link
Member

Choose a reason for hiding this comment

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

Is this possible to happen in the new okhttp3 way?

Copy link
Member Author

Choose a reason for hiding this comment

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

@ligangty it's verified, IOException is never thrown in responsebody.close().

@yma96
Copy link
Member Author

yma96 commented Feb 10, 2023

Generally looks good. BTW, do we have a unit test for this ProxyStreamingOutput?

@ligangty no, sidecar doesn't have the ReportService and WebClientAdapter related unit tests, this streaming should call both of them for the testing, it needs to be perfect then.

@ligangty
Copy link
Member

Ok, so it LGTM.

@yma96 yma96 merged commit 1e322ac into Commonjava:2.0.x Feb 10, 2023
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