Open rohanKanojia opened 2 days ago
[APPROVALNOTIFIER] This PR is NOT APPROVED
This pull-request has been approved by: Once this PR has been reviewed and has the lgtm label, please assign gbraad for approval. For more information see the Kubernetes Code Review Process.
The full list of commands accepted by this bot can be found here.
Hi @rohanKanojia. Thanks for your PR.
I'm waiting for a crc-org member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test
on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.
Once the patch is verified, the new status will be reflected by the ok-to-test
label.
I understand the commands that are listed here.
/assign @anjannath
Fixes: Issue #3766
Relates to: Issue #3766
Solution/Idea
Add a custom response writer to capture the response body and status code so that we can conditionally log the response body in case of failure.
Proposed changes
CustomResponseWriter
object as a wrapper aroundhttp.ResponseWriter
and override methods to capture response status code and body.interceptResponseBodyMiddleware
that would inject the abovementioned response writer into HTTP Handlers.interceptResponseBodyMiddleware
in daemon endpoint declarations and add handler for conditionally logging response body when response is not successfulTesting
What is the bottom-line functionality that needs testing? Describe in pseudo-code or in English. Use verifiable statements that tie your changes to existing functionality.
crc daemon
to start CRC daemonFor example if we make requests like these
We see these logs (notice there is no logging in case of successful request done in the end) :