-
Notifications
You must be signed in to change notification settings - Fork 150
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[202211] chassisd: Fix crash on exit on linecard (#352)
* Chassisd do an explicit stop of the config_manager (#328) * Fix to explicit stop the config_manager * Add tests for chassisd run method. * chassisd: Fix crash on exit on linecard Set the `config_manager` variable to `None` if we are running on a linecard and thus don't need to set up the config manager. During cleanup, the chassid service tries to clean up the `config_manager`, but the `config_manager` variable is only ever initialized if we are on the supervisor. Thus, checking if it is `None` is insufficient because this results in an `UnboundLocalError` that prevents the cleanup from succeeding on a linecard. --------- Co-authored-by: judyjoseph <53951155+judyjoseph@users.noreply.github.com>
- Loading branch information
1 parent
4daa748
commit ea8e5c7
Showing
6 changed files
with
89 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
""" | ||
Mock implementation of sonic_platform package for unit testing | ||
""" | ||
|
||
from . import chassis | ||
from . import platform |
26 changes: 26 additions & 0 deletions
26
sonic-chassisd/tests/mocked_libs/sonic_platform/chassis.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
""" | ||
Mock implementation of sonic_platform package for unit testing | ||
""" | ||
|
||
import sys | ||
if sys.version_info.major == 3: | ||
from unittest import mock | ||
else: | ||
import mock | ||
|
||
from sonic_platform_base.chassis_base import ChassisBase | ||
|
||
|
||
class Chassis(ChassisBase): | ||
def __init__(self): | ||
ChassisBase.__init__(self) | ||
self.eeprom = mock.MagicMock() | ||
|
||
def get_eeprom(self): | ||
return self.eeprom | ||
|
||
def get_my_slot(self): | ||
return 1 | ||
|
||
def get_supervisor_slot(self): | ||
return 1 |
12 changes: 12 additions & 0 deletions
12
sonic-chassisd/tests/mocked_libs/sonic_platform/platform.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
""" | ||
Mock implementation of sonic_platform package for unit testing | ||
""" | ||
|
||
from sonic_platform_base.platform_base import PlatformBase | ||
from sonic_platform.chassis import Chassis | ||
|
||
|
||
class Platform(PlatformBase): | ||
def __init__(self): | ||
PlatformBase.__init__(self) | ||
self._chassis = Chassis() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters