From 49a17e758fe7aa4941e323efcbdf3d72866458cb Mon Sep 17 00:00:00 2001 From: Stephen Sun Date: Thu, 18 Jan 2024 08:28:06 +0000 Subject: [PATCH] Fix issue that the Lua script can not be loaded on VS Signed-off-by: Stephen Sun --- orchagent/switchorch.cpp | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/orchagent/switchorch.cpp b/orchagent/switchorch.cpp index 9b899ac13a..630955219c 100644 --- a/orchagent/switchorch.cpp +++ b/orchagent/switchorch.cpp @@ -209,16 +209,24 @@ void SwitchOrch::initAsicSdkHealthEventNotification() set_switch_capability(fvVector); - // Load the Lua script to eliminate oldest entries - string eliminateEventsLuaScript = swss::loadLuaScript("eliminate_events.lua"); - m_eliminateEventsSha = swss::loadRedisScript(m_stateDb.get(), eliminateEventsLuaScript); - - // Init timer - auto interv = timespec { .tv_sec = ASIC_SDK_HEALTH_EVENT_ELIMINATE_INTERVAL, .tv_nsec = 0 }; - m_eliminateEventsTimer = new SelectableTimer(interv); - auto executor = new ExecutableTimer(m_eliminateEventsTimer, this, "ASIC_SDK_HEALTH_EVENT_ELIMINATE_TIMER"); - Orch::addExecutor(executor); - m_eliminateEventsTimer->start(); + try + { + // Load the Lua script to eliminate oldest entries + string eliminateEventsLuaScript = swss::loadLuaScript("eliminate_events.lua"); + m_eliminateEventsSha = swss::loadRedisScript(m_stateDb.get(), eliminateEventsLuaScript); + + // Init timer + auto interv = timespec { .tv_sec = ASIC_SDK_HEALTH_EVENT_ELIMINATE_INTERVAL, .tv_nsec = 0 }; + m_eliminateEventsTimer = new SelectableTimer(interv); + auto executor = new ExecutableTimer(m_eliminateEventsTimer, this, "ASIC_SDK_HEALTH_EVENT_ELIMINATE_TIMER"); + Orch::addExecutor(executor); + m_eliminateEventsTimer->start(); + } + catch (...) + { + // This can happen only on mock test. If it happens on a real switch, we should log an error message + SWSS_LOG_ERROR("Unable to load the Lua script to eliminate events\n"); + } } void SwitchOrch::initAclGroupsBindToSwitch()