Repository navigation
[Dataflow] Warn when the staging bucket has an age-based lifecycle rule - #41678
Anurag-S1ngh wants to merge 1 commit into
Conversation
Check bucket lifecycle metadata during job submission and warn when a Delete rule has an age condition. Failures to inspect the bucket are logged at debug level so the check never blocks submission.
There was a problem hiding this comment.
📋 Review Summary
This PR adds a non-blocking pre-submission check in DataflowApplicationClient.create_job_description that warns users when their GCS staging bucket has an age-based Delete lifecycle rule. The implementation cleanly handles local staging paths and suppresses metadata lookup failures at DEBUG level so job submission is never disrupted.
🔍 General Feedback
- The lifecycle rule inspection is straightforward and well-tested, though filtering out conditions that cannot affect live staged objects (such as
isLive: Falseon versioned buckets or non-matchingmatchesPrefixrules) would help prevent false-positive warnings.
💡 Tip: Comment /gemini review on this pull request to trigger a new Gemini code review.
| return | ||
| for rule in bucket.lifecycle_rules or []: | ||
| condition = rule.get('condition', {}) | ||
| if rule.get('action', {}).get('type') == 'Delete' and 'age' in condition: |
There was a problem hiding this comment.
🟡 Medium: GCS Delete lifecycle rules with an age condition may be scoped to non-live object versions ("isLive": False on versioned buckets) or to specific prefixes ("matchesPrefix", e.g., ["temp/"] when a single bucket is shared between --temp_location=gs://bucket/temp and --staging_location=gs://bucket/staging). Checking that condition.get('isLive') is not False (and, if matchesPrefix is set, that it can match the staging path prefix) will avoid false-positive warnings for properly configured buckets.
| if rule.get('action', {}).get('type') == 'Delete' and 'age' in condition: | |
| if (rule.get('action', {}).get('type') == 'Delete' and condition.get('age') is not None and condition.get('isLive') is not False): |
|
Assigning reviewers: R: @tvalentyn for label python. Note: If you would like to opt out of this review, comment Available commands:
The PR bot will only process comments in the main thread (not review comments). |
Summary
Warns during Dataflow job submission when the staging bucket has a lifecycle rule that deletes objects by age. This helps catch the configuration that causes staged files to be removed while a long-running or streaming pipeline still needs them.
Changes
Deleterule includes anageconditionTesting
pytest apache_beam/runners/dataflow/internal/apiclient_test.py: 71 passed, 1 skippedruff check apache_beam/runners/dataflow/internal/apiclient.py apache_beam/runners/dataflow/internal/apiclient_test.pyyapf --diff apache_beam/runners/dataflow/internal/apiclient.py apache_beam/runners/dataflow/internal/apiclient_test.pyCloses #18123