diff --git a/cloudinit/analyze/show.py b/cloudinit/analyze/show.py index fdb940311525..6ffcce63853b 100644 --- a/cloudinit/analyze/show.py +++ b/cloudinit/analyze/show.py @@ -220,10 +220,10 @@ def gather_timestamps_using_dmesg(): # so we cannot get that timestamp return SUCCESS_CODE, kernel_start, kernel_end, kernel_end except (ValueError, subp.ProcessExecutionError): - return TIMESTAMP_UNKNOWN + pass except Exception as e: LOG.warning("Unhandled exception: %s", e) - return TIMESTAMP_UNKNOWN + return TIMESTAMP_UNKNOWN def gather_timestamps_using_systemd(): diff --git a/cloudinit/cmd/main.py b/cloudinit/cmd/main.py index 3f8c5fa0b0b8..c3e7739f7259 100644 --- a/cloudinit/cmd/main.py +++ b/cloudinit/cmd/main.py @@ -746,7 +746,7 @@ def status_wrapper(name, args): try: status = json.loads(util.load_text_file(status_path)) except OSError: - LOG.warning("File %s not found %s.", status_path, mode) + LOG.debug("File %s not found %s.", status_path, mode) except json.JSONDecodeError as e: LOG.warning("File %s not valid json %s: %s", status_path, mode, e) except Exception as e: diff --git a/cloudinit/config/cc_growpart.py b/cloudinit/config/cc_growpart.py index 2d8618e586c7..662f1b0c6ae3 100644 --- a/cloudinit/config/cc_growpart.py +++ b/cloudinit/config/cc_growpart.py @@ -380,6 +380,12 @@ def resize_encrypted(blockdev, partition) -> Tuple[str, str]: "Could not load encryption key. This is expected if " "the volume has been previously resized." ) from e + except Exception as e: + LOG.warning("Unhandled exception: %s", e) + raise RuntimeError( + "Could not load encryption key. This is expected if " + "the volume has been previously resized." + ) from e try: subp.subp( diff --git a/cloudinit/net/__init__.py b/cloudinit/net/__init__.py index e5e41e6c7368..951f98d6e08c 100644 --- a/cloudinit/net/__init__.py +++ b/cloudinit/net/__init__.py @@ -209,8 +209,10 @@ def get_dev_features(devname): features = "" try: features = read_sys_net(devname, "device/features") - except OSError: + except (OSError, UnicodeError): pass + except Exception as e: + LOG.warning("Unhandled exception: %s", e) return features diff --git a/cloudinit/sources/DataSourceAzure.py b/cloudinit/sources/DataSourceAzure.py index 8f500afde67a..e56e9e0c34c2 100644 --- a/cloudinit/sources/DataSourceAzure.py +++ b/cloudinit/sources/DataSourceAzure.py @@ -867,9 +867,8 @@ def _get_data(self): except errors.ReportableError as error: self._report_failure(error) return False - except Exception as e: - LOG.warning("Unhandled exception: %s", e) - reportable_error = errors.ReportableErrorUnhandledException(e) + except Exception as error: + reportable_error = errors.ReportableErrorUnhandledException(error) self._report_failure(reportable_error) return False finally: @@ -1338,7 +1337,6 @@ def _report_failure( logger_func=LOG.error, ) except Exception as e: - LOG.warning("Unhandled exception: %s", e) report_diagnostic_event( "Failed to report failure using " "cached ephemeral dhcp context: %s" % e, @@ -1520,7 +1518,6 @@ def _generate_network_config(self): ), ) except Exception as e: - LOG.warning("Unhandled exception: %s", e) LOG.error( "Failed generating network config " "from IMDS network metadata: %s", @@ -1531,7 +1528,6 @@ def _generate_network_config(self): try: return _generate_network_config_from_fallback_config() except Exception as e: - LOG.warning("Unhandled exception: %s", e) LOG.error("Failed generating fallback network config: %s", str(e)) return {}