Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GCU] apply-patch failed to get token from 'using' group #2041

Closed
wen587 opened this issue Jan 26, 2022 · 0 comments · Fixed by #2044
Closed

[GCU] apply-patch failed to get token from 'using' group #2041

wen587 opened this issue Jan 26, 2022 · 0 comments · Fixed by #2044

Comments

@wen587
Copy link
Contributor

wen587 commented Jan 26, 2022

Description

When apply-patch a json file which yang has grouping member, the method cannot grab token.

Steps to reproduce the issue

  1. bgp-monitor.yang has member that defined in sonic-bgp-common.yang
    https://github.com/Azure/sonic-buildimage/blob/master/src/sonic-yang-models/yang-models/sonic-bgp-monitor.yang#L43
  2. When apply-patch, it failed to grab token.
admin@vlab-01:~$ sudo config apply-patch -i /FEATURE -i /QUEUE -i /SCHEDULER bgpl/add.json
Patch Applier: Patch application starting.
Patch Applier: Patch: [{"op": "add", "path": "/BGP_MONITORS", "value": {"11.0.0.1": {"admin_status": "up", "asn": "65100", "holdtime": "10", "keepalive": "3", "local_addr": "10.1.0.32", "name": "BGPMonitor", "nhopself": "0", "rrclient": "0"}}}]
...
Failed to apply patch
Usage: config apply-patch [OPTIONS] PATCH_FILE_PATH
Try "config apply-patch -h" for help.

Error: Token not found 
  1. some debug info when error occur in https://github.com/Azure/sonic-utilities/blob/master/generic_config_updater/gu_common.py#L551
    raise ValueError("Token not found model {} token_index {} path_tokens {}".format(model, token_index, path_tokens))
    The token is only got from leaf not from using
model OrderedDict([('@name', 'BGP_MONITORS_LIST'), 
('key', OrderedDict([('@value', 'addr')])), 
('description', OrderedDict([('text', 'This list is to support BGP monitor configuration handled by bgpcfgd')])), 
('leaf', OrderedDict([('@name', 'addr'), ('type', OrderedDict([('@name', 'inet:ip-address')])), 
('description', OrderedDict([('text', 'BGP monitor address')])), ('__isleafList', False)])), 

('uses', OrderedDict([('@name', 'bgpcmn:sonic-bgp-cmn-neigh'),    <===================================================

('refine', OrderedDict([('@target-node', 'name'), 
('must', OrderedDict([('@condition', "current() = 'BGPMonitor'"), 
('error-message', OrderedDict([('value', 'Invalid BGP monitor name')]))]))]))]))]) 
token_index 2 path_tokens ['BGP_MONITORS', '11.0.0.1', 'asn']

Describe the results you received

See above.

Describe the results you expected

Fix in two ways:

  1. We don't using grouping in Yang such that bgp-monitor has all member defined in itself.
  2. Handle using keyword in yang model.

Additional information you deem important (e.g. issue happens only occasionally)

Output of show version

(paste your output here)
@ghooo ghooo marked this as a duplicate of #2034 Jan 26, 2022
@ghooo ghooo closed this as completed Jan 26, 2022
@ghooo ghooo reopened this Feb 3, 2022
ghooo added a commit that referenced this issue Feb 23, 2022
#### What I did
Fixes #2041

Supporting groupings during `config-db path` <-> `config-yang xpath` translation

This mimics the `config-db` <-> `config-yang`  translation as added by sonic-net/sonic-buildimage#8318

#### How I did it
Handled groupings of leaf commands only as that's what is supported in sonic-yang-mgmt

#### How to verify it
unit-test

#### Previous command output (if the output of a command-line utility has changed)

#### New command output (if the output of a command-line utility has changed)
stepanblyschak pushed a commit to stepanblyschak/sonic-utilities that referenced this issue Apr 18, 2022
includes:

320591a [DualToR] Handle race condition between tunnel_decap and mux orchestrator (sonic-net#2114)
5027a8f Handling Invalid CRM configuration gracefully (sonic-net#2109)
0b120fa [ci]: use native arm64 and armhf pool (sonic-net#2013)
394e88a Don't handle buffer pool watermark during warm reboot reconciling (sonic-net#1987)
9008a01 patch for issue sonic-net#1971 - enable Rx Drop handling for cisco-8000 (sonic-net#2041)
2723ee3 create debug_shell_enable config to enable debug shell (sonic-net#2060)
d7be0b9 [request parser] Add unit tests for request parser for multiple values (sonic-net#1766)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants