github-actions[bot] commented on code in PR #41678:
URL: https://github.com/apache/beam/pull/41678#discussion_r4698352591
##########
sdks/python/apache_beam/runners/dataflow/internal/apiclient.py:
##########
@@ -872,6 +874,32 @@ def create_job_description(self, job: Job):
pipeline_proto_hash=pipeline_proto_hash).proto
_LOGGER.debug('JOB: %s', job)
+ def _warn_if_staging_bucket_has_ttl(self, staging_location):
+ """Warns when the staging bucket deletes objects by age."""
+ if not staging_location or not staging_location.startswith('gs://'):
+ return
+ bucket_name = staging_location[len('gs://'):].split('/', 1)[0]
+ try:
+ bucket = self._storage_client.get_bucket(bucket_name)
+ except Exception as e: # pylint: disable=broad-except
+ _LOGGER.debug(
+ 'Unable to check lifecycle rules of staging bucket %s: %s',
+ bucket_name,
+ e)
+ return
+ if bucket is None:
+ return
+ for rule in bucket.lifecycle_rules or []:
+ condition = rule.get('condition', {})
+ if rule.get('action', {}).get('type') == 'Delete' and 'age' in condition:
Review 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.
```suggestion
if (rule.get('action', {}).get('type') == 'Delete' and
condition.get('age') is not None and condition.get('isLive') is not False):
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]