From 82c59360621a590085ed110f828c2c0fed9ace50 Mon Sep 17 00:00:00 2001 From: Shlomi Bitton Date: Sun, 1 Mar 2020 21:52:13 +0200 Subject: [PATCH 1/6] Bug fix for PFCWD Signed-off-by: Shlomi Bitton --- pfcwd/main.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/pfcwd/main.py b/pfcwd/main.py index 880a5f33f8..8b59dda880 100644 --- a/pfcwd/main.py +++ b/pfcwd/main.py @@ -3,6 +3,7 @@ import click import swsssdk import os +import random from tabulate import tabulate from natsort import natsorted @@ -194,8 +195,24 @@ def interval(poll_interval): configdb.connect() pfcwd_info = {} if poll_interval is not None: + pfcwd_table = configdb.get_table(CONFIG_DB_PFC_WD_TABLE_NAME) + entry_min = 3000 + for entry in pfcwd_table: + if("Ethernet" not in entry): + continue + detection_time_entry_value = int(configdb.get_entry(CONFIG_DB_PFC_WD_TABLE_NAME, entry).get('detection_time')) + restoration_time_entry_value = int(configdb.get_entry(CONFIG_DB_PFC_WD_TABLE_NAME, entry).get('restoration_time')) + if ((detection_time_entry_value != None) and (detection_time_entry_value < min)): + entry_min = detection_time_entry_value + res_str = "detection_time" + if ((restoration_time_entry_value != None) and (restoration_time_entry_value < min)): + entry_min = restoration_time_entry_value + res_str = "restoration_time" + if entry_min < poll_interval: + poll_interval = random.randint(1,entry_min-1) + print "polling_interval is greater than {}, using polling_interval = {}ms".format(res_str,poll_interval) + pfcwd_info['POLL_INTERVAL'] = poll_interval - configdb.mod_entry(CONFIG_DB_PFC_WD_TABLE_NAME, "GLOBAL", pfcwd_info) # Stop WD From 7738ffcc73cca209feea7ebd8aee07d17646ca8f Mon Sep 17 00:00:00 2001 From: Shlomi Bitton Date: Thu, 12 Mar 2020 14:10:05 +0200 Subject: [PATCH 2/6] Change polling value from random to minimum --- pfcwd/main.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pfcwd/main.py b/pfcwd/main.py index 8b59dda880..f598b253ba 100644 --- a/pfcwd/main.py +++ b/pfcwd/main.py @@ -202,14 +202,14 @@ def interval(poll_interval): continue detection_time_entry_value = int(configdb.get_entry(CONFIG_DB_PFC_WD_TABLE_NAME, entry).get('detection_time')) restoration_time_entry_value = int(configdb.get_entry(CONFIG_DB_PFC_WD_TABLE_NAME, entry).get('restoration_time')) - if ((detection_time_entry_value != None) and (detection_time_entry_value < min)): + if ((detection_time_entry_value != None) and (detection_time_entry_value < entry_min)): entry_min = detection_time_entry_value res_str = "detection_time" - if ((restoration_time_entry_value != None) and (restoration_time_entry_value < min)): + if ((restoration_time_entry_value != None) and (restoration_time_entry_value < entry_min)): entry_min = restoration_time_entry_value res_str = "restoration_time" if entry_min < poll_interval: - poll_interval = random.randint(1,entry_min-1) + poll_interval = entry_min - 1 print "polling_interval is greater than {}, using polling_interval = {}ms".format(res_str,poll_interval) pfcwd_info['POLL_INTERVAL'] = poll_interval From b5dde41a656f4f108e28499a531ba2dafb5fb26f Mon Sep 17 00:00:00 2001 From: Shlomi Bitton Date: Sun, 15 Mar 2020 11:34:12 +0200 Subject: [PATCH 3/6] remove unused import, validating 'poll_interval' value --- pfcwd/main.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pfcwd/main.py b/pfcwd/main.py index f598b253ba..a2d94088b3 100644 --- a/pfcwd/main.py +++ b/pfcwd/main.py @@ -3,7 +3,6 @@ import click import swsssdk import os -import random from tabulate import tabulate from natsort import natsorted @@ -213,7 +212,10 @@ def interval(poll_interval): print "polling_interval is greater than {}, using polling_interval = {}ms".format(res_str,poll_interval) pfcwd_info['POLL_INTERVAL'] = poll_interval - configdb.mod_entry(CONFIG_DB_PFC_WD_TABLE_NAME, "GLOBAL", pfcwd_info) + if(poll_interval < 100): + print "unable to use polling_interval = {}ms, value is less than 100".format(poll_interval) + else: + configdb.mod_entry(CONFIG_DB_PFC_WD_TABLE_NAME, "GLOBAL", pfcwd_info) # Stop WD @cli.command() From d5a1a4489bf458f908c2983056313385216307e8 Mon Sep 17 00:00:00 2001 From: Shlomi Bitton Date: Wed, 25 Mar 2020 11:29:29 +0200 Subject: [PATCH 4/6] Exit if value is bigger than minimum --- pfcwd/main.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/pfcwd/main.py b/pfcwd/main.py index a2d94088b3..856825708b 100644 --- a/pfcwd/main.py +++ b/pfcwd/main.py @@ -3,6 +3,7 @@ import click import swsssdk import os +import sys from tabulate import tabulate from natsort import natsorted @@ -203,19 +204,14 @@ def interval(poll_interval): restoration_time_entry_value = int(configdb.get_entry(CONFIG_DB_PFC_WD_TABLE_NAME, entry).get('restoration_time')) if ((detection_time_entry_value != None) and (detection_time_entry_value < entry_min)): entry_min = detection_time_entry_value - res_str = "detection_time" if ((restoration_time_entry_value != None) and (restoration_time_entry_value < entry_min)): entry_min = restoration_time_entry_value - res_str = "restoration_time" - if entry_min < poll_interval: - poll_interval = entry_min - 1 - print "polling_interval is greater than {}, using polling_interval = {}ms".format(res_str,poll_interval) + if entry_min <= poll_interval: + print >> sys.stderr, "unable to use polling_interval = {}ms, value is bigger or equal to the minimum in PFCWD table".format(poll_interval) + exit(1) pfcwd_info['POLL_INTERVAL'] = poll_interval - if(poll_interval < 100): - print "unable to use polling_interval = {}ms, value is less than 100".format(poll_interval) - else: - configdb.mod_entry(CONFIG_DB_PFC_WD_TABLE_NAME, "GLOBAL", pfcwd_info) + configdb.mod_entry(CONFIG_DB_PFC_WD_TABLE_NAME, "GLOBAL", pfcwd_info) # Stop WD @cli.command() From a25d699df268a75194a2cc4e8b312469c293b042 Mon Sep 17 00:00:00 2001 From: Shlomi Bitton Date: Sun, 29 Mar 2020 11:52:42 +0300 Subject: [PATCH 5/6] remove '=' and edit error msg to be more clear --- pfcwd/main.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pfcwd/main.py b/pfcwd/main.py index 856825708b..7c0eaa0c83 100644 --- a/pfcwd/main.py +++ b/pfcwd/main.py @@ -204,10 +204,12 @@ def interval(poll_interval): restoration_time_entry_value = int(configdb.get_entry(CONFIG_DB_PFC_WD_TABLE_NAME, entry).get('restoration_time')) if ((detection_time_entry_value != None) and (detection_time_entry_value < entry_min)): entry_min = detection_time_entry_value + entry_min_str = "detection_time" if ((restoration_time_entry_value != None) and (restoration_time_entry_value < entry_min)): entry_min = restoration_time_entry_value - if entry_min <= poll_interval: - print >> sys.stderr, "unable to use polling_interval = {}ms, value is bigger or equal to the minimum in PFCWD table".format(poll_interval) + entry_min_str = "restoration_time" + if entry_min < poll_interval: + print >> sys.stderr, "unable to use polling_interval = {}ms, value is bigger than one of the configured {} values, please choose a smaller polling_interval".format(poll_interval,entry_min_str) exit(1) pfcwd_info['POLL_INTERVAL'] = poll_interval From 3c23191a5519f7e527814439f57591f0ebd91b39 Mon Sep 17 00:00:00 2001 From: Shlomi Bitton Date: Sun, 5 Apr 2020 11:30:45 +0300 Subject: [PATCH 6/6] changed user msg --- pfcwd/main.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pfcwd/main.py b/pfcwd/main.py index 7c0eaa0c83..c0e10c3402 100644 --- a/pfcwd/main.py +++ b/pfcwd/main.py @@ -204,12 +204,12 @@ def interval(poll_interval): restoration_time_entry_value = int(configdb.get_entry(CONFIG_DB_PFC_WD_TABLE_NAME, entry).get('restoration_time')) if ((detection_time_entry_value != None) and (detection_time_entry_value < entry_min)): entry_min = detection_time_entry_value - entry_min_str = "detection_time" + entry_min_str = "detection time" if ((restoration_time_entry_value != None) and (restoration_time_entry_value < entry_min)): entry_min = restoration_time_entry_value - entry_min_str = "restoration_time" + entry_min_str = "restoration time" if entry_min < poll_interval: - print >> sys.stderr, "unable to use polling_interval = {}ms, value is bigger than one of the configured {} values, please choose a smaller polling_interval".format(poll_interval,entry_min_str) + print >> sys.stderr, "unable to use polling interval = {}ms, value is bigger than one of the configured {} values, please choose a smaller polling_interval".format(poll_interval,entry_min_str) exit(1) pfcwd_info['POLL_INTERVAL'] = poll_interval