Skip to content

Commit 4a32b5a

Browse files
authored
[y-cable] fix for logging the xcvrd metrics before writing the state to the State-DB (sonic-net#208)
fix for logging the xcvrd metrics before writing the state back to the STATE DB Description This PR fixes the logging for mux_metrics for writing anything to the state DB for a state transition. Basically previously xcvrd would first post the query result to the DB and only then update its own metric for state transition, but now we do the reverse. Motivation and Context Second change was motivated by the sequence of events which happen inside state transition for mux-metrics table. Previously orchagent reports finishing the transition before xcvrd which is not the case. Ideally xcvrd does the transition first followed by orchagent followed by linkmgr How Has This Been Tested? Ran the change on Arista7050cx3 testbed. Additional Information (Optional) Signed-off-by: vaibhav-dahiya <[email protected]>
1 parent 53e1532 commit 4a32b5a

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

sonic-xcvrd/xcvrd/xcvrd_utilities/y_cable_helper.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -1102,17 +1102,18 @@ def task_worker(self):
11021102
port, old_status, new_status))
11031103
new_status = 'unknown'
11041104

1105-
fvs_updated = swsscommon.FieldValuePairs([('state', new_status),
1106-
('read_side', read_side),
1107-
('active_side', str(active_side))])
1108-
y_cable_tbl[asic_index].set(port, fvs_updated)
11091105
helper_logger.log_debug("Y_CABLE_DEBUG: xcvrd successful to transition port {} from {} to {} and write back to the DB".format(port, old_status, new_status))
11101106
helper_logger.log_info("Got a change event for toggle the mux-direction active side for port {} state from {} to {}".format(
11111107
port, old_status, new_status))
11121108
time_end = datetime.datetime.utcnow().strftime("%Y-%b-%d %H:%M:%S.%f")
11131109
fvs_metrics = swsscommon.FieldValuePairs([('xcvrd_switch_{}_start'.format(new_status), str(time_start)),
11141110
('xcvrd_switch_{}_end'.format(new_status), str(time_end))])
11151111
mux_metrics_tbl[asic_index].set(port, fvs_metrics)
1112+
1113+
fvs_updated = swsscommon.FieldValuePairs([('state', new_status),
1114+
('read_side', read_side),
1115+
('active_side', str(active_side))])
1116+
y_cable_tbl[asic_index].set(port, fvs_updated)
11161117
else:
11171118
helper_logger.log_info("Got a change event on port {} of table {} that does not contain state".format(
11181119
port, swsscommon.APP_HW_MUX_CABLE_TABLE_NAME))

0 commit comments

Comments
 (0)