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

DPDV-6531: Retry when server does not return JSON #81

Merged

Conversation

martin-majlis-s1
Copy link
Collaborator

@martin-majlis-s1 martin-majlis-s1 commented Feb 29, 2024

Jira Link: https://sentinelone.atlassian.net/browse/DPDV-6531

🥅 Goal

Retry to send requests even when the server is not sending expected (JSON) response.

🛠️ Solution

Original version was not retrying when it was not possible to connect to the server or when it returned response in different format then expected. Since this situation can happen during some system outages - upstream connect error or disconnect/reset before headers. reset reason: connection termination:

error:            "unable to parse response body: invalid character 'u' looking for beginning of value, url: https://app.scalyr.com/api/addEvents, response: upstream connect error or disconnect/reset before headers. reset reason: connection termination",

We should retry. Hopefully the server recovers meanwhile.

🏫 Testing

I have added test for this scenario.

📓 Note

I have also updated dependabot configuration, so it updates also examples, so we do not have this version changes in the future.

@martin-majlis-s1 martin-majlis-s1 marked this pull request as ready for review February 29, 2024 08:55
@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 85.71429% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 75.79%. Comparing base (422e686) to head (9cd8492).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #81      +/-   ##
==========================================
- Coverage   75.95%   75.79%   -0.17%     
==========================================
  Files          12       12              
  Lines        2096     2094       -2     
==========================================
- Hits         1592     1587       -5     
- Misses        419      421       +2     
- Partials       85       86       +1     
Files Coverage Δ
pkg/client/client.go 85.08% <100.00%> (-0.05%) ⬇️
pkg/client/add_events.go 81.55% <66.67%> (-0.64%) ⬇️

@martinrataj
Copy link
Collaborator

@martin-majlis-s1 I don't know much about this library. But does it make sense to retry if the response has unexpected format? Do you have some examples when a retry could help in this case?

Copy link
Collaborator

@tomaz-s1 tomaz-s1 left a comment

Choose a reason for hiding this comment

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

LGTM, thanks.

@martin-majlis-s1
Copy link
Collaborator Author

@martinrataj : It looks that when there is some outage, it's returning - upstream connect error or disconnect/reset before headers. reset reason: connection termination

@martin-majlis-s1 martin-majlis-s1 added this pull request to the merge queue Mar 1, 2024
Merged via the queue into main with commit 46bddbb Mar 1, 2024
11 checks passed
@martin-majlis-s1 martin-majlis-s1 deleted the DPDV-6531-retry-when-non-json-response-is-returned branch March 1, 2024 13:04
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.

4 participants