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] Using simulated config instead of target config when validating replace operation in NoDependencyMoveValidator #1987

Merged
merged 1 commit into from
Dec 27, 2021

Conversation

ghooo
Copy link
Contributor

@ghooo ghooo commented Dec 24, 2021

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:

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

… replace operation in NoDependencyMoveValidator
@@ -1013,7 +1015,7 @@ def __init__(self, move_wrapper):
self.move_wrapper = move_wrapper
self.mem = {}

def rec(self, diff):
def sort(self, diff):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

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.

@ghooo ghooo merged commit b3a5052 into sonic-net:master 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)
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.

3 participants