From 80837d4cb84359d1b7bb0c6bb6743f5bb49e27b2 Mon Sep 17 00:00:00 2001 From: jcaiMR <111116206+jcaiMR@users.noreply.github.com> Date: Fri, 25 Nov 2022 20:12:41 +0800 Subject: [PATCH] better solution for STATIC_ROUTE_EXPIRY_TIME check (#12824) --- src/sonic-bgpcfgd/bgpcfgd/static_rt_timer.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/sonic-bgpcfgd/bgpcfgd/static_rt_timer.py b/src/sonic-bgpcfgd/bgpcfgd/static_rt_timer.py index f9b5993fd1f9..060e7d59439c 100644 --- a/src/sonic-bgpcfgd/bgpcfgd/static_rt_timer.py +++ b/src/sonic-bgpcfgd/bgpcfgd/static_rt_timer.py @@ -15,17 +15,15 @@ def __init__(self): MAX_TIMER = 1800 def set_timer(self): - """ Check for custom route expiry time in STATIC_ROUTE:EXPIRY_TIME """ - keys = self.db.keys(self.db.APPL_DB, "STATIC_ROUTE_EXPIRY_TIME") - if len(keys) == 0: - return + """ Check for custom route expiry time in STATIC_ROUTE_EXPIRY_TIME """ timer = self.db.get(self.db.APPL_DB, "STATIC_ROUTE_EXPIRY_TIME", "time") if timer is not None: - timer = int(timer) - if timer > 0 and timer <= self.MAX_TIMER: - self.timer = timer - return - log_err("Custom static route expiry time of {}s is invalid!".format(timer)) + if timer.isdigit(): + timer = int(timer) + if timer > 0 and timer <= self.MAX_TIMER: + self.timer = timer + return + log_err("Custom static route expiry time of {}s is invalid!".format(timer)) return def alarm(self):