jason810496 commented on code in PR #53821:
URL: https://github.com/apache/airflow/pull/53821#discussion_r2271903582


##########
providers/elasticsearch/src/airflow/providers/elasticsearch/log/es_task_handler.py:
##########
@@ -526,22 +542,10 @@ def close(self) -> None:
         # so we know where to stop while auto-tailing.
         self.emit(logging.makeLogRecord({"msg": self.end_of_log_mark}))
 
-        if self.write_stdout:
+        if self.io.write_stdout:
             self.handler.close()
             sys.stdout = sys.__stdout__
 
-        if self.write_to_es and not self.write_stdout:
-            full_path = self.handler.baseFilename  # type: ignore[union-attr]
-            log_relative_path = 
pathlib.Path(full_path).relative_to(self.local_base).as_posix()
-            local_loc = os.path.join(self.local_base, log_relative_path)
-            if os.path.exists(local_loc):
-                # read log and remove old logs to get just the latest additions
-                log = pathlib.Path(local_loc).read_text()
-                log_lines = self._parse_raw_log(log)
-                success = self._write_to_es(log_lines)
-                if success and self.delete_local_copy:
-                    shutil.rmtree(os.path.dirname(local_loc))
-

Review Comment:
   We might still need to test ES provider against Airflow 2, no really sure 
will the logs be upload to ES or not for Airflow 2 here.
   
   It _seems_ we need somehow like:
   ```python
   # rest of the code is still required by Airflow 2
   if not AIRFLOW_V_3_0_PLUS and self.write_to_es and not self.write_stdout:
       full_path = self.handler.baseFilename  # type: ignore[union-attr]
   ```



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