Skip to content
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

[ycable] add changes for correcting telemetry values for 'active-active' #341

Merged
merged 2 commits into from
Mar 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions sonic-ycabled/tests/test_y_cable_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -6271,8 +6271,10 @@ def test_check_identifier_presence_and_setup_channel(self):
test_db[asic_index], "HW_TABLE1")
hw_mux_cable_tbl_peer[asic_index] = swsscommon.Table(
test_db[asic_index], "HW_TABLE2")
mux_tbl[asic_index] = swsscommon.Table(
test_db[asic_index], "MUX_INFO_TABLE")

rc = check_identifier_presence_and_setup_channel("Ethernet0", port_tbl, hw_mux_cable_tbl, hw_mux_cable_tbl_peer, asic_index, read_side, y_cable_presence)
rc = check_identifier_presence_and_setup_channel("Ethernet0", port_tbl, hw_mux_cable_tbl, hw_mux_cable_tbl_peer, asic_index, read_side, mux_tbl, y_cable_presence)
assert(rc == None)

@patch('ycable.ycable_utilities.y_cable_helper.logical_port_name_to_physical_port_list', MagicMock(return_value=[0]))
Expand Down Expand Up @@ -6302,8 +6304,10 @@ def test_check_identifier_presence_and_setup_channel_with_mock(self):
test_db[asic_index], "HW_TABLE1")
hw_mux_cable_tbl_peer[asic_index] = swsscommon.Table(
test_db[asic_index], "HW_TABLE2")
mux_tbl[asic_index] = swsscommon.Table(
test_db[asic_index], "MUX_INFO_TABLE")

rc = check_identifier_presence_and_setup_channel("Ethernet0", port_tbl, hw_mux_cable_tbl, hw_mux_cable_tbl_peer, asic_index, read_side, y_cable_presence)
rc = check_identifier_presence_and_setup_channel("Ethernet0", port_tbl, hw_mux_cable_tbl, hw_mux_cable_tbl_peer, asic_index, read_side, mux_tbl, y_cable_presence)
assert(rc == None)


Expand Down Expand Up @@ -6337,8 +6341,10 @@ def test_check_identifier_presence_and_setup_channel_with_mock_not_none(self):
test_db[asic_index], "HW_TABLE1")
hw_mux_cable_tbl_peer[asic_index] = swsscommon.Table(
test_db[asic_index], "HW_TABLE2")
mux_tbl[asic_index] = swsscommon.Table(
test_db[asic_index], "MUX_INFO_TABLE")

rc = check_identifier_presence_and_setup_channel("Ethernet0", port_tbl, hw_mux_cable_tbl, hw_mux_cable_tbl_peer, asic_index, read_side, y_cable_presence)
rc = check_identifier_presence_and_setup_channel("Ethernet0", port_tbl, hw_mux_cable_tbl, hw_mux_cable_tbl_peer, asic_index, read_side, mux_tbl, y_cable_presence)
assert(rc == None)

@patch('proto_out.linkmgr_grpc_driver_pb2_grpc.DualToRActiveStub', MagicMock(return_value=True))
Expand Down
14 changes: 9 additions & 5 deletions sonic-ycabled/ycable/ycable_utilities/y_cable_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,7 @@ def process_loopback_interface_and_get_read_side(loopback_keys):
return -1


def check_identifier_presence_and_setup_channel(logical_port_name, port_tbl, hw_mux_cable_tbl, hw_mux_cable_tbl_peer, asic_index, read_side, y_cable_presence):
def check_identifier_presence_and_setup_channel(logical_port_name, port_tbl, hw_mux_cable_tbl, hw_mux_cable_tbl_peer, asic_index, read_side, mux_tbl, y_cable_presence):

global grpc_port_stubs
global grpc_port_channels
Expand Down Expand Up @@ -702,6 +702,7 @@ def check_identifier_presence_and_setup_channel(logical_port_name, port_tbl, hw_
return

channel, stub = setup_grpc_channel_for_port(logical_port_name, soc_ipv4)
post_port_mux_info_to_db(logical_port_name, mux_tbl, asic_index, hw_mux_cable_tbl, 'pseudo-cable')
if channel is not None:
grpc_port_channels[logical_port_name] = channel
helper_logger.log_notice(
Expand Down Expand Up @@ -733,6 +734,7 @@ def setup_grpc_channels(stop_event):
loopback_keys = {}
hw_mux_cable_tbl = {}
hw_mux_cable_tbl_peer = {}
mux_tbl = {}

namespaces = multi_asic.get_front_end_namespaces()
for namespace in namespaces:
Expand All @@ -748,6 +750,8 @@ def setup_grpc_channels(stop_event):
state_db[asic_id], swsscommon.STATE_HW_MUX_CABLE_TABLE_NAME)
hw_mux_cable_tbl_peer[asic_id] = swsscommon.Table(
state_db[asic_id], "HW_MUX_CABLE_TABLE_PEER")
mux_tbl[asic_id] = swsscommon.Table(
state_db[asic_id], "MUX_CABLE_INFO")

if read_side == -1:
read_side = process_loopback_interface_and_get_read_side(loopback_keys)
Expand All @@ -772,7 +776,7 @@ def setup_grpc_channels(stop_event):

if logical_port_name in port_table_keys[asic_index]:
check_identifier_presence_and_setup_channel(
logical_port_name, port_tbl, hw_mux_cable_tbl, hw_mux_cable_tbl_peer, asic_index, read_side, y_cable_presence)
logical_port_name, port_tbl, hw_mux_cable_tbl, hw_mux_cable_tbl_peer, asic_index, read_side, mux_tbl, y_cable_presence)
else:
# This port does not exist in Port table of config but is present inside
# logical_ports after loading the port_mappings from port_config_file
Expand Down Expand Up @@ -1399,7 +1403,7 @@ def init_ports_status_for_y_cable(platform_sfp, platform_chassis, y_cable_presen
if status and cable_type == "active-active":
grpc_port_stats[logical_port_name] = {}
check_identifier_presence_and_setup_channel(
logical_port_name, port_tbl, hw_mux_cable_tbl, hw_mux_cable_tbl_peer, asic_index, read_side, y_cable_presence)
logical_port_name, port_tbl, hw_mux_cable_tbl, hw_mux_cable_tbl_peer, asic_index, read_side, mux_tbl, y_cable_presence)
else:
# This port does not exist in Port table of config but is present inside
# logical_ports after loading the port_mappings from port_config_file
Expand Down Expand Up @@ -1469,7 +1473,7 @@ def change_ports_status_for_y_cable_change_event(port_dict, y_cable_presence, st
state_db, port_tbl, y_cable_tbl, static_tbl, mux_tbl, asic_index, logical_port_name, y_cable_presence)
if status and cable_type == "active-active":
check_identifier_presence_and_setup_channel(
logical_port_name, port_tbl, hw_mux_cable_tbl, hw_mux_cable_tbl_peer, asic_index, read_side, y_cable_presence)
logical_port_name, port_tbl, hw_mux_cable_tbl, hw_mux_cable_tbl_peer, asic_index, read_side, mux_tbl, y_cable_presence)
elif value == SFP_STATUS_REMOVED:
helper_logger.log_info("Got SFP deleted ycable event")
check_identifier_presence_and_delete_mux_table_entry(
Expand Down Expand Up @@ -2232,7 +2236,7 @@ def post_port_mux_info_to_db(logical_port_name, mux_tbl, asic_index, y_cable_tbl

for physical_port in physical_port_list:

if not y_cable_wrapper_get_presence(physical_port):
if not y_cable_wrapper_get_presence(physical_port) or cable_type == 'pseudo-cable':
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is 'pseudo-cable'?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a one-time call to make sure when the gRPC channels/stubs etc are created, ycabled posts the active-standby fields but only as unknown/N/a. The reason for doing it is ST today depends on having this fields populated albeit N/A or unknown, to post the full data to Kusto DB.
this pseudo-cable logic takes care of it, and is only called once when Cable is either inserted/or ycabled spawns

mux_info_dict = get_muxcable_info_without_presence()
elif cable_type == 'active-active':
helper_logger.log_warning("Error: trying to post mux info without presence of port {}".format(logical_port_name))
Expand Down