Skip to content

Commit

Permalink
Merge pull request ceph#294 from gbregman/devel
Browse files Browse the repository at this point in the history
When comparing state values in update() make sure both values are the same type
  • Loading branch information
gbregman authored Oct 26, 2023
2 parents 4e7b0c7 + 5741870 commit e1c4c57
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion control/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,12 @@ def _update_caller(self, notify_event):
notify_event.wait(max(update_time - time.time(), 0))
notify_event.clear()

def compare_state_values(self, val1, val2) -> bool:
# We sometimes get one value as type bytes and the other as type str, so convert them both to str for the comparison
val1_str = val1.decode() if type(val1) == type(b'') else val1
val2_str = val2.decode() if type(val2) == type(b'') else val2
return val1_str == val2_str

def update(self):
"""Checks for updated omap state and initiates local update."""
prefix_list = [
Expand All @@ -457,7 +463,7 @@ def update(self):
changed = {
key: omap_state_dict[key]
for key in same_keys
if omap_state_dict[key] != local_state_dict[key]
if not self.compare_state_values(local_state_dict[key], omap_state_dict[key])
}
grouped_changed = self._group_by_prefix(changed, prefix_list)
# Find OMAP removals
Expand Down

0 comments on commit e1c4c57

Please sign in to comment.