← Back to team overview

cloud-init-dev team mailing list archive

[Merge] ~momousta/cloud-init:momoustamsft/UniqueKeysForKVPs into cloud-init:master

 

Moustafa Moustafa has proposed merging ~momousta/cloud-init:momoustamsft/UniqueKeysForKVPs into cloud-init:master.

Commit message:
The KVPs currently being emitted to the .kvp_poolx file can have duplicate keys which is wrong since these keys should be unique. The situation can occur if for example one azure function called twice or more and this function is reporting telemetry through the use of KVPs. Any KVP consumer can get confused by the duplicate keys and a race condition can and have occurred.

Requested reviews:
  cloud-init Commiters (cloud-init-dev)

For more details, see:
https://code.launchpad.net/~momousta/cloud-init/+git/cloud-init/+merge/375226

Adding the timestamp as part of the KVP key to guarantee the KVP key uniqueness. 
-- 
Your team cloud-init Commiters is requested to review the proposed merge of ~momousta/cloud-init:momoustamsft/UniqueKeysForKVPs into cloud-init:master.
diff --git a/cloudinit/reporting/handlers.py b/cloudinit/reporting/handlers.py
index 10165ae..037e0ed 100755
--- a/cloudinit/reporting/handlers.py
+++ b/cloudinit/reporting/handlers.py
@@ -201,10 +201,11 @@ class HyperVKvpReportingHandler(ReportingHandler):
     def _event_key(self, event):
         """
         the event key format is:
-        CLOUD_INIT|<incarnation number>|<event_type>|<event_name>
+        CLOUD_INIT|<incarnation number>|<event_type>|<event_name>|<time>
         """
-        return u"{0}|{1}|{2}".format(self.event_key_prefix,
-                                     event.event_type, event.name)
+        return u"{0}|{1}|{2}|{3}".format(self.event_key_prefix,
+                                         event.event_type, event.name,
+                                         event.timestamp)
 
     def _encode_kvp_item(self, key, value):
         data = (struct.pack("%ds%ds" % (

Follow ups