Skip to content

Commit

Permalink
trap_rates.lua get value error (sonic-net#3219)
Browse files Browse the repository at this point in the history
why I did:
    If the SAI_COUNTER_STAT_PACKETS field in the COUNTERS table in the counter db is 0,
    it will be calculated as a Boolean value by trap_rates.lua, resulting in a script operation error.

what I did:
    Force in_pkts to be converted into a numerical value before operation
  • Loading branch information
inspurSDN authored Oct 31, 2024
1 parent 93f7c15 commit 9dd2848
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion orchagent/trap_rates.lua
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ for i = 1, n do
logit(initialized)

-- Get new COUNTERS values
local in_pkts = redis.call('HGET', counters_table_name .. ':' .. KEYS[i], 'SAI_COUNTER_STAT_PACKETS')
local in_pkts_str = redis.call('HGET', counters_table_name .. ':' .. KEYS[i], 'SAI_COUNTER_STAT_PACKETS')
local in_pkts = tonumber(in_pkts_str) or 0

if initialized == 'DONE' or initialized == 'COUNTERS_LAST' then
-- Get old COUNTERS values
Expand Down

0 comments on commit 9dd2848

Please sign in to comment.