Skip to content

[GCU] Copying config_db before calling sonic_yang.loadData#1983

Merged
ghooo merged 1 commit intosonic-net:masterfrom
ghooo:dev/mghoneim/copy_before_loaddata
Dec 27, 2021
Merged

[GCU] Copying config_db before calling sonic_yang.loadData#1983
ghooo merged 1 commit intosonic-net:masterfrom
ghooo:dev/mghoneim/copy_before_loaddata

Conversation

@ghooo
Copy link
Contributor

@ghooo ghooo commented Dec 23, 2021

What I did

Adding unit-test for cases where PatchSorter.sort is called to update config that has tables without YANG. This would sometimes throw the error

KeyError: 'NameOfTableWithoutYang'

This error happened because find_ref_paths would remove tables without yang as a side-effect.

Earlier this was fixed by cropping tables without yang models from current and target configs. That fix had 2 issues:

  • It is not addressing the real problem which is cropping the config as a side effect to find_ref_paths
  • If the move generated by the inner logic of PatchSorter was to replace whole config, it would result in replacing whole config with the config with cropped non-yang tables

How I did it

  • Fixing find_ref_paths to not crop the given config as a side-effect
    • Added a unit-test for that
  • Revert the change to crop current config and target config in PatchSorter.sort
    • Added a unit-test to verify replace whole config move does not result unintentionally in removing tables without yang
  • Added unit-test to verify calling PatchSorter.sort on a config with non-yang tables does not result in the exception:
    KeyError: 'NameOfTableWithoutYang'
    

How to verify it

unit-tests

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)

@qiluo-msft qiluo-msft self-requested a review December 23, 2021 01:13
@qiluo-msft qiluo-msft changed the title [GCU] Copying config_db before callding sonic_yang.loadData [GCU] Copying config_db before calling sonic_yang.loadData Dec 24, 2021
@qiluo-msft
Copy link
Contributor

Could you explain your motivation in PR description? Is it a bug fix or refactoring?

@ghooo ghooo force-pushed the dev/mghoneim/copy_before_loaddata branch from 6b8cb79 to 0218a83 Compare December 27, 2021 17:14
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding __str__ and __repr__ are not related to this PR, but they are small improvements to the Diff class.

@ghooo ghooo force-pushed the dev/mghoneim/copy_before_loaddata branch 2 times, most recently from efdddff to 2374d73 Compare December 27, 2021 17:34
@ghooo ghooo force-pushed the dev/mghoneim/copy_before_loaddata branch from 2374d73 to e96fd8c Compare December 27, 2021 18:44
@ghooo ghooo merged commit 35cb524 into sonic-net:master Dec 27, 2021
judyjoseph pushed a commit that referenced this pull request Jan 9, 2022
#### What I did
Adding unit-test for cases where `PatchSorter.sort` is called to update config that has tables without YANG. This would sometimes throw the error
```
KeyError: 'NameOfTableWithoutYang'
```
This error happened because `find_ref_paths` would remove tables without yang as a side-effect.

Earlier this was fixed by cropping tables without yang models from current and target configs. That fix had 2 issues:
- It is not addressing the real problem which is cropping the config as a side effect to `find_ref_paths`
- If the move generated by the inner logic of `PatchSorter` was to replace whole config, it would result in replacing whole config with the config with cropped non-yang tables

#### How I did it
- Fixing `find_ref_paths` to not crop the given config as a side-effect
  - Added a unit-test for that
- Revert the change to crop current config and target config in `PatchSorter.sort`
  - Added a unit-test to verify replace whole config move does not result unintentionally in removing tables without yang
- Added unit-test to verify calling `PatchSorter.sort` on a config with non-yang tables does not result in the exception: 
  ```
  KeyError: 'NameOfTableWithoutYang'
  ```

#### How to verify it
unit-tests

#### 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)
dbarashinvd pushed a commit to dbarashinvd/sonic-utilities that referenced this pull request Jul 11, 2022
…t#1983)

#### What I did
Adding unit-test for cases where `PatchSorter.sort` is called to update config that has tables without YANG. This would sometimes throw the error
```
KeyError: 'NameOfTableWithoutYang'
```
This error happened because `find_ref_paths` would remove tables without yang as a side-effect.

Earlier this was fixed by cropping tables without yang models from current and target configs. That fix had 2 issues:
- It is not addressing the real problem which is cropping the config as a side effect to `find_ref_paths`
- If the move generated by the inner logic of `PatchSorter` was to replace whole config, it would result in replacing whole config with the config with cropped non-yang tables

#### How I did it
- Fixing `find_ref_paths` to not crop the given config as a side-effect
  - Added a unit-test for that
- Revert the change to crop current config and target config in `PatchSorter.sort`
  - Added a unit-test to verify replace whole config move does not result unintentionally in removing tables without yang
- Added unit-test to verify calling `PatchSorter.sort` on a config with non-yang tables does not result in the exception: 
  ```
  KeyError: 'NameOfTableWithoutYang'
  ```

#### How to verify it
unit-tests

#### 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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[generic-config-updater] Failing to run 'config apply-patch' for a patch to add an ACL

3 participants