-
Notifications
You must be signed in to change notification settings - Fork 32
feat: merge attemptDeadlineSeconds and timeoutSeconds option for v2 scheduled functions #264
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
Conversation
Summary of ChangesHello @taeold, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request simplifies the configuration of scheduled functions by unifying the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
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.
Code Review
This pull request aims to unify the timeoutSeconds of a scheduled function with the attemptDeadlineSeconds of the underlying Cloud Scheduler job. The changes correctly propagate the timeout value in firebase_functions.options.py, update the manifest definition, and add a new test case.
My review identifies a couple of issues with the current implementation. First, the unification of timeouts does not work correctly when default values are used, leading to different timeout values for the function and the scheduler job. Second, the provided timeout value is not validated against the allowed range for Cloud Scheduler's attemptDeadlineSeconds, which could result in deployment failures. I've provided a code suggestion to address these points.
I've also suggested an additional test case to cover the default timeout scenario and ensure the fix is verified.
| endpoint = decorated_func.__firebase_endpoint__ | ||
| self.assertEqual(endpoint.timeoutSeconds, 120) | ||
| self.assertEqual(endpoint.scheduleTrigger.get("attemptDeadlineSeconds"), 120) | ||
|
|
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.
To ensure the unification of timeouts works correctly for the default case (when timeout_sec is not specified), it would be beneficial to add a test case that covers this scenario. This will help verify that attemptDeadlineSeconds is set to the function's default timeout (60s) instead of Cloud Scheduler's default.
def test_on_schedule_with_default_timeout(self):
"""
Tests that attemptDeadlineSeconds is set to the default timeoutSeconds.
"""
decorated_func = scheduler_fn.on_schedule(
schedule="* * * * *",
)(Mock(__name__="example_func"))
endpoint = decorated_func.__firebase_endpoint__
# The function timeout will be the platform default, but the attempt deadline
# should be explicitly set to the function's default timeout (60s).
self.assertEqual(endpoint.timeoutSeconds, scheduler_fn._options.RESET_VALUE)
self.assertEqual(endpoint.scheduleTrigger.get("attemptDeadlineSeconds"), 60)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.
disagree. scheduler having a default timeout of 3m. functions have default timeout of 1m. when scheudler timeout > function timeout, we don't expect things to go wrong.
We are removing explicit control for users to set
attemptDeadlineSeconds. This is because we feel thatattemptDeadlineSecondsandtimeoutSecondsfor the function is deeply coupled - there isn't a valid use case we can think of that requires the two values to be different.Per Cloud Scheduler docs:
Effectively, we believe function timeout ~= attemptDeadline (ideally attemptDeadline should be a second or two greater than function timeout, but we leave that out as edge case for now)