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

fix: retry on download errors #274

Merged
merged 4 commits into from
Jul 29, 2024
Merged

fix: retry on download errors #274

merged 4 commits into from
Jul 29, 2024

Conversation

carlossg
Copy link
Contributor

to avoid failing because of issues like connection reset

@yannh
Copy link
Owner

yannh commented Jun 30, 2024

Good idea, though this never gives up and doesnt back off incrementallly.. Any library we might be able to use maybe? 🤔

@carlossg
Copy link
Contributor Author

It just tries once, one second later, but I've used now hashicorp/go-retryablehttp.
If this looks good the tests need to use a real local server to test the retries

retries and other errors
@carlossg
Copy link
Contributor Author

carlossg commented Jul 26, 2024

@yannh added a test with a real http server to test the retries

test output

2024/07/26 13:34:55 [DEBUG] GET http://localhost:9163/simulate-reset
2024/07/26 13:34:55 [ERR] GET http://localhost:9163/simulate-reset request failed: Get "http://localhost:9163/simulate-reset": EOF
2024/07/26 13:34:55 [DEBUG] GET http://localhost:9163/simulate-reset: retrying in 1s (2 left)
2024/07/26 13:34:56 using schema found at http://localhost:9163/simulate-reset
2024/07/26 13:34:56 [DEBUG] GET http://localhost:9163/404
2024/07/26 13:34:56 could not find schema at http://localhost:9163/404
2024/07/26 13:34:56 [DEBUG] GET http://localhost:9163/500
2024/07/26 13:34:56 [DEBUG] GET http://localhost:9163/500 (status: 500): retrying in 1s (2 left)
2024/07/26 13:34:57 [DEBUG] GET http://localhost:9163/500 (status: 500): retrying in 2s (1 left)
2024/07/26 13:34:59 failed downloading schema at http://localhost:9163/500: Get "http://localhost:9163/500": GET http://localhost:9163/500 giving up after 3 attempt(s)
2024/07/26 13:34:59 [DEBUG] GET http://localhost:9163/503
2024/07/26 13:34:59 [DEBUG] GET http://localhost:9163/503 (status: 503): retrying in 1s (2 left)
2024/07/26 13:35:00 using schema found at http://localhost:9163/503
2024/07/26 13:35:00 [DEBUG] GET http://localhost:9163
2024/07/26 13:35:00 using schema found at http://localhost:9163

schemaPathTemplate: testCase.schemaPathTemplate,
strict: testCase.strict,
// create a temporary directory for the cache
tmpDir, err := os.MkdirTemp("", "kubeconform-cache")
Copy link
Owner

Choose a reason for hiding this comment

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

Not sure about creating a cache folder here... Esp as we test the HTTP client?

@yannh
Copy link
Owner

yannh commented Jul 27, 2024

Hi @carlossg , thanks a lot for the contribution. Your tests are quite a bit more complex than what we had before, but they look good. I iterated on them a little bit, can you let me know what you think? Thanks!

@carlossg
Copy link
Contributor Author

much better thanks

@yannh yannh merged commit 50ce5f8 into yannh:master Jul 29, 2024
@yannh
Copy link
Owner

yannh commented Jul 29, 2024

Acceptance tests are failing, not sure why - they run locally just fine. Unsure if related to this PR 🤔 it ll take me some time to troubleshoot.

yannh added a commit that referenced this pull request Jul 29, 2024
yannh added a commit that referenced this pull request Jul 29, 2024
@yannh
Copy link
Owner

yannh commented Jul 29, 2024

I reverted it, it seems to print debug log in some cases. I ll review this later today/this week 🙇

@yannh yannh mentioned this pull request Jul 30, 2024
@carlossg carlossg deleted the retry branch July 31, 2024 17:31
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