In case the path value in a json file that is used in gcu with 'sudo config apply-patch' includes '/', which is replaced with as '~1', the patch fails as the path is not recognized.
As it seems the code reads the code until the '~1' characters and tries to find the path as it is with as a result getting a KeyError.
This behavior seems to be broken only in multi-asics platform where namespace prefix is used in path.
Please see the console output from an apply-patch with a path that falls above category in a successful run (single-asic) vs a failed run (in multi-asic).
# Apply patch of 'add_portchannel_single_asic.json' (SUCCESS)
admin@vlab-01:~$ sudo config apply-patch add_portchannel_single_asic.json
Patch Applier: localhost: Patch application starting.
Patch Applier: localhost: Patch: [{"op": "add", "path": "/PORTCHANNEL_INTERFACE/PortChannel101|10.0.0.56~131", "value": {}}]
Patch Applier: localhost getting current config db.
Patch Applier: localhost: simulating the target full config after applying the patch.
Patch Applier: localhost: validating all JsonPatch operations are permitted on the specified fields
Patch Applier: localhost: validating target config does not have empty tables,
since they do not show up in ConfigDb.
Patch Applier: localhost: sorting patch updates.
Patch Applier: The localhost patch was converted into 0 changes.
Patch Applier: localhost: applying 0 changes in order.
Patch Applier: localhost: verifying patch updates are reflected on ConfigDB.
Patch Applier: localhost patch application completed.
Patch applied successfully.
# Apply patch of 'add_portchannel_multi_asic.json' (FAILED)
admin@ixre-egl-board30:~$ sudo add_portchannel_multi_asic.json
Patch Applier: asic1: Patch application starting.
Patch Applier: asic1: Patch: [{"op": "add", "path": "/PORTCHANNEL_INTERFACE/PortChannel105|10.0.0.18/31", "value": {}}]
Patch Applier: asic1 getting current config db.
Patch Applier: asic1: simulating the target full config after applying the patch.
Failed to apply patch due to: Failed to apply patch on the following scopes:
asic1: member 'PortChannel105|10.0.0.18' not found in {'PortChannel105': {}, 'PortChannel105|10.0.0.18/31': {}, 'PortChannel105|FC00::25/126': {}}
Usage: config apply-patch [OPTIONS] PATCH_FILE_PATH
Try "config apply-patch -h" for help.
Error: Failed to apply patch on the following scopes:
asic1: member 'PortChannel105|10.0.0.18' not found in {'PortChannel105': {}, 'PortChannel105|10.0.0.18/31': {}, 'PortChannel105|FC00::25/126': {}}
Description
In case the path value in a json file that is used in gcu with 'sudo config apply-patch' includes '/', which is replaced with as '~1', the patch fails as the path is not recognized.
As it seems the code reads the code until the '~1' characters and tries to find the path as it is with as a result getting a KeyError. This behavior seems to be broken only in multi-asics platform where namespace prefix is used in path.
Please see the console output from an apply-patch with a path that falls above category in a successful run (single-asic) vs a failed run (in multi-asic).
# Contents of 'add_portchannel_single_asic.json'
# Apply patch of 'add_portchannel_single_asic.json' (SUCCESS)
# Contents of 'add_portchannel_multi_asic.json'
# Apply patch of 'add_portchannel_multi_asic.json' (FAILED)
Steps to reproduce the issue
Failed test cases:
(Automated test cases support for running in t2 topology is added via PR https://github.com/sonic-net/sonic-mgmt/pull/14070 )
Manual steps:
4.sudo config apply-patch tmp.json
Describe the results you received
apply-patch fails and path is not recognized as expected.
Here, member 'PortChannel105|10.0.0.18' is recognized although it should read 'PortChannel105|10.0.0.18/31'.
Describe the results you expected
apply-patch shoudl succeed.
In above error, member 'PortChannel105|10.0.0.18' is recognized although it should read 'PortChannel105|10.0.0.18/31'.
Additional information you deem important (e.g. issue happens only occasionally)
This behavior is successful in single-asic platforms. Issue is only for multi-asic.
Output of
show version