-
Notifications
You must be signed in to change notification settings - Fork 438
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
feat(storage): retry SignBlob call for URL signing #7862
Conversation
feat: add integration test for universe domain
…-tests feat(storage): add integration test for universe domain
feat(storage): add support for restore token
…yaguk09/google-cloud-php-fork into correct_retries-signBlob_api
signblob retry test cases
Correct retries sign blob api
using existing retryTrait
using existing retryTrait
throw new ServiceException('Transient error', 503); | ||
}; | ||
|
||
$res = $this->helper->proxyPrivateMethodCall('retrySignBlob', [ |
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.
generally speaking, calling private methods is a bad way to test. It would be better to mock the Connection
class being passed to v2Sign
, in a way that can trigger the retry.
I can work with you on how to write tests like that, if you'd like.
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.
That's a great point. Mocking the Connection class to trigger retries is a much more robust and testable approach. I'd be happy to work with you on implementing this.
review corrections and lint fix
Test case error fix
Storage/src/SigningHelper.php
Outdated
$retryDecider = $this->getRestRetryFunction($resourceName, 'execute', $args); | ||
|
||
while ($attempts < $maxRetries) { | ||
$attempts++; |
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.
I'm confused; shouldn't the retryDecider decide max number of attempts?
Hmm the documentation on this trait is confusing that it uses maxAttempts but doesn't have it in the function signature:
https://github.com/googleapis/google-cloud-php/blob/main/Storage/src/Connection/RetryTrait.php#L190
@bshaffer am I misunderstanding this? i'm not up-to-date on PHP
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.
You're right, I couldn't find a maxRetries or maxAttempts option in the documentation either. That's why I added the maxAttempt directly.
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.
I'll approve from my side; just need @bshaffer to weigh in here when he has a chance.
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.
If I'm reading this correctly, the current code does not have any check for maxAttempts
, so it seems like this would result in an infinite loop. There is no test case for a retryable error meeting its max attempts. I feel like we definitely need a retry max attempts.
add retry using idempontentOps list
implement review changes and maintain code standard
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.
I know that the logic for "maxAttempts" was intentionally removed, but I think that we still need some kind of protection here. Otherwise the user could get in an infinite loop.
Here's an example of a test I've added that results in an infinite loop, when it should be passing:
public function testRetrySignBlobThrowsExceptionAfterThreeAttempts()
{
$this->expectException(ServiceException::class);
$this->expectExceptionMessage('Transient error (4 attempts)');
$attempt = 0;
$signBlobFn = function () use (&$attempt) {
throw new ServiceException(
sprintf('Transient error (%s attempts)', ++$attempt),
503
);
};
$this->helper->proxyPrivateMethodCall('retrySignBlob', [$signBlobFn]);
}
I've hardcoded this to have a maxAttempts of 3, but it could be any number.
Ensure proper handling of maxRetries to prevent infinite loop errors.
Adds a retry mechanism to the SignBlob call's SignedURL() method to improve reliability in case of transient network or server issues. This change ensures that the SignedURL() operation can be retried under certain conditions, increasing the likelihood of successful URL generation.