summaryrefslogtreecommitdiff
path: root/cloudinit/sources/azure/errors.py
diff options
context:
space:
mode:
authorChris Patterson <cpatterson@microsoft.com>2023-05-11 11:43:13 -0700
committerGitHub <noreply@github.com>2023-05-11 13:43:13 -0500
commit481bf4d3c3460fe398c74c950eb02f8562e1c20a (patch)
treede8487d377980ba69c62e40afb36265968485c5f /cloudinit/sources/azure/errors.py
parent0c4d53f2b756c8ecc3c17e3403ba66ebb5ce1560 (diff)
downloadcloud-init-git-481bf4d3c3460fe398c74c950eb02f8562e1c20a.tar.gz
azure/errors: add host reporting for dhcp errors (#2167)
- Add host_only flag to _report_failure() to allow caller to only report the failure to host. This is for cases where we don't want _report_failure() to attempt DHCP or we expect that we may recover from the reported error (there is no issue reporting multiple times to host, whereas fabric reports will immediately fail the VM provisioning). - Add ReportableErrorDhcpLease() to report lease failures. - Add ReportableErrorDhcpInterfaceNotFound() to report errors where the DHCP interface hasn't been found yet. - Add TestReportFailure class with new test coverage. Will migrate other _report_failure() tests in the future as they currently depend on TestAzureDataSource/CiTestCase. Future work will add the interface name to supporting data, but as that information is not available with iface=None, another PR will explicitly add a call to net.find_fallback_nic() to specify it. Signed-off-by: Chris Patterson <cpatterson@microsoft.com>
Diffstat (limited to 'cloudinit/sources/azure/errors.py')
-rw-r--r--cloudinit/sources/azure/errors.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/cloudinit/sources/azure/errors.py b/cloudinit/sources/azure/errors.py
index 5c4ad7db..ca902a03 100644
--- a/cloudinit/sources/azure/errors.py
+++ b/cloudinit/sources/azure/errors.py
@@ -84,6 +84,21 @@ class ReportableError(Exception):
return self.as_encoded_report()
+class ReportableErrorDhcpInterfaceNotFound(ReportableError):
+ def __init__(self, duration: float) -> None:
+ super().__init__("failure to find DHCP interface")
+
+ self.supporting_data["duration"] = duration
+
+
+class ReportableErrorDhcpLease(ReportableError):
+ def __init__(self, duration: float, interface: Optional[str]) -> None:
+ super().__init__("failure to obtain DHCP lease")
+
+ self.supporting_data["duration"] = duration
+ self.supporting_data["interface"] = interface
+
+
class ReportableErrorUnhandledException(ReportableError):
def __init__(self, exception: Exception) -> None:
super().__init__("unhandled exception")