summaryrefslogtreecommitdiff
path: root/cloudinit/reporting/handlers.py
diff options
context:
space:
mode:
authorChris Patterson <cpatterson@microsoft.com>2023-04-25 13:14:45 -0400
committerGitHub <noreply@github.com>2023-04-25 12:14:45 -0500
commit6e380dd68c32555d54f6ecbd9adff0b3248b679d (patch)
tree9add4a30751890b169f785b2a7f028deec1de3de /cloudinit/reporting/handlers.py
parent34637a49df13a054c4355de675b7cf286450b2f5 (diff)
downloadcloud-init-git-6e380dd68c32555d54f6ecbd9adff0b3248b679d.tar.gz
sources/azure: report failures to host via kvp (#2136)
Azure can report provisioning failures via the Wireserver health endpoint. However, in the event of networking failures or Wireserver issues, this report cannot be made and the VM will result in an OS provisioning timeout and a generic error is presented to the user. Report the failure via KVP using the "PROVISIONING_REPORT" key so that the host can relay the provisioning error report to the user when the VM fails to provision. The format used is subject to change and/or removal. Signed-off-by: Chris Patterson <cpatterson@microsoft.com>
Diffstat (limited to 'cloudinit/reporting/handlers.py')
-rw-r--r--cloudinit/reporting/handlers.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/cloudinit/reporting/handlers.py b/cloudinit/reporting/handlers.py
index 2c1f4998..ff07f940 100644
--- a/cloudinit/reporting/handlers.py
+++ b/cloudinit/reporting/handlers.py
@@ -347,6 +347,21 @@ class HyperVKvpReportingHandler(ReportingHandler):
break
return result_array
+ def write_key(self, key: str, value: str) -> None:
+ """Write KVP key-value.
+
+ Values will be truncated as needed.
+ """
+ if len(value) >= self.HV_KVP_AZURE_MAX_VALUE_SIZE:
+ value = value[0 : self.HV_KVP_AZURE_MAX_VALUE_SIZE - 1]
+
+ data = [self._encode_kvp_item(key, value)]
+
+ try:
+ self._append_kvp_item(data)
+ except (OSError, IOError):
+ LOG.warning("failed posting kvp=%s value=%s", key, value)
+
def _encode_event(self, event):
"""
encode the event into kvp data bytes.