[GCU] Using simulated config instead of target config when validating replace operation in NoDependencyMoveValidator#1987
Merged
ghooo merged 1 commit intosonic-net:masterfrom Dec 27, 2021
Conversation
… replace operation in NoDependencyMoveValidator
ghooo
commented
Dec 24, 2021
| self.mem = {} | ||
|
|
||
| def rec(self, diff): | ||
| def sort(self, diff): |
Contributor
Author
There was a problem hiding this comment.
small change not related to the PR.
The MemoizationSorter is not used so we have not caught this before. This sorter is just added to run experiments on the performance.
qiluo-msft
approved these changes
Dec 27, 2021
judyjoseph
pushed a commit
that referenced
this pull request
Jan 9, 2022
… replace operation in NoDependencyMoveValidator (#1987) #### What I did Using `SimulatedConfig` instead of `TargetConfig` for validating a move using `NoDependencyMoveValidator` SimulatedConfig: config after applying the given move TargetConfig: the final config state that's required by the patch The problem is if the moves is to update a list item, the list item location in the `TargetConfig` might have different location in the `CurrentConfig`. The reason for that is the `TargetConfig` has the final outcome after applying the `patch`, but the move might be just making a small change towards this goal. Example: Assume current_config ``` { "VLAN": { "Vlan100": { "vlanid": "100", "dhcp_servers": [ "192.0.0.1", "192.0.0.2" ] } } } ``` TargetConfig: ``` { "VLAN": { "Vlan100": { "vlanid": "100", "dhcp_servers": [ "192.0.0.3" ] } } } ``` Move: ```python ps.JsonMove(diff, OperationType.REPLACE, ["VLAN", "Vlan100", "dhcp_servers", 1], ["VLAN", "Vlan100", "dhcp_servers", 0]) ``` The move means: ``` Replace the value in CurrentConfig that has path `/VLAN/Vlan100/dhcp_servers/1` with the value from the TargetConfig that has the path `/VLAN/Vlan100/dhcp_servers/0` ``` Notice how the array index in CurrentConfig does not exist in TargetConfig Instead of using TargetConfig to validate, use SimulatedConfig which is the config after applying the move. In this case it would be: ``` { "VLAN": { "Vlan100": { "vlanid": "100", "dhcp_servers": [ "192.0.0.1", "192.0.0.3" ] } } } ``` #### How I did it Replace `diff.target_config` with `simulated_config` #### How to verify it added a unit-test
stepanblyschak
pushed a commit
to stepanblyschak/sonic-utilities
that referenced
this pull request
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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What I did
Using
SimulatedConfiginstead ofTargetConfigfor validating a move usingNoDependencyMoveValidatorSimulatedConfig: config after applying the given move
TargetConfig: the final config state that's required by the patch
The problem is if the moves is to update a list item, the list item location in the
TargetConfigmight have different location in theCurrentConfig.The reason for that is the
TargetConfighas the final outcome after applying thepatch, but the move might be just making a small change towards this goal.Example:
Assume current_config
TargetConfig:
Move:
The move means:
Notice how the array index in CurrentConfig does not exist in TargetConfig
Instead of using TargetConfig to validate, use SimulatedConfig which is the config after applying the move. In this case it would be:
How I did it
Replace
diff.target_configwithsimulated_configHow to verify it
added a unit-test