]> git.proxmox.com Git - mirror_ifupdown2.git/commitdiff
log: add extra try except when removing log dirs and fix eni.d cp
authorJulien Fortin <jfortin@nvidia.com>
Tue, 28 Dec 2021 21:47:48 +0000 (22:47 +0100)
committerJulien Fortin <jfortin@nvidia.com>
Thu, 26 May 2022 10:26:17 +0000 (12:26 +0200)
The extra try/except are necessary just in case something goes wrong
we still want to go through the entire list of extra log dir present
on the system.

Signed-off-by: Julien Fortin <jfortin@nvidia.com>
ifupdown2/lib/log.py

index ca30d4d55a47cccbeebf6103a0f0c2352aaa5151..c0bf084dad1441ab09424989cdc90aa7dc55f749 100644 (file)
@@ -193,16 +193,19 @@ class LogManager:
         # cp ENI and ENI.d in the log directory
         shutil.copy2("/etc/network/interfaces", new_dir_path)
         try:
-            shutil.copytree("/etc/network/interfaces.d/", new_dir_path)
-        except FileNotFoundError:
+            shutil.copytree("/etc/network/interfaces.d/", "%s/interfaces.d" % new_dir_path)
+        except Exception:
             pass
 
         # remove extra directory logs if we are reaching the 'user_config_limit'
         len_ifupdown2_log_dirs = len(ifupdown2_log_dirs)
         if len_ifupdown2_log_dirs > user_config_limit:
             for index in range(0, len_ifupdown2_log_dirs - user_config_limit):
-                directory_to_remove = "%s/%s%s_%s" % (self.LOGGING_DIRECTORY, self.LOGGING_DIRECTORY_PREFIX, ifupdown2_log_dirs[index][0], ifupdown2_log_dirs[index][1])
-                shutil.rmtree(directory_to_remove, ignore_errors=True)
+                try:
+                    directory_to_remove = "%s/%s%s_%s" % (self.LOGGING_DIRECTORY, self.LOGGING_DIRECTORY_PREFIX, ifupdown2_log_dirs[index][0], ifupdown2_log_dirs[index][1])
+                    shutil.rmtree(directory_to_remove, ignore_errors=True)
+                except:
+                    pass
 
     @staticmethod
     def __create_dir(path):