summaryrefslogtreecommitdiff
path: root/cloudinit/reporting
diff options
context:
space:
mode:
authormomousta <momousta>2019-11-08 15:02:07 -0600
committerRyan Harper <ryan.harper@canonical.com>2019-11-08 15:02:07 -0600
commit92cc71dec8da73bf43d345418b73db1a32a6b8b9 (patch)
tree578d45b726f809104155bf4263e1039ea8a12dba /cloudinit/reporting
parent8ae0a7030e5e825dd4179761a62fa7f8670df101 (diff)
downloadvyos-cloud-init-92cc71dec8da73bf43d345418b73db1a32a6b8b9.tar.gz
vyos-cloud-init-92cc71dec8da73bf43d345418b73db1a32a6b8b9.zip
reporting: Using a uuid to enforce uniqueness on the KVP keys.
The KVPs currently being emitted to the .kvp_pool 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.
Diffstat (limited to 'cloudinit/reporting')
-rwxr-xr-xcloudinit/reporting/handlers.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/cloudinit/reporting/handlers.py b/cloudinit/reporting/handlers.py
index 10165aec..6605e795 100755
--- a/cloudinit/reporting/handlers.py
+++ b/cloudinit/reporting/handlers.py
@@ -1,6 +1,7 @@
# This file is part of cloud-init. See LICENSE file for license information.
import abc
+import uuid
import fcntl
import json
import six
@@ -201,10 +202,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,
+ uuid.uuid4())
def _encode_kvp_item(self, key, value):
data = (struct.pack("%ds%ds" % (