Skip to content

Commit

Permalink
[y-cable] fix for logging the xcvrd metrics before writing the state …
Browse files Browse the repository at this point in the history
…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]>
  • Loading branch information
vdahiya12 authored Jul 27, 2021
1 parent 53e1532 commit 4a32b5a
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions sonic-xcvrd/xcvrd/xcvrd_utilities/y_cable_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -1102,17 +1102,18 @@ def task_worker(self):
port, old_status, new_status))
new_status = 'unknown'

fvs_updated = swsscommon.FieldValuePairs([('state', new_status),
('read_side', read_side),
('active_side', str(active_side))])
y_cable_tbl[asic_index].set(port, fvs_updated)
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))
helper_logger.log_info("Got a change event for toggle the mux-direction active side for port {} state from {} to {}".format(
port, old_status, new_status))
time_end = datetime.datetime.utcnow().strftime("%Y-%b-%d %H:%M:%S.%f")
fvs_metrics = swsscommon.FieldValuePairs([('xcvrd_switch_{}_start'.format(new_status), str(time_start)),
('xcvrd_switch_{}_end'.format(new_status), str(time_end))])
mux_metrics_tbl[asic_index].set(port, fvs_metrics)

fvs_updated = swsscommon.FieldValuePairs([('state', new_status),
('read_side', read_side),
('active_side', str(active_side))])
y_cable_tbl[asic_index].set(port, fvs_updated)
else:
helper_logger.log_info("Got a change event on port {} of table {} that does not contain state".format(
port, swsscommon.APP_HW_MUX_CABLE_TABLE_NAME))
Expand Down

0 comments on commit 4a32b5a

Please sign in to comment.