Skip to content

Commit 4b1db99

Browse files
jcaiMRStormLiangMS
authored andcommitted
better solution for STATIC_ROUTE_EXPIRY_TIME check (sonic-net#12824)
1 parent 31badbb commit 4b1db99

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

src/sonic-bgpcfgd/bgpcfgd/static_rt_timer.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,15 @@ def __init__(self):
1515
MAX_TIMER = 1800
1616

1717
def set_timer(self):
18-
""" Check for custom route expiry time in STATIC_ROUTE:EXPIRY_TIME """
19-
keys = self.db.keys(self.db.APPL_DB, "STATIC_ROUTE_EXPIRY_TIME")
20-
if len(keys) == 0:
21-
return
18+
""" Check for custom route expiry time in STATIC_ROUTE_EXPIRY_TIME """
2219
timer = self.db.get(self.db.APPL_DB, "STATIC_ROUTE_EXPIRY_TIME", "time")
2320
if timer is not None:
24-
timer = int(timer)
25-
if timer > 0 and timer <= self.MAX_TIMER:
26-
self.timer = timer
27-
return
28-
log_err("Custom static route expiry time of {}s is invalid!".format(timer))
21+
if timer.isdigit():
22+
timer = int(timer)
23+
if timer > 0 and timer <= self.MAX_TIMER:
24+
self.timer = timer
25+
return
26+
log_err("Custom static route expiry time of {}s is invalid!".format(timer))
2927
return
3028

3129
def alarm(self):

0 commit comments

Comments
 (0)