aoelvp94 commented on code in PR #73015:
URL: https://github.com/apache/airflow/pull/73015#discussion_r4407457141


##########
providers/amazon/src/airflow/providers/amazon/aws/bundles/s3.py:
##########
@@ -140,6 +170,60 @@ def refresh(self) -> None:
                 delete_stale=True,
             )
 
+    def _refresh_from_archive(self) -> None:
+        """Stage the Dag bundle by downloading and unpacking the single 
archive object."""
+        client = self.s3_hook.get_conn()
+        head = client.head_object(Bucket=self.bucket_name, 
Key=self.archive_key)
+        etag: str = head.get("ETag", "")
+
+        marker = self.s3_dags_dir / self.archive_etag_marker
+        if etag and marker.is_file() and marker.read_text() == etag:
+            self._log.debug(
+                "Dag bundle archive 's3://%s/%s' is unchanged (ETag %s), 
skipping staging",
+                self.bucket_name,
+                self.archive_key,
+                etag,
+            )
+            return
+
+        staging_dir = Path(tempfile.mkdtemp(dir=self.s3_dags_dir.parent, 
prefix=".s3-archive-staging-"))

Review Comment:
   Done in 
[#73015](https://github.com/apache/airflow/pull/73015/commits/69bacb5c8bee33a487d55ed5e35fae1c5cf9d176).
 The staging prefix is now .{bundle name}-archive-staging-. refresh() already 
holds this bundle's lock, and leftover directories with that prefix are removed 
before a new one is created. That cleanup also runs when the ETag is unchanged, 
because a killed process can leave a directory while the marker still matches. 
The match is iterdir plus startswith, so characters in the bundle name stay 
literal.



-- 
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]

Reply via email to