-
Notifications
You must be signed in to change notification settings - Fork 269
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove retry circular dependency (#1969)
Removing usage of `@retry.wrap` in logs methods. This removal is necessary because retries also use logs inside of their implementation so we want to avoid the following cyclic scenario: 1. Log method is called 2. A log fails (e.g. permission issue) 3. The logging method uses a retry wrapper, so it tries again 4. The code inside the retry wrapper also calls a log method, so we go back to step 1 Before this PR, this scenario was avoided by using a `log_retries` parameter, that would disable loggings on retries functions when the retry was called from a log function. This PR remove this parameter and get rid of the circular dependency by making a custom retry logic inside of the logs methods. --------- Co-authored-by: Gustavo Chaves Galdino de Moraes <[email protected]> Co-authored-by: jonathanmetzman <[email protected]>
- Loading branch information
1 parent
e83b9be
commit 162ca0c
Showing
4 changed files
with
92 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Copyright 2024 Google LLC | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
"""Tests for utils.py""" | ||
|
||
from common import utils | ||
|
||
|
||
def test_get_retry_delay(): | ||
""""Tests if get delay is working as expected""" | ||
delay = 3 | ||
backoff = 2 | ||
|
||
first_try = 1 | ||
first_try_delay = utils.get_retry_delay(first_try, delay, backoff) | ||
# Backoff should have no effect on first try | ||
assert first_try_delay == delay | ||
|
||
second_try = 2 | ||
second_try_delay = utils.get_retry_delay(second_try, delay, backoff) | ||
assert second_try_delay == delay * backoff |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters