-
Notifications
You must be signed in to change notification settings - Fork 694
Read switch_id of fabric switch from config_db #3102
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
Changes from all commits
983e024
c2cc222
057073e
3b2aa32
94a9cba
9246a29
1f050a7
15d3c8f
6d00bbc
df11562
85c4872
45719b7
b9e2b3f
8d88bdc
c8af827
557fb3b
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 |
|---|---|---|
|
|
@@ -588,6 +588,28 @@ int main(int argc, char **argv) | |
| attr.value.u32 = SAI_SWITCH_TYPE_FABRIC; | ||
| attrs.push_back(attr); | ||
|
|
||
| //Read switch_id from config_db. | ||
| Table cfgDeviceMetaDataTable(&config_db, CFG_DEVICE_METADATA_TABLE_NAME); | ||
| string value; | ||
| if (cfgDeviceMetaDataTable.hget("localhost", "switch_id", value)) | ||
| { | ||
| if (value.size()) | ||
| { | ||
| gVoqMySwitchId = stoi(value); | ||
| } | ||
|
|
||
| if (gVoqMySwitchId < 0) | ||
| { | ||
| SWSS_LOG_ERROR("Invalid fabric switch id %d configured", gVoqMySwitchId); | ||
| exit(EXIT_FAILURE); | ||
| } | ||
| } | ||
| else | ||
| { | ||
| SWSS_LOG_ERROR("Fabric switch id is not configured"); | ||
|
Collaborator
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. Seems like its a breaking change. You are exiting orchagent if switch_id is not present in db. Is this intenational. @judyjoseph , @arlakshm
Contributor
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. @prsunny We have the same condition for linecard asics. In latest SAI,
Collaborator
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, please approve the PR |
||
| exit(EXIT_FAILURE); | ||
| } | ||
|
|
||
| attr.id = SAI_SWITCH_ATTR_SWITCH_ID; | ||
| attr.value.u32 = gVoqMySwitchId; | ||
| attrs.push_back(attr); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| from dvslib.dvs_common import wait_for_result, PollingConfig | ||
| import pytest | ||
|
|
||
| class TestFabricSwitchId(object): | ||
| def check_syslog(self, dvs, marker, log): | ||
| def do_check_syslog(): | ||
| (ec, out) = dvs.runcmd(['sh', '-c', "awk \'/%s/,ENDFILE {print;}\' /var/log/syslog | grep \'%s\' | wc -l" %(marker, log)]) | ||
| return (int(out.strip()) >= 1, None) | ||
| max_poll = PollingConfig(polling_interval=5, timeout=600, strict=True) | ||
| wait_for_result(do_check_syslog, polling_config=max_poll) | ||
|
|
||
| def test_invalid_fabric_switch_id(self, vst): | ||
| # Find supervisor dvs. | ||
| dvs = None | ||
| config_db = None | ||
| for name in vst.dvss.keys(): | ||
| dvs = vst.dvss[name] | ||
| config_db = dvs.get_config_db() | ||
| metatbl = config_db.get_entry("DEVICE_METADATA", "localhost") | ||
| cfg_switch_type = metatbl.get("switch_type") | ||
| if cfg_switch_type == "fabric": | ||
| break | ||
| assert dvs and config_db | ||
|
|
||
| # Verify orchagent's handling of invalid fabric switch_id in following cases: | ||
| # - Invalid fabric switch_id, e.g, -1, is set. | ||
| # - fabric switch_id is missing in ConfigDb. | ||
| for invalid_switch_id in (-1, None): | ||
| print(f"Test invalid switch id {invalid_switch_id}") | ||
| if invalid_switch_id is None: | ||
| config_db.delete_field("DEVICE_METADATA", "localhost", "switch_id") | ||
| expected_log = "Fabric switch id is not configured" | ||
| else: | ||
| config_db.set_field("DEVICE_METADATA", "localhost", "switch_id", str(invalid_switch_id)) | ||
| expected_log = f"Invalid fabric switch id {invalid_switch_id} configured" | ||
|
|
||
| # Restart orchagent and verify orchagent behavior by checking syslog. | ||
| dvs.stop_swss() | ||
| marker = dvs.add_log_marker() | ||
| dvs.start_swss() | ||
| self.check_syslog(dvs, marker, expected_log) | ||
|
|
||
|
|
||
| # Add Dummy always-pass test at end as workaroud | ||
| # for issue when Flaky fail on final test it invokes module tear-down before retrying | ||
| def test_nonflaky_dummy(): | ||
| pass | ||
|
|
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.
Can you check if VS tests are adopted for this change for Voq?