You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by fo...@apache.org on 2017/11/10 08:11:33 UTC

incubator-airflow git commit: [AIRFLOW-1563] Catch OSError while symlinking the latest log directory

Repository: incubator-airflow
Updated Branches:
  refs/heads/master f5f770125 -> faa9a5266


[AIRFLOW-1563] Catch OSError while symlinking the latest log directory

Closes #2564 from NielsZeilemaker/AIRFLOW-1563


Project: http://git-wip-us.apache.org/repos/asf/incubator-airflow/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-airflow/commit/faa9a526
Tree: http://git-wip-us.apache.org/repos/asf/incubator-airflow/tree/faa9a526
Diff: http://git-wip-us.apache.org/repos/asf/incubator-airflow/diff/faa9a526

Branch: refs/heads/master
Commit: faa9a5266c0b2e68693dd106b5cb46d30770dadc
Parents: f5f7701
Author: Niels Zeilemaker <ni...@godatadriven.com>
Authored: Fri Nov 10 09:03:00 2017 +0100
Committer: Fokko Driesprong <fo...@godatadriven.com>
Committed: Fri Nov 10 09:03:00 2017 +0100

----------------------------------------------------------------------
 airflow/utils/log/file_processor_handler.py | 28 ++++++++++++++----------
 1 file changed, 16 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-airflow/blob/faa9a526/airflow/utils/log/file_processor_handler.py
----------------------------------------------------------------------
diff --git a/airflow/utils/log/file_processor_handler.py b/airflow/utils/log/file_processor_handler.py
index cd03a2a..8559e38 100644
--- a/airflow/utils/log/file_processor_handler.py
+++ b/airflow/utils/log/file_processor_handler.py
@@ -100,19 +100,23 @@ class FileProcessorHandler(logging.Handler):
         log_directory = self._get_log_directory()
         latest_log_directory_path = os.path.join(self.base_log_folder, "latest")
         if os.path.isdir(log_directory):
-            # if symlink exists but is stale, update it
-            if os.path.islink(latest_log_directory_path):
-                if os.readlink(latest_log_directory_path) != log_directory:
-                    os.unlink(latest_log_directory_path)
+            try:
+                # if symlink exists but is stale, update it
+                if os.path.islink(latest_log_directory_path):
+                    if os.readlink(latest_log_directory_path) != log_directory:
+                        os.unlink(latest_log_directory_path)
+                        os.symlink(log_directory, latest_log_directory_path)
+                elif (os.path.isdir(latest_log_directory_path) or
+                          os.path.isfile(latest_log_directory_path)):
+                    self.log.warning(
+                        "%s already exists as a dir/file. Skip creating symlink.",
+                        latest_log_directory_path
+                    )
+                else:
                     os.symlink(log_directory, latest_log_directory_path)
-            elif (os.path.isdir(latest_log_directory_path) or
-                      os.path.isfile(latest_log_directory_path)):
-                self.log.warning(
-                    "%s already exists as a dir/file. Skip creating symlink.",
-                    latest_log_directory_path
-                )
-            else:
-                os.symlink(log_directory, latest_log_directory_path)
+            except OSError:
+                self.logger.warning("OSError while attempting to symlink "
+                                    "the latest log directory")
 
     def _init_file(self, filename):
         """