-
Notifications
You must be signed in to change notification settings - Fork 150
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Collect asic info and store in CHASSIS_STATE_DB #175
Changes from all commits
4473710
81f65ad
5430bbc
917c604
ccd0ad8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,6 +44,13 @@ CHASSIS_MODULE_INFO_NAME_FIELD = 'name' | |
CHASSIS_MODULE_INFO_DESC_FIELD = 'desc' | ||
CHASSIS_MODULE_INFO_SLOT_FIELD = 'slot' | ||
CHASSIS_MODULE_INFO_OPERSTATUS_FIELD = 'oper_status' | ||
CHASSIS_MODULE_INFO_NUM_ASICS_FIELD = 'num_asics' | ||
CHASSIS_MODULE_INFO_ASICS = 'asics' | ||
|
||
CHASSIS_ASIC_INFO_TABLE = 'CHASSIS_ASIC_TABLE' | ||
CHASSIS_ASIC = 'asic' | ||
CHASSIS_ASIC_PCI_ADDRESS_FIELD = 'asic_pci_address' | ||
CHASSIS_ASIC_ID_IN_MODULE_FIELD = 'asic_id_in_module' | ||
|
||
CHASSIS_MIDPLANE_INFO_TABLE = 'CHASSIS_MIDPLANE_TABLE' | ||
CHASSIS_MIDPLANE_INFO_KEY_TEMPLATE = 'CHASSIS_MIDPLANE {}' | ||
|
@@ -163,6 +170,9 @@ class ModuleUpdater(logger.Logger): | |
CHASSIS_MODULE_INFO_SLOT_FIELD, | ||
CHASSIS_MODULE_INFO_OPERSTATUS_FIELD] | ||
|
||
chassis_state_db = daemon_base.db_connect("CHASSIS_STATE_DB") | ||
self.asic_table = swsscommon.Table(chassis_state_db, CHASSIS_ASIC_INFO_TABLE) | ||
|
||
self.midplane_initialized = try_get(chassis.init_midplane_switch, default=False) | ||
if not self.midplane_initialized: | ||
self.log_error("Chassisd midplane intialization failed") | ||
|
@@ -182,6 +192,11 @@ class ModuleUpdater(logger.Logger): | |
if self.chassis_table is not None: | ||
self.chassis_table._del(CHASSIS_INFO_KEY_TEMPLATE.format(1)) | ||
|
||
if self.asic_table is not None: | ||
asics = list(self.asic_table.getKeys()) | ||
for asic in asics: | ||
self.asic_table._del(asic) | ||
|
||
def modules_num_update(self): | ||
# Check if module list is populated | ||
num_modules = self.chassis.get_num_modules() | ||
|
@@ -194,6 +209,8 @@ class ModuleUpdater(logger.Logger): | |
self.chassis_table.set(CHASSIS_INFO_KEY_TEMPLATE.format(1), fvs) | ||
|
||
def module_db_update(self): | ||
notOnlineModules = [] | ||
|
||
for module_index in range(0, self.num_modules): | ||
module_info_dict = self._get_module_info(module_index) | ||
if module_info_dict is not None: | ||
|
@@ -211,9 +228,29 @@ class ModuleUpdater(logger.Logger): | |
fvs = swsscommon.FieldValuePairs([(CHASSIS_MODULE_INFO_DESC_FIELD, module_info_dict[CHASSIS_MODULE_INFO_DESC_FIELD]), | ||
(CHASSIS_MODULE_INFO_SLOT_FIELD, | ||
module_info_dict[CHASSIS_MODULE_INFO_SLOT_FIELD]), | ||
(CHASSIS_MODULE_INFO_OPERSTATUS_FIELD, module_info_dict[CHASSIS_MODULE_INFO_OPERSTATUS_FIELD])]) | ||
(CHASSIS_MODULE_INFO_OPERSTATUS_FIELD, module_info_dict[CHASSIS_MODULE_INFO_OPERSTATUS_FIELD]), | ||
(CHASSIS_MODULE_INFO_NUM_ASICS_FIELD, str(len(module_info_dict[CHASSIS_MODULE_INFO_ASICS])))]) | ||
self.module_table.set(key, fvs) | ||
|
||
if module_info_dict[CHASSIS_MODULE_INFO_OPERSTATUS_FIELD] != str(ModuleBase.MODULE_STATUS_ONLINE): | ||
notOnlineModules.append(key) | ||
continue | ||
|
||
for asic_id, asic in enumerate(module_info_dict[CHASSIS_MODULE_INFO_ASICS]): | ||
asic_global_id, asic_pci_addr = asic | ||
asic_key = "%s%s" % (CHASSIS_ASIC, asic_global_id) | ||
asic_fvs = swsscommon.FieldValuePairs([(CHASSIS_ASIC_PCI_ADDRESS_FIELD, asic_pci_addr), | ||
(CHASSIS_MODULE_INFO_NAME_FIELD, key), | ||
(CHASSIS_ASIC_ID_IN_MODULE_FIELD, str(asic_id))]) | ||
self.asic_table.set(asic_key, asic_fvs) | ||
judyjoseph marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
judyjoseph marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# Asics that are on the "not online" modules need to be cleaned up | ||
asics = list(self.asic_table.getKeys()) | ||
for asic in asics: | ||
fvs = self.asic_table.get(asic) | ||
if fvs[CHASSIS_MODULE_INFO_NAME_FIELD] in notOnlineModules: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ngoc-do
However, if the code is changed to below, it works:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm I don't see that. But if this happens, the unit test will fail, I think? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unit-tests use mock_swsscommon.py, where it uses a simple dictionary. So, unit-tests are passing. However, I am seeing the behavior I mentioned previously in the real hw environment. Are you testing on the near latest github? Will try and investigate. Will help if you can confirm/investigate as well. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah OK. Yes, I tested on our chassis when committing the change. But it could be that there were new changes at the upstream, and I didn't have latest upstream in our local repos by the time I tested. I will double check, but I'm afraid that our local repos hasn't been updated at this moment. So if you see it needs to be fixed, free to do that. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK, I found it happened on our latest update. I have a fix in #203. Please review. |
||
self.asic_table._del(asic) | ||
|
||
def _get_module_info(self, module_index): | ||
""" | ||
Retrieves module info of this module | ||
|
@@ -225,11 +262,14 @@ class ModuleUpdater(logger.Logger): | |
slot = try_get(self.chassis.get_module(module_index).get_slot, default=INVALID_SLOT) | ||
status = try_get(self.chassis.get_module(module_index).get_oper_status, | ||
default=ModuleBase.MODULE_STATUS_OFFLINE) | ||
asics = try_get(self.chassis.get_module(module_index).get_all_asics, | ||
default=[]) | ||
|
||
module_info_dict[CHASSIS_MODULE_INFO_NAME_FIELD] = name | ||
module_info_dict[CHASSIS_MODULE_INFO_DESC_FIELD] = str(desc) | ||
module_info_dict[CHASSIS_MODULE_INFO_SLOT_FIELD] = str(slot) | ||
module_info_dict[CHASSIS_MODULE_INFO_OPERSTATUS_FIELD] = str(status) | ||
module_info_dict[CHASSIS_MODULE_INFO_ASICS] = asics | ||
|
||
return module_info_dict | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This new table is kept in CHASSIS_STATE_DB, unlike the other tables like MIDPLANE_TABLE etc that is kept in STATE_DB ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See this comment in PR description that the info is kept in CHASSIS_STATE_DB because it's accessible by swss containers. Does the swss use this asic present info ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are a couple of places we can keep asic info like STATE_DB (redis instance) or CHASSIS_STATE_DB (redis chassis instance).
CHASSIS_STATE_DB is accessible from every where in swss like
/usr/bin/swss.sh or /usr/bin/local/swss.sh
- script creating swss containerand
docker_init.sh` inside swss container. Inside swss container, STATE_DB is not accessible (asic database is mapped, instead of database). So CHASSIS_STATE_DB is a safer choice.