From 9dd28489339fb5e5c940afee74d1dfdb3c53cd46 Mon Sep 17 00:00:00 2001 From: InspurSDN <57648884+inspurSDN@users.noreply.github.com> Date: Fri, 1 Nov 2024 07:35:37 +0800 Subject: [PATCH] trap_rates.lua get value error (#3219) 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 --- orchagent/trap_rates.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/orchagent/trap_rates.lua b/orchagent/trap_rates.lua index 69b9c5cd3f..a20f62b9d0 100644 --- a/orchagent/trap_rates.lua +++ b/orchagent/trap_rates.lua @@ -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