Skip to content

Commit

Permalink
Fixes bug for PFCWD feature parameters (#838)
Browse files Browse the repository at this point in the history
What I did

The feature allows setting 'detection_time', 'restoration_time' and 'pollling_interval' PFCWD to an interface. The 'pollling_interval' must be lower than 'detection_time' and 'restoration_time'.
The fix is checking if there is a lower value of 'detection_time' or 'restoration_time' than the 'pollling_interval' value entered by the user in config DB, if yes exit with error code 1.

How I did it
Checking the config DB for interfaces PFCWD values.

How to verify it
Try adding 'pollling_interval' greater than one of the values of PFCWD interfaces.

Previous command output (if the output of a command-line utility has changed)
No Output.

New command output (if the output of a command-line utility has changed)
unable to use polling_interval = #ms, value is bigger or equal to the minimum in PFCWD table
  • Loading branch information
shlomibitton authored and abdosi committed Jun 16, 2020
1 parent fa50fd7 commit 370b906
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions pfcwd/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import click
import swsssdk
import os
import sys
from tabulate import tabulate
from natsort import natsorted

Expand Down Expand Up @@ -194,9 +195,25 @@ 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 < 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
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

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()
Expand Down

0 comments on commit 370b906

Please sign in to comment.