potiuk commented on code in PR #75566:
URL: https://github.com/apache/airflow/pull/75566#discussion_r4757565468
##########
providers/google/src/airflow/providers/google/cloud/bundles/gcs.py:
##########
@@ -27,46 +32,64 @@
from airflow.providers.google.cloud.hooks.gcs import GCSHook
from airflow.providers.google.common.hooks.base_google import GoogleBaseHook
+if TYPE_CHECKING:
+ from structlog.typing import FilteringBoundLogger
-class GCSDagBundle(BaseDagBundle):
- """
- GCS Dag bundle - exposes a directory in GCS as a Dag bundle.
- This allows Airflow to load Dags directly from a GCS bucket.
+def _require_tar_data_filter() -> None:
+ if hasattr(tarfile, "data_filter"):
+ return
+ raise RuntimeError("Archive Dag bundles require Python 3.11.4 or later
(tarfile filter='data').")
- :param gcp_conn_id: Airflow connection ID for GCS. Defaults to
GoogleBaseHook.default_conn_name.
- :param bucket_name: The name of the GCS bucket containing the Dag files.
- :param prefix: Optional subdirectory within the GCS bucket where the Dags
are stored.
- If None, Dags are assumed to be at the root of the bucket
(Optional).
+
+def _extract_archive(archive_path: Path, unpack_dir: Path) -> None:
Review Comment:
**The S3 bundle's Python check for `filter="data"` is missing here**
`tarfile`'s `filter=` exists from Python 3.11.4, while the provider allows
`>=3.11`. The merged `S3ArchiveDagBundle` calls `_require_tar_data_filter()` in
`__init__` and fails with a clear message; here `extractall(...,
filter="data")` raises a `TypeError` on the first refresh instead. It is the
one place this port diverges from #73015. Bring back the same
`_require_tar_data_filter()` check in `GCSArchiveDagBundle.__init__`.
---
Drafted-by: Claude Code (Opus 5.5); reviewed by @potiuk before posting
##########
providers/google/docs/bundles/index.rst:
##########
@@ -45,3 +45,45 @@ Example of using the GCSDagBundle:
}
}
]'
+
+GCSArchiveDagBundle
+===================
+
+Use :class:`~airflow.providers.google.cloud.bundles.gcs.GCSArchiveDagBundle`
when the Dags are published as
+one ``.tar.gz`` object.
:class:`~airflow.providers.google.cloud.bundles.gcs.GCSDagBundle` downloads
every
+object under ``prefix`` one at a time. Each object costs a full request
round-trip, so bundles made of
+many small files can take a long time to stage — a cost paid by every
component that stages the bundle,
+which with ephemeral workers (e.g. KubernetesExecutor task pods) means on
every task start.
+
+``GCSArchiveDagBundle`` stages the bundle from the ``archive_object``: one
metadata read to detect changes
+(unchanged archives are not re-downloaded when the staged tree still has
files), one download pinned to that
Review Comment:
**The docs promise a check the code does not make**
"unchanged archives are not re-downloaded when the staged tree still has
files" suggests an emptiness check, but the skip only compares the
`.archive_etag` marker, so a tree whose Dag files were removed while the hidden
marker stayed is not staged again until the archive changes (the S3 bundle
behaves the same). Say "when the staged tree's ETag marker matches", or add the
check in both bundles.
*Flagged by both the primary and adversarial reviewers.*
---
Drafted-by: Claude Code (Opus 5.5); reviewed by @potiuk before posting
--
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]