sonic-swss icon indicating copy to clipboard operation
sonic-swss copied to clipboard

Remove unwanted newline character at end of timestamp

Open arista-nwolfe opened this issue 10 months ago • 13 comments

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'}

arista-nwolfe avatar Apr 10 '24 19:04 arista-nwolfe

Can this be caught by VS test?

prsunny avatar Apr 10 '24 19:04 prsunny

/azpw run Azure.sonic-swss

arista-nwolfe avatar Apr 10 '24 23:04 arista-nwolfe

/AzurePipelines run Azure.sonic-swss

mssonicbld avatar Apr 10 '24 23:04 mssonicbld

Azure Pipelines successfully started running 1 pipeline(s).

azure-pipelines[bot] avatar Apr 10 '24 23:04 azure-pipelines[bot]

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.

arista-nwolfe avatar Apr 22 '24 22:04 arista-nwolfe

/azpw run Azure.sonic-swss

arista-nwolfe avatar Apr 23 '24 18:04 arista-nwolfe

/AzurePipelines run Azure.sonic-swss

mssonicbld avatar Apr 23 '24 18:04 mssonicbld

Azure Pipelines successfully started running 1 pipeline(s).

azure-pipelines[bot] avatar Apr 23 '24 18:04 azure-pipelines[bot]

/azpw run Azure.sonic-swss

arista-nwolfe avatar May 02 '24 21:05 arista-nwolfe

/AzurePipelines run Azure.sonic-swss

mssonicbld avatar May 02 '24 21:05 mssonicbld

Azure Pipelines successfully started running 1 pipeline(s).

azure-pipelines[bot] avatar May 02 '24 21:05 azure-pipelines[bot]

@prsunny, can you help merge this?

arlakshm avatar May 03 '24 21:05 arlakshm

@prgeor , @arlakshm , could you folks signoff?

prsunny avatar May 03 '24 21:05 prsunny

@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?

justin-wong-ce avatar Aug 06 '24 22:08 justin-wong-ce

@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.

arista-nwolfe avatar Aug 06 '24 22:08 arista-nwolfe

hi @arista-nwolfe could you run test with 202311 for the cherrypick?

StormLiangMS avatar Aug 08 '24 04:08 StormLiangMS

@yxieca could you help to cherry pick?

StormLiangMS avatar Aug 08 '24 04:08 StormLiangMS

hi @arista-nwolfe could you run test with 202311 for the cherrypick?

Tested this on 202311

arista-nwolfe avatar Aug 08 '24 16:08 arista-nwolfe

Cherry-pick PR to 202311: https://github.com/sonic-net/sonic-swss/pull/3256

mssonicbld avatar Aug 08 '24 22:08 mssonicbld