Skip to content

Conversation

@Anaethelion
Copy link
Contributor

This ensures the product check is not flagged wrongfully as successful if the answer has not been properly validated.
The client will retry product check until success or error.

@Anaethelion Anaethelion requested review from axw and removed request for axw July 21, 2021 16:46
@Anaethelion Anaethelion requested a review from axw July 21, 2021 19:54
@axw
Copy link
Member

axw commented Jul 22, 2021

This ensures the product check is not flagged wrongfully as successful if the answer has not been properly validated.

@Anaethelion can you describe how this was happening before? This change seems complicated to me, and I don't understand why it's necessary.

elasticsearch.go Outdated
Comment on lines 303 to 308
checkHeader := func() error {
if res != nil {
return genuineCheckHeader(res.Header)
}
return nil
}
Copy link
Member

Choose a reason for hiding this comment

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

As we have already checked err == nil above, res must be non-nil according to net/http:

If the returned error is nil, the Response will contain a non-nil Body which the user is expected to close. If the Body is not both read to EOF and closed, the Client's underlying RoundTripper (typically Transport) may not be able to re-use a persistent TCP connection to the server for a subsequent "keep-alive" request.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice catch, thanks for this! 👍

@Anaethelion Anaethelion merged commit 0cc2c99 into elastic:7.x Jul 22, 2021
@Anaethelion Anaethelion deleted the client/product_check/retry branch July 22, 2021 12:03
Anaethelion added a commit to Anaethelion/go-elasticsearch that referenced this pull request Jul 22, 2021
* Client: Improve product check
Differentiate unspported/unknown products

* Client: Handle http errors
Anaethelion added a commit that referenced this pull request Jul 22, 2021
* Product check: Improve retry mechanism  (#309)

* Client: Improve product check
Differentiate unspported/unknown products

* Client: Handle http errors

* Client: Rework product check according to latest spec (#310)

Handling of Info special cases
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