Skip to content

[Dataflow] Warn when the staging bucket has an age-based lifecycle rule - #41678

Open
Anurag-S1ngh wants to merge 1 commit into
apache:masterfrom
Anurag-S1ngh:fix/18123-warn-staging-bucket-ttl
Open

Anurag-S1ngh wants to merge 1 commit into
apache:masterfrom
Anurag-S1ngh:fix/18123-warn-staging-bucket-ttl

Conversation

@Anurag-S1ngh

Copy link
Copy Markdown
Contributor

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

  • Inspect the staging bucket lifecycle rules before staging job resources
  • Warn when a Delete rule includes an age condition
  • Ignore local staging paths
  • Log metadata lookup failures at debug level so the check never blocks submission
  • Add tests for matching and non-matching lifecycle rules, local paths, and lookup failures

Testing

  • pytest apache_beam/runners/dataflow/internal/apiclient_test.py: 71 passed, 1 skipped
  • ruff check apache_beam/runners/dataflow/internal/apiclient.py apache_beam/runners/dataflow/internal/apiclient_test.py
  • yapf --diff apache_beam/runners/dataflow/internal/apiclient.py apache_beam/runners/dataflow/internal/apiclient_test.py

Closes #18123

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.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📋 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: False on versioned buckets or non-matching matchesPrefix rules) 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:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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.

Suggested change
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):

@github-actions github-actions Bot added python runners size/s S: 10-49 lines changed labels Nov 25, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Assigning reviewers:

R: @tvalentyn for label python.
Backup reviewer: claudevdm (if the main reviewer is unresponsive, you can escalate to them by tagging their username)

Note: If you would like to opt out of this review, comment assign to next reviewer.

Available commands:

  • stop reviewer notifications - opt out of the automated review tooling
  • remind me after tests pass - tag the comment author after tests pass
  • waiting on author - shift the attention set back to the author (any comment or push by the author will return the attention set to the reviewers)

The PR bot will only process comments in the main thread (not review comments).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

py DataflowRunner should warn if the stagingLocation has a TTL

1 participant