Skip to content

Commit

Permalink
[watermarkstat] Fix for error in processing empty array from couters …
Browse files Browse the repository at this point in the history
…db (#1810)

With switch to swsscommon, the get operations return NULL ('') if there
are no entries in any table. But the existing code for handling counters
values in the case of absence of entries assumes that the get operations
return 'None', which was the case with swsssdk. This was causing
problem.

For PG_WATERMARK_STAT_COUNTER SAI does not support
SAI_INGRESS_PRIORITY_GROUP_STAT_XOFF_ROOM_WATERMARK_BYTES and
SAI_INGRESS_PRIORITY_GROUP_STAT_SHARED_WATERMARK_BYTES. So there are no
objects in the counters db. With swsscommon, in the absence of objects,
an empty string ('') is returned instead of 'None'. The code expecting
'None' tries to converts the empty string to integer and throws error.
This is fixed by adding check for empty string in addition to 'None'.

Signed-off-by: vedganes <vedavinayagam.ganesan@nokia.com>
  • Loading branch information
vganesan-nokia authored Oct 27, 2021
1 parent 0b2536b commit f53baac
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion scripts/watermarkstat
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ class Watermarkstat(object):
idx = int(idx_func(obj_id))
pos = idx - self.min_idx
counter_data = self.counters_db.get(self.counters_db.COUNTERS_DB, full_table_id, watermark)
if counter_data is None:
if counter_data is None or counter_data == '':
fields[pos] = STATUS_NA
elif fields[pos] != STATUS_NA:
fields[pos] = str(int(counter_data))
Expand Down

0 comments on commit f53baac

Please sign in to comment.