Browse Source

Merge "Byte encoding of member Id" into stable/stein

stable/stein
Zuul 2 weeks ago
parent
commit
43e3b39a64
2 changed files with 8 additions and 1 deletions
  1. 3
    1
      aodh/coordination.py
  2. 5
    0
      aodh/tests/unit/test_coordination.py

+ 3
- 1
aodh/coordination.py View File

@@ -18,6 +18,7 @@ import struct
18 18
 
19 19
 from oslo_config import cfg
20 20
 from oslo_log import log
21
+from oslo_utils import encodeutils
21 22
 from oslo_utils import uuidutils
22 23
 import six
23 24
 import tenacity
@@ -114,7 +115,8 @@ class PartitionCoordinator(object):
114 115
         self.backend_url = self.conf.coordination.backend_url
115 116
         self._coordinator = None
116 117
         self._groups = set()
117
-        self._my_id = my_id or uuidutils.generate_uuid()
118
+        self._my_id = my_id or \
119
+            encodeutils.safe_encode(uuidutils.generate_uuid())
118 120
 
119 121
     def start(self):
120 122
         if self.backend_url:

+ 5
- 0
aodh/tests/unit/test_coordination.py View File

@@ -193,6 +193,11 @@ class TestPartitioning(base.BaseTestCase):
193 193
         self.assertEqual(['group1', 'group2'],
194 194
                          sorted(self.shared_storage.keys()))
195 195
 
196
+    def test_member_id(self):
197
+        agent = 'agent'.encode('ascii')
198
+        coord = self._get_new_started_coordinator({}, agent)
199
+        self.assertEqual(agent, coord._my_id)
200
+
196 201
     def test_partitioning(self):
197 202
         all_resources = ['resource_%s' % i for i in range(1000)]
198 203
         agents = ['agent_%s' % i for i in range(10)]

Loading…
Cancel
Save