Repository navigation
Conversation
The deduplication and receiver samples identified a scheduled run by the raw X-CloudScheduler-ScheduleTime header. A forced run sent before a job's first scheduled run carries the schedule time without Cloud Scheduler's per-job offset of a few seconds, so the same run could get two keys and be processed twice. Key on the scheduled minute in UTC instead, and reject a schedule time that can't be parsed with HTTP 400. Add unit tests for a delivery with and without the offset, and for an invalid schedule time.
Contributor
There was a problem hiding this comment.
Code Review
This pull request updates the Cloud Scheduler deduplication logic in both the deduplicate_job_requests and receiver services to key on the scheduled minute rather than the exact schedule time, ensuring that forced runs (which omit the few-second offset) are correctly identified as duplicates. Feedback highlights a compatibility issue where datetime.datetime.fromisoformat does not support the Z suffix in Python versions prior to 3.11, and suggests normalizing the suffix to +00:00 before parsing.
Replace the three-line explanation in the deduplication and receiver samples with a single line, and drop redundant comments from the tests whose names already describe the behavior.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes duplicate processing in
cloudscheduler_deduplicate_job_requests(from #14772) andcloudscheduler_receiver, found while live-testing the equivalent Workflows sample (#14782).Both samples identified a scheduled run by the raw
X-CloudScheduler-ScheduleTimeheader. In testing, a forced run (gcloud scheduler jobs run) sent before a job's first scheduled run carried the schedule time without Cloud Scheduler's per-job offset of a few seconds, for example01:00:00-08:00, while later deliveries of the same run carried01:00:02.202379-08:00. The two values produced different keys, so the same scheduled run was processed twice.Both samples now key on the scheduled minute in UTC, which matches either form. A schedule time that can't be parsed returns HTTP 400.
Tests
Checklist
Testing
Compliance & Style
Post-Approval Actions