Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
Add mechanism to get the linecard_reboot_timeout value from platform_env.conf file.
This provides capabilitiy to different platform can have a different timeout value
  • Loading branch information
mlok-nokia committed May 3, 2024
1 parent 8a214aa commit 918461f
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions sonic-chassisd/scripts/chassisd
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ CHASSIS_MODULE_INFO_HOSTNAME_FIELD = 'hostname'
CHASSIS_MODULE_REBOOT_INFO_TABLE = 'CHASSIS_MODULE_REBOOT_INFO_TABLE'
CHASSIS_MODULE_REBOOT_TIMESTAMP_FIELD = 'timestamp'
CHASSIS_MODULE_REBOOT_REBOOT_FIELD = 'reboot'
REBOOT_SYSTEM_UP_WARNING_TIMEOUT = 180
DEFAULT_LINECARD_REBOOT_TIMEOUT = 180
PLATFORM_ENV_CONF_FILE = "/usr/share/sonic/platform/platform_env.conf"

CHASSIS_INFO_UPDATE_PERIOD_SECS = 10
CHASSIS_DB_CLEANUP_MODULE_DOWN_PERIOD = 30 # Minutes
Expand Down Expand Up @@ -207,6 +208,14 @@ class ModuleUpdater(logger.Logger):
self.down_modules = {}
self.chassis_app_db_clean_sha = None

self.linecard_reboot_timeout = DEFAULT_LINECARD_REBOOT_TIMEOUT
if os.path.isfile(PLATFORM_ENV_CONF_FILE):
with open(PLATFORM_ENV_CONF_FILE, 'r') as file:
for line in file:
field = line.split('=')[0].strip()
if field == "linecard_reboot_timeout":
self.linecard_reboot_timeout = int(line.split('=')[1].strip())

self.midplane_initialized = try_get(chassis.init_midplane_switch, default=False)
if not self.midplane_initialized:
self.log_error("Chassisd midplane intialization failed")
Expand Down Expand Up @@ -388,7 +397,7 @@ class ModuleUpdater(logger.Logger):
if CHASSIS_MODULE_REBOOT_TIMESTAMP_FIELD in fvs.keys():
timestamp= float(fvs[CHASSIS_MODULE_REBOOT_TIMESTAMP_FIELD])
time_now = time.time()
if time_now - timestamp >= REBOOT_SYSTEM_UP_WARNING_TIMEOUT:
if time_now - timestamp >= self.linecard_reboot_timeout:
self.module_reboot_table._del(key)
return True
return False
Expand Down Expand Up @@ -438,7 +447,7 @@ class ModuleUpdater(logger.Logger):
self.module_reboot_table._del(module_key)
elif midplane_access is False and current_midplane_state == 'False':
if self.is_module_reboot_system_up_expired(module_key):
self.log_warning("Unexpected: Module {} midplane connectivity is not restored in 3 minutes".format(module_key))
self.log_warning("Unexpected: Module {} midplane connectivity is not restored in {} seconds".format(module_key, self.linecard_reboot_timeout))

# Update db with midplane information
fvs = swsscommon.FieldValuePairs([(CHASSIS_MIDPLANE_INFO_IP_FIELD, midplane_ip),
Expand Down

0 comments on commit 918461f

Please sign in to comment.