Skip to content

Commit

Permalink
py3: fix misc encoding issues
Browse files Browse the repository at this point in the history
Fix miscellanous encoding issue when running under Python 3:

 - Encoding of member_id prior to passing into tooz.
 - Decoding of member ID's during response processing
   for status API calls.

(cherry picked from commit 7a3ddc4)
  • Loading branch information
javacruft authored and mergify[bot] committed Jan 12, 2021
1 parent e9fdd6c commit 598b1ea
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
14 changes: 8 additions & 6 deletions gnocchi/cli/metricd.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,14 @@ def wakeup(self):
self._wake_up.set()

def _configure(self):
member_id = "%s.%s.%s" % (socket.gethostname(),
self.worker_id,
# NOTE(jd) Still use a uuid here so we're
# sure there's no conflict in case of
# crash/restart
str(uuid.uuid4()))
member_id = (
"%s.%s.%s" % (socket.gethostname(),
self.worker_id,
# NOTE(jd) Still use a uuid here so we're
# sure there's no conflict in case of
# crash/restart
str(uuid.uuid4()))
).encode()
self.coord = get_coordinator_and_start(member_id,
self.conf.coordination_url)
self.store = storage.get_driver(self.conf)
Expand Down
6 changes: 4 additions & 2 deletions gnocchi/rest/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2099,9 +2099,11 @@ def get(details=True):
metricd.MetricProcessor.GROUP_ID, member)
for member in members
]
report_dict['metricd']['processors'] = members
report_dict['metricd']['processors'] = [
member.decode() for member in members
]
report_dict['metricd']['statistics'] = {
member: cap.get()
member.decode(): cap.get()
for member, cap in six.moves.zip(members, caps)
}
else:
Expand Down
2 changes: 1 addition & 1 deletion gnocchi/rest/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def _lazy_load(self, name):
# entirely.
self.backends[name] = (
metricd.get_coordinator_and_start(
str(uuid.uuid4()),
str(uuid.uuid4()).encode(),
self.conf.coordination_url)
)
elif name == "storage":
Expand Down

0 comments on commit 598b1ea

Please sign in to comment.