Skip to content

Review handling of status code in HTTP requests #1549

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

Merged
merged 11 commits into from
Nov 13, 2023

Conversation

jsoriano
Copy link
Member

@jsoriano jsoriano commented Nov 8, 2023

In a number of places we were not handling HTTP status codes, what may hide issues
or complicate debugging.
Also ensure that body is closed in all cases.

Fixes #1486

@jsoriano jsoriano requested a review from a team November 8, 2023 18:51
@jsoriano jsoriano self-assigned this Nov 8, 2023
@jsoriano jsoriano force-pushed the http-unexpected-status-codes branch from 1f5c8d9 to 2dc182d Compare November 8, 2023 18:55
// No docs yet.
return &hits{}, nil
}
if resp.StatusCode == http.StatusServiceUnavailable && strings.Contains(resp.String(), "no_shard_available_exception") {
Copy link
Member Author

Choose a reason for hiding this comment

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

FTR, this is the error I saw that made me to handle this case:

Error: error running package system tests: could not complete test run: failed to search docs for data stream metrics-apache.status-ep: [503 Service Unavailable] {"error":{"root_cause":[{"type":"no_shard_available_action_exception","reason":null}],"type":"search_phase_execution_exception","reason":"all shards failed","phase":"query","grouped":true,"failed_shards":[{"shard":0,"index":".ds-metrics-apache.status-ep-2023.11.09-000001","node":null,"reason":{"type":"no_shard_available_action_exception","reason":null}}]},"status":503}

@jsoriano jsoriano force-pushed the http-unexpected-status-codes branch from bf6b99a to f2246ac Compare November 9, 2023 15:43
@jsoriano
Copy link
Member Author

jsoriano commented Nov 9, 2023

/test

@jsoriano jsoriano requested a review from mrodm November 10, 2023 09:44
Copy link
Contributor

@mrodm mrodm left a comment

Choose a reason for hiding this comment

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

LGTM
Should we run a test integrations in this PR before merging ?

@jsoriano
Copy link
Member Author

test integrations

@elasticmachine
Copy link
Collaborator

Created or updated PR in integrations repository to test this version. Check elastic/integrations#8460

@jsoriano
Copy link
Member Author

test integrations

@elasticmachine
Copy link
Collaborator

Created or updated PR in integrations repository to test this version. Check elastic/integrations#8460

@jsoriano
Copy link
Member Author

test integrations

@elasticmachine
Copy link
Collaborator

Created or updated PR in integrations repository to test this version. Check elastic/integrations#8460

@elasticmachine
Copy link
Collaborator

💚 Build Succeeded

History

cc @jsoriano

@jsoriano jsoriano requested a review from mrodm November 10, 2023 16:43
@jsoriano
Copy link
Member Author

I had to do some fixes after testing with integrations, it seems to be fine now @mrodm could you re-review? Thanks!

Copy link
Contributor

@mrodm mrodm left a comment

Choose a reason for hiding this comment

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

🚀

@jsoriano jsoriano merged commit 2c241f1 into elastic:main Nov 13, 2023
@jsoriano jsoriano deleted the http-unexpected-status-codes branch November 13, 2023 09:50
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.

Handle unexpected status codes in HTTP responses
3 participants