-
Notifications
You must be signed in to change notification settings - Fork 185
update FilesExt retry logic #1211
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
base: main
Are you sure you want to change the base?
update FilesExt retry logic #1211
Conversation
45745d5 to
969720e
Compare
databricks/sdk/config.py
Outdated
| # Maximum number of retry attempts for FilesExt cloud API operations. | ||
| # This works in conjunction with retry_timeout_seconds - whichever limit | ||
| # is hit first will stop the retry loop. | ||
| files_ext_cloud_api_max_retries: int = 3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can use this as a temporary parameter, since our end goal is not to fallback.
| # Maximum number of retry attempts for FilesExt cloud API operations. | |
| # This works in conjunction with retry_timeout_seconds - whichever limit | |
| # is hit first will stop the retry loop. | |
| files_ext_cloud_api_max_retries: int = 3 | |
| # Maximum number of retry attempts for FilesExt cloud API operations. | |
| # This works in conjunction with retry_timeout_seconds - whichever limit | |
| # is hit first will stop the retry loop. | |
| experimental_files_ext_cloud_api_max_retries: int = 3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
databricks/sdk/retries.py
Outdated
|
|
||
| # Determine which limit was hit | ||
| if max_attempts is not None and attempt > max_attempts: | ||
| raise TimeoutError(f"Exceeded max retry attempts ({max_attempts})") from last_err |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have a better error to represent this error? TimeoutError feels a bit odd for this case, as the function is not actually timed out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally we should use a custom type RetryError, with TimeoutError and MaxRetryExceededError as it's derived types, so that the user can catch the RetryError if they don't care why the retry exhausted, while keeping the information.
However since we have been using built-in TimeoutError and users may already be depending on this behavior, it is risky to change it to a different Error.
If we were to introduce a new type of error for max retry exceeded scenario, it would be more difficult for the upper layer to handle the retry error: it needs to catch both Errors manually.
I don't see a better solution here, unless we can rewrite the retry logic completely, or make FilesExt using a different retry library.
tests/test_retries.py
Outdated
| def failing_function(): | ||
| nonlocal call_count | ||
| call_count += 1 | ||
| raise ValueError("test error") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we sleep on this failing function for a sec? I am a bit worried that this test will become flaky because it is possible to retry 100 times in 2 seconds.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It wouldn't because of the backoff logic, right?
tests/test_retries.py
Outdated
| def test_max_attempts_none_preserves_backward_compatibility(): | ||
| """Test that max_attempts=None only uses timeout (backward compatibility).""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| def test_max_attempts_none_preserves_backward_compatibility(): | |
| """Test that max_attempts=None only uses timeout (backward compatibility).""" | |
| def test_max_attempts_none(): | |
| """Test that max_attempts=None only uses timeout.""" |
I think we don't need to mention that this test is for backward compatibility because, almost always, a unit test is for regression catching.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
tests/test_retries.py
Outdated
| assert call_count == attempts | ||
|
|
||
|
|
||
| def test_max_attempts_respected(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we make these a table test to simplify the tests?
tests/test_retries.py
Outdated
| with pytest.raises(TimeoutError) as exc_info: | ||
| failing_function() | ||
|
|
||
| # Should have attempted 3 times (initial + 2 retries) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| # Should have attempted 3 times (initial + 2 retries) | |
| # Should have attempted 3 times (initial + 2 retries). |
Period after a sentence, ditto all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
87e5849 to
2cfa627
Compare
|
If integration tests don't run automatically, an authorized user can run them manually by following the instructions below: Trigger: Inputs:
Checks will be approved automatically on success. |
What changes are proposed in this pull request?
WHAT
max_attemptto allow client to retry and fail after certain amountWHY
How is this tested?
Unit tests were updated to reflect the change.