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

Catch Timeout on test urls #4248

Merged
merged 1 commit into from
Oct 22, 2024

Conversation

Glutexo
Copy link
Collaborator

@Glutexo Glutexo commented Oct 14, 2024

All Pull Requests:

Check all that apply:

  • Have you followed the guidelines in our Contributing document, including the instructions about commit messages?
  • No Sensitive Data in this change?
  • Is this PR to correct an issue?
  • Is this PR an enhancement?

Complete Description of Additions/Changes:

The internal methods used by the --test-connection command only used to catch ConnectionError, including ConnectionTimeout, but not other timeouts such as ReadTimeoutError. As a result, in case of a read timeout,  the failure is not fully handled. That means:

  • an error message containing the failed URL is not logged;
  • and in case of legacy upload, the URL fallback mechanism is interrupted.

Re-used the existing REQUEST_FAILED_EXCEPTIONS list to process all timeouts in the same way.

Card IDs:

@Glutexo Glutexo added the client These issues represent work to be done by the "client" team. label Oct 14, 2024
@Glutexo Glutexo self-assigned this Oct 14, 2024
@codecov-commenter
Copy link

codecov-commenter commented Oct 14, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 77.10%. Comparing base (416ed6b) to head (bafcb3d).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4248      +/-   ##
==========================================
+ Coverage   77.01%   77.10%   +0.09%     
==========================================
  Files         761      761              
  Lines       41471    41471              
  Branches     8763     8763              
==========================================
+ Hits        31937    31976      +39     
+ Misses       8481     8438      -43     
- Partials     1053     1057       +4     
Flag Coverage Δ
unittests 77.09% <100.00%> (+0.09%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Glutexo
Copy link
Collaborator Author

Glutexo commented Oct 14, 2024

I extracted this fix from #4237 and originally from #4211. #4211 only changes exception handling in the outer test_connection method, because that is the minimal patch to fix the reported issue of a stack trace being dumped on the standard output. This new PR, on the other hand, fixes error logging and fallback mechanism in case of a read timeout.

Moreover, this would unblock #4246 in case of #4211 being merged first of the two. See my comment in #4246 for more details.

@Glutexo
Copy link
Collaborator Author

Glutexo commented Oct 15, 2024

This patch only updates the inner _test_urls and _legacy_test_urls methods, not the outer test_connection method. It doesn’t even change any printing or logging logic. Therefore, unlike #4211 and #4246, there are no tests of test_connection or integration tests.

The error log and standard out tests are the only way how to find out whether the except block fired as intended. That’s why there are log/stdout tests in place. They, however, don’t test the contents of the messages as that’s not the subject of this pull request. That will change after merging with the tests from other related PRs.

@Glutexo Glutexo marked this pull request as ready for review October 15, 2024 12:26
@Glutexo
Copy link
Collaborator Author

Glutexo commented Oct 15, 2024

Open for review. @m-horky

Copy link
Contributor

@m-horky m-horky left a comment

Choose a reason for hiding this comment

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

I don't have objections, I'll just need to see in context of the other PRs.

Copy link
Contributor

Choose a reason for hiding this comment

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

Are all these tests for the patch of connection.py in this PR?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not entirely. As I mentioned in my comment, there are only tests for the _test_urls and _legacy_test_urls. There are no tests for test_connection.

Some notes for tests that may seem over the scope:

  • The log and print tests are there to check that the except block executed. They only assert the calls, not the contents.
  • The get/post methods are the ones that raise the caught exceptions. Hence the call asserts for those.

The other pull requests contain more tests or make some of the existing ones more precise. The latter applies for the log/stdout messages. I will resolve the merge conflict, by which the new patch in the following PR will be nice and clear. The test names are the same, so this will be easy.

@Glutexo
Copy link
Collaborator Author

Glutexo commented Oct 21, 2024

To make things simpler, let‘s say this is a blocker of #4246, which is a blocker of #4211. Merging this first will make further reviewing and merging easier.

@Glutexo Glutexo requested a review from m-horky October 21, 2024 12:34
@Glutexo Glutexo mentioned this pull request Oct 21, 2024
3 tasks
The internal methods used by the --test-connection command only used to catch ConnectionError, including ConnectionTimeout, but not other timeouts such as ReadTimeoutError. As a result, in case of a read timeout,  the failure is not fully handled. That means:

* an error message containing the failed URL is not logged;
* and in case of legacy upload, the URL fallback mechanism is interrupted.

Re-used the existing REQUEST_FAILED_EXCEPTIONS list to process all timeouts in the same way.

Card IDs:

* CCT-859

Signed-off-by: Štěpán Tomsa <[email protected]>
@Glutexo
Copy link
Collaborator Author

Glutexo commented Oct 22, 2024

There is also #4254 in the family. It neither blocks anything nor is blocked by anything. It only shares some tests.

Copy link
Contributor

@m-horky m-horky left a comment

Choose a reason for hiding this comment

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

ACK

@m-horky
Copy link
Contributor

m-horky commented Oct 22, 2024

Hi, @xiangce, good to merge!

@xiangce xiangce merged commit ab75010 into RedHatInsights:master Oct 22, 2024
14 of 15 checks passed
@Glutexo Glutexo deleted the read-timeout-test-urls branch October 22, 2024 13:13
@Glutexo Glutexo mentioned this pull request Oct 22, 2024
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
client These issues represent work to be done by the "client" team.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants