Skip to content

Commit

Permalink
comments
Browse files Browse the repository at this point in the history
  • Loading branch information
holmanb committed Jun 11, 2024
1 parent 3376535 commit d68eb04
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 10 deletions.
4 changes: 2 additions & 2 deletions cloudinit/analyze/show.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
2 changes: 1 addition & 1 deletion cloudinit/cmd/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 6 additions & 0 deletions cloudinit/config/cc_growpart.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
4 changes: 3 additions & 1 deletion cloudinit/net/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
8 changes: 2 additions & 6 deletions cloudinit/sources/DataSourceAzure.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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",
Expand All @@ -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 {}
Expand Down

0 comments on commit d68eb04

Please sign in to comment.