Skip to content

Commit 6522c46

Browse files
authored
[ycabled] add notification for gRPC connection state transitions to IDLE/TRANSIENT_FAILURE (#295)
Signed-off-by: vaibhav-dahiya [email protected] For the cases where gRPC connectivity to server becomes IDLE/TRANSIENT_FAILURE, the ToR should periodically query/retry establish admin state and revert the Forwarding state back to active-active for both the T0's This PR tries to attain that via adding a transient failure message to APP DB when connectivity is lost, so each time connectivity state changes back to not desired state(IDLE/TRANSIENT_FAILURE) we log a message, and linkmgr will query again to get gRPC in sync Description Motivation and Context How Has This Been Tested? Unit-tests and deploying changes to testbed Additional Information (Optional)
1 parent 4b3b238 commit 6522c46

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

sonic-ycabled/ycable/ycable_utilities/y_cable_helper.py

+21-1
Original file line numberDiff line numberDiff line change
@@ -424,16 +424,36 @@ def connect_channel(channel, stub, port):
424424
def create_channel(type, level, kvp, soc_ip, port):
425425

426426

427-
#Helper callback to get an channel connectivity state
427+
appl_db = {}
428+
fwd_state_response_tbl = {}
429+
namespaces = multi_asic.get_front_end_namespaces()
430+
for namespace in namespaces:
431+
# Open a handle to the Application database, in all namespaces
432+
asic_id = multi_asic.get_asic_index_from_namespace(namespace)
433+
appl_db[asic_id] = daemon_base.db_connect("APPL_DB", namespace)
434+
fwd_state_response_tbl[asic_id] = swsscommon.Table(
435+
appl_db[asic_id], "FORWARDING_STATE_RESPONSE")
436+
437+
asic_index = y_cable_platform_sfputil.get_asic_id_for_logical_port(port)
438+
439+
# Helper callback to get an channel connectivity state
428440
def wait_for_state_change(channel_connectivity):
429441
if channel_connectivity == grpc.ChannelConnectivity.TRANSIENT_FAILURE:
430442
helper_logger.log_notice("gRPC port {} state changed to TRANSIENT_FAILURE".format(port))
443+
# for connectivity state to FAILURE/IDLE report a failure
444+
fvs_updated = swsscommon.FieldValuePairs([('response', 'failure')])
445+
fwd_state_response_tbl[asic_index].set(port, fvs_updated)
446+
431447
if channel_connectivity == grpc.ChannelConnectivity.CONNECTING:
432448
helper_logger.log_notice("gRPC port {} state changed to CONNECTING".format(port))
433449
if channel_connectivity == grpc.ChannelConnectivity.READY:
434450
helper_logger.log_notice("gRPC port {} state changed to READY".format(port))
435451
if channel_connectivity == grpc.ChannelConnectivity.IDLE:
436452
helper_logger.log_notice("gRPC port {} state changed to IDLE".format(port))
453+
# for connectivity state to FAILURE/IDLE report a failure
454+
fvs_updated = swsscommon.FieldValuePairs([('response', 'failure')])
455+
fwd_state_response_tbl[asic_index].set(port, fvs_updated)
456+
437457
if channel_connectivity == grpc.ChannelConnectivity.SHUTDOWN:
438458
helper_logger.log_notice("gRPC port {} state changed to SHUTDOWN".format(port))
439459

0 commit comments

Comments
 (0)