sonic-swss
sonic-swss copied to clipboard
Remove unwanted newline character at end of timestamp
In https://github.com/sonic-net/sonic-swss/pull/3052 2 new fields were added the PORT_TABLE
in APPL_DB
: last_down_time
and last_up_time
.
But their value was generated with std::ctime
which includes a newline character at the end of the character array which causes issues for parsing the output.
Output today:
> sonic-db-cli APPL_DB hgetall PORT_TABLE:Ethernet8
{'admin_status': 'up', 'alias': 'Ethernet3/1', 'asic_port_name': 'Eth8', 'coreId': '0', 'corePortId': '3', 'description': 'Ethernet8-connected-to-@Ethernet5/4/1', 'fec': 'rs', 'index': '3', 'lanes': '4,5', 'mtu': '9100', 'numVoq': '8', 'pfc_asym': 'off', 'role': 'Ext', 'speed': '100000', 'tpid': '0x8100', 'oper_status': 'up', 'flap_count': '1', 'last_up_time': 'Wed Apr 10 00:18:44 2024
', 'system_oper_status': 'up', 'line_oper_status': 'up'}
> config interface shutdown Ethernet8
> sonic-db-cli APPL_DB hgetall PORT_TABLE:Ethernet8
{'admin_status': 'down', 'alias': 'Ethernet3/1', 'asic_port_name': 'Eth8', 'coreId': '0', 'corePortId': '3', 'description': 'Ethernet8-connected-to-@Ethernet5/4/1', 'fec': 'rs', 'index': '3', 'lanes': '4,5', 'mtu': '9100', 'numVoq': '8', 'pfc_asym': 'off', 'role': 'Ext', 'speed': '100000', 'tpid': '0x8100', 'oper_status': 'down', 'flap_count': '2', 'last_up_time': 'Wed Apr 10 00:18:44 2024
', 'system_oper_status': 'down', 'line_oper_status': 'down', 'last_down_time': 'Wed Apr 10 16:35:11 2024
'}
> config interface startup Ethernet8
> sonic-db-cli APPL_DB hgetall PORT_TABLE:Ethernet8
{'admin_status': 'up', 'alias': 'Ethernet3/1', 'asic_port_name': 'Eth8', 'coreId': '0', 'corePortId': '3', 'description': 'Ethernet8-connected-to-@Ethernet5/4/1', 'fec': 'rs', 'index': '3', 'lanes': '4,5', 'mtu': '9100', 'numVoq': '8', 'pfc_asym': 'off', 'role': 'Ext', 'speed': '100000', 'tpid': '0x8100', 'oper_status': 'up', 'flap_count': '3', 'last_up_time': 'Wed Apr 10 16:35:34 2024
', 'system_oper_status': 'up', 'line_oper_status': 'up', 'last_down_time': 'Wed Apr 10 16:35:11 2024
'}
Output after this change:
> sonic-db-cli APPL_DB hgetall PORT_TABLE:Ethernet8
{'admin_status': 'up', 'alias': 'Ethernet3/1', 'asic_port_name': 'Eth8', 'coreId': '0', 'corePortId': '3', 'description': 'Ethernet8-connected-to-@Ethernet5/4/1', 'fec': 'rs', 'index': '3', 'lanes': '4,5', 'mtu': '9100', 'numVoq': '8', 'pfc_asym': 'off', 'role': 'Ext', 'speed': '100000', 'tpid': '0x8100', 'oper_status': 'up', 'flap_count': '1', 'last_up_time': 'Wed Apr 10 17:01:00 2024', 'system_oper_status': 'up', 'line_oper_status': 'up'}
> config interface shutdown Ethernet8
> sonic-db-cli APPL_DB hgetall PORT_TABLE:Ethernet8
{'admin_status': 'down', 'alias': 'Ethernet3/1', 'asic_port_name': 'Eth8', 'coreId': '0', 'corePortId': '3', 'description': 'Ethernet8-connected-to-@Ethernet5/4/1', 'fec': 'rs', 'index': '3', 'lanes': '4,5', 'mtu': '9100', 'numVoq': '8', 'pfc_asym': 'off', 'role': 'Ext', 'speed': '100000', 'tpid': '0x8100', 'oper_status': 'down', 'flap_count': '2', 'last_up_time': 'Wed Apr 10 17:01:00 2024', 'system_oper_status': 'down', 'line_oper_status': 'down', 'last_down_time': 'Wed Apr 10 18:37:03 2024'}
> config interface startup Ethernet8
> sonic-db-cli APPL_DB hgetall PORT_TABLE:Ethernet8
{'admin_status': 'up', 'alias': 'Ethernet3/1', 'asic_port_name': 'Eth8', 'coreId': '0', 'corePortId': '3', 'description': 'Ethernet8-connected-to-@Ethernet5/4/1', 'fec': 'rs', 'index': '3', 'lanes': '4,5', 'mtu': '9100', 'numVoq': '8', 'pfc_asym': 'off', 'role': 'Ext', 'speed': '100000', 'tpid': '0x8100', 'oper_status': 'up', 'flap_count': '3', 'last_up_time': 'Wed Apr 10 18:37:13 2024', 'system_oper_status': 'up', 'line_oper_status': 'up', 'last_down_time': 'Wed Apr 10 18:37:03 2024'}
Can this be caught by VS test?
/azpw run Azure.sonic-swss
/AzurePipelines run Azure.sonic-swss
Azure Pipelines successfully started running 1 pipeline(s).
Can this be caught by VS test?
This PR is the fix for a regression in a feature introduced by someone else in https://github.com/sonic-net/sonic-swss/pull/3052 I've opened https://github.com/sonic-net/sonic-swss/issues/3120 to track adding a test for it.
/azpw run Azure.sonic-swss
/AzurePipelines run Azure.sonic-swss
Azure Pipelines successfully started running 1 pipeline(s).
/azpw run Azure.sonic-swss
/AzurePipelines run Azure.sonic-swss
Azure Pipelines successfully started running 1 pipeline(s).
@prsunny, can you help merge this?
@prgeor , @arlakshm , could you folks signoff?
@arista-nwolfe A backport to 202311 is needed to fix a regression caused by a backport of this PR: https://github.com/sonic-net/sonic-swss/pull/3052
Can you add a Request for 202311 Branch
label please?
@arista-nwolfe A backport to 202311 is needed to fix a regression caused by a backport of this PR: #3052
Can you add a
Request for 202311 Branch
label please?
I don't have label permissions @wenyiz2021 @arlakshm @vmittal-msft would one of you be able to add it.
hi @arista-nwolfe could you run test with 202311 for the cherrypick?
@yxieca could you help to cherry pick?
hi @arista-nwolfe could you run test with 202311 for the cherrypick?
Tested this on 202311
Cherry-pick PR to 202311: https://github.com/sonic-net/sonic-swss/pull/3256