-
Notifications
You must be signed in to change notification settings - Fork 567
feat(storage): add support for conditional idempotent operations #18834
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): add support for conditional idempotent operations #18834
Conversation
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.
consider:
def self.retry? query_params
query_params.any? { |_key, val| !val.nil? }
endThere 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.
This seems like it should be a module, not a class, since there's no point in instantiating it. Also, if the module exists only to contain one helper method, maybe that method should just be a private helper method in the service class where it's being called from. It seems like it's not meant to be a part of the public interface.
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.
Yeah that makes sense. I kept it in a separate file because I thought it'd be used from multiple places.
tritone
left a comment
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.
Seems like a step in the right direction. Remind me, have you added user configuration to allow users to retry in all cases yet? This will be helpful if any users were depending on this current behavior, so it should be a fast follow from this PR if it's not already complete.
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.
Note that this should be for the destination file, not the source-- not sure how this is distinguished in Ruby.
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 believe this is for destination file and if_source_generation_match is for source file.
google-cloud-storage/test/helper.rb
Outdated
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 see you updated mocks for existing tests; is it possible to also add a simple test with preconditions to ensure that retries do occur in this case? I guess this will be covered by conformance tests as well.
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 did think of that. I'm not sure how I can verify if the method is being retried over here but then I thought this would be covered in conformance test. I think that would suffice, no?
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.
Yup conformance tests should cover it
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.
Same here, compose also requires preconditions for the destination specifically in order to allow 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.
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 believe that's correct.
We by default used to retry all the operations. Now, we're trying not to retry the conditionally idempotent operations. |
ae00319 to
f5a4d34
Compare
|
The acceptance and samples tests failures are happening on the main branch too and are unrelated to my changes. I've created the issue#18854 to track this. |
Changing the default to only retry idempotent ops is correct. My questions is, can users override this default? Having this configurability is important so users can choose to retry everything if they don't like the default behavior. |
No, not with this change. I thought the requirement was not to let users retry the conditionally idempotent & non-idempotent operations even if they want to. |
5213b3b to
2aa5542
Compare
tritone
left a comment
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.
Overall LGTM, please add some docs for the retry option.
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.
Could you add docs for the option? Also just wanted to confirm that this will be something you can add across the board to library methods.
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 updated OVERVIEW doc which explains how to use the options field overall. Also updated other methods to accept options. We've a separate PR raised already for non-idempotent operations.
4bdd3b6 to
9dd64f8
Compare
tritone
left a comment
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 LGTM
| (For ex. a file has the same "generation"), the library retries only if the | ||
| condition is specified. | ||
|
|
||
| Rather than using this default behaviour, you may choose to disable the 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.
Also include information about how users can enable retries on non-idempotent operations. (this is possible right?)
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.
We'll be adding it in a separate PR which covers retry configurations for non-idempotent operations overall. I didn't want to club that here because Sandeep has already worked on it.
Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:
bundle exec rake ciin the gem subdirectory.closes: #<issue_number_goes_here>