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

Don't log non-standard ES JSON error responses as errors #5971

Merged
merged 1 commit into from
Sep 19, 2022

Conversation

pebrc
Copy link
Collaborator

@pebrc pebrc commented Aug 24, 2022

Fixes #5473

Only controversial bit is maybe the logging of the whole response body but I thought it might be acceptable as the client is always Elasticsearch we roughly know the responses that are being returned. However a proxy in-between like Envoy might change that. Curious about your thoughts.

@pebrc pebrc added >enhancement Enhancement of existing functionality v2.5.0 labels Aug 24, 2022
@barkbay barkbay self-assigned this Sep 7, 2022
Copy link
Contributor

@barkbay barkbay left a comment

Choose a reason for hiding this comment

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

Only controversial bit is maybe the logging of the whole response body

I think I'm fine with the change since the body is only logged when an error occurs. It is then very unlikely that the body contains sensitive data in that case.

@@ -277,6 +277,16 @@ func TestAPIError_Error(t *testing.T) {
`Type:illegal_argument_exception} Reason:illegal value can't update [discovery.zen.minimum_master_nodes] from [1] to [6] Type:illegal_argument_exception ` +
`StackTrace: RootCause:[{Reason:[stack-sample-es-575vhzs8ln][10.60.1.22:9300][cluster:admin/settings/update] Type:remote_transport_exception}]}}`,
},
{
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: the changes in pkg/controller/elasticsearch/client/error.go have no effect on the value returned by apiError.Error(), unless I'm missing something I don't think this test brings more value than the existing ones?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You are right about that. I added it because I felt we were missing the case where we have an HTTP error status code but a regular Elasticsearch REST response in the body of the request.

@pebrc pebrc merged commit 5cb6127 into elastic:main Sep 19, 2022
fantapsody pushed a commit to fantapsody/cloud-on-k8s that referenced this pull request Feb 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>enhancement Enhancement of existing functionality v2.5.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unhelpful error log on unmarshallable ES error response
2 participants