From e07ad4a570c6588323bac0a5417167e4fd690b28 Mon Sep 17 00:00:00 2001 From: Ksenija Stanojevic Date: Tue, 9 May 2023 14:21:50 -0700 Subject: Remove mount NTFS error message (#2134) Provide an option to suppress error logging from mount_cb as some errors can be expected error and handled appropriately by DataSources. For example: failure to mount NTFS volumes on VMs that do not have NTFS drivers. --- cloudinit/sources/DataSourceAzure.py | 1 + cloudinit/util.py | 26 ++++++++++++++++---------- 2 files changed, 17 insertions(+), 10 deletions(-) (limited to 'cloudinit') diff --git a/cloudinit/sources/DataSourceAzure.py b/cloudinit/sources/DataSourceAzure.py index 923644e1..863a06b5 100644 --- a/cloudinit/sources/DataSourceAzure.py +++ b/cloudinit/sources/DataSourceAzure.py @@ -1596,6 +1596,7 @@ def can_dev_be_reformatted(devpath, preserve_ntfs): count_files, mtype="ntfs", update_env_for_mount={"LANG": "C"}, + log_error=False, ) except util.MountFailedError as e: evt.description = "cannot mount ntfs" diff --git a/cloudinit/util.py b/cloudinit/util.py index b0d2ddb0..7651ae67 100644 --- a/cloudinit/util.py +++ b/cloudinit/util.py @@ -1908,7 +1908,12 @@ def mounts(): def mount_cb( - device, callback, data=None, mtype=None, update_env_for_mount=None + device, + callback, + data=None, + mtype=None, + update_env_for_mount=None, + log_error=True, ): """ Mount the device, call method 'callback' passing the directory @@ -1968,15 +1973,16 @@ def mount_cb( mountpoint = tmpd break except (IOError, OSError) as exc: - LOG.debug( - "Failed to mount device: '%s' with type: '%s' " - "using mount command: '%s', " - "which caused exception: %s", - device, - mtype, - " ".join(mountcmd), - exc, - ) + if log_error: + LOG.debug( + "Failed to mount device: '%s' with type: '%s' " + "using mount command: '%s', " + "which caused exception: %s", + device, + mtype, + " ".join(mountcmd), + exc, + ) failure_reason = exc if not mountpoint: raise MountFailedError( -- cgit v1.2.1