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

[minigraph][port_config] Consume port_config.json while loading minigraph #1705

Merged
merged 1 commit into from
Jul 15, 2021

Conversation

Blueve
Copy link
Contributor

@Blueve Blueve commented Jul 5, 2021

What I did

The port state will be reset to up if user use config load_minigraph to recover configurations.
This PR is for supporting consume port_config.json while loading minigraph. User can put the stateful port_config.json with minigraph file to keep the port state unchanged after reload minigraph.
The port_config.json includes a segment of config_db PORT table(we called that segment configlet as well) and it will be placed on \etc\sonic\port_config.json, below is a sample:

[
  {
    "PORT": {
      "Ethernet112": {
        "admin_status": "down"
      },
      "Ethernet116": {
        "admin_status": "up"
      }
    }
  }
]

This feature will only consume the port_config.json when the file is existed in \etc\sonic\port_config.json.

Please notice that we do not leverage this feature #716 to consume the port_config.json due to the configlet might contains multiple fields for an interface such as mtu, speed, ... however, we just want to consume the admin_status here only and there might have some side effects if we update the PORT table only.

How I did it

Add code config load_minigraph command to let it consume port_config.json.

How to verify it

Add UTs.

tests/config_test.py::TestLoadMinigraph::test_load_minigraph_with_port_config_bad_format PASSED [ 15%]
tests/config_test.py::TestLoadMinigraph::test_load_minigraph_with_port_config_inconsistent_port PASSED [ 16%]
tests/config_test.py::TestLoadMinigraph::test_load_minigraph_with_port_config PASSED [ 16%]

KVM SONiC test:
Before

admin@vlab-01:/etc/sonic$ show interface status
      Interface            Lanes    Speed    MTU    FEC           Alias             Vlan    Oper    Admin    Type    Asym PFC
---------------  ---------------  -------  -----  -----  --------------  ---------------  ------  -------  ------  ----------
    Ethernet112      93,94,95,96      40G   9100    N/A  fortyGigE0/112  PortChannel0001      up       up     N/A         off
    Ethernet116      89,90,91,92      40G   9100    N/A  fortyGigE0/116  PortChannel0002      up       up     N/A         off
    Ethernet120  101,102,103,104      40G   9100    N/A  fortyGigE0/120  PortChannel0003      up       up     N/A         off
    Ethernet124     97,98,99,100      40G   9100    N/A  fortyGigE0/124  PortChannel0004      up       up     N/A         off

admin@vlab-01:/etc/sonic$ show ip bgp sum
Neighbhor      V     AS    MsgRcvd    MsgSent    TblVer    InQ    OutQ  Up/Down      State/PfxRcd  NeighborName
-----------  ---  -----  ---------  ---------  --------  -----  ------  ---------  --------------  --------------
10.0.0.57      4  64600      22731      24480         0      0       0  16:16:49             6400  ARISTA01T1
10.0.0.59      4  64600      22752      24480         0      0       0  16:16:48             6400  ARISTA02T1
10.0.0.61      4  64600      22744      24480         0      0       0  16:16:48             6400  ARISTA03T1
10.0.0.63      4  64600      22736      24480         0      0       0  16:16:48             6400  ARISTA04T1

Total number of neighbors 4

Prepare port_config.json with below content:

[
  {
    "PORT": {
      "Ethernet112": {
        "admin_status": "down"
      },
      "Ethernet116": {
        "admin_status": "up"
      }
    }
  }
]

After config load_minigraph:

admin@vlab-01:/etc/sonic$ show interface status
      Interface            Lanes    Speed    MTU    FEC           Alias             Vlan    Oper    Admin    Type    Asym PFC
---------------  ---------------  -------  -----  -----  --------------  ---------------  ------  -------  ------  ----------
    Ethernet112      93,94,95,96      40G   9100    N/A  fortyGigE0/112  PortChannel0001    down     down     N/A         off
    Ethernet116      89,90,91,92      40G   9100    N/A  fortyGigE0/116  PortChannel0002      up       up     N/A         off
    Ethernet120  101,102,103,104      40G   9100    N/A  fortyGigE0/120  PortChannel0003      up       up     N/A         off
    Ethernet124     97,98,99,100      40G   9100    N/A  fortyGigE0/124  PortChannel0004      up       up     N/A         off

admin@vlab-01:/etc/sonic$ show ip bgp sum
Neighbhor      V     AS    MsgRcvd    MsgSent    TblVer    InQ    OutQ  Up/Down    State/PfxRcd    NeighborName
-----------  ---  -----  ---------  ---------  --------  -----  ------  ---------  --------------  --------------
10.0.0.57      4  64600          0          0         0      0       0  never      Active          ARISTA01T1
10.0.0.59      4  64600       3222       7664         0      0       0  00:00:59   6400            ARISTA02T1
10.0.0.61      4  64600       3223       7664         0      0       0  00:00:58   6400            ARISTA03T1
10.0.0.63      4  64600       3222       7664         0      0       0  00:00:59   6400            ARISTA04T1

Remove port_config.json and run config load_minigraph again:

admin@vlab-01:/etc/sonic$ show interface status
      Interface            Lanes    Speed    MTU    FEC           Alias             Vlan    Oper    Admin    Type    Asym PFC
---------------  ---------------  -------  -----  -----  --------------  ---------------  ------  -------  ------  ----------
    Ethernet112      93,94,95,96      40G   9100    N/A  fortyGigE0/112  PortChannel0001      up       up     N/A         off
    Ethernet116      89,90,91,92      40G   9100    N/A  fortyGigE0/116  PortChannel0002      up       up     N/A         off
    Ethernet120  101,102,103,104      40G   9100    N/A  fortyGigE0/120  PortChannel0003      up       up     N/A         off
    Ethernet124     97,98,99,100      40G   9100    N/A  fortyGigE0/124  PortChannel0004      up       up     N/A         off

admin@vlab-01:/etc/sonic$ show ip bgp sum
Neighbhor      V     AS    MsgRcvd    MsgSent    TblVer    InQ    OutQ  Up/Down      State/PfxRcd  NeighborName
-----------  ---  -----  ---------  ---------  --------  -----  ------  ---------  --------------  --------------
10.0.0.57      4  64600       3274       8396         0      0       0  00:03:30             6400  ARISTA01T1
10.0.0.59      4  64600       3274      13103         0      0       0  00:03:31             6400  ARISTA02T1
10.0.0.61      4  64600       3274      13104         0      0       0  00:03:31             6400  ARISTA03T1
10.0.0.63      4  64600       4884       9839         0      0       0  00:03:18             6400  ARISTA04T1

Total number of neighbors 4

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

N/A

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

N/A

@Blueve Blueve merged commit 866d1d7 into sonic-net:master Jul 15, 2021
qiluo-msft pushed a commit that referenced this pull request Jul 15, 2021
…igraph (#1705)

Signed-off-by: Jing Kan jika@microsoft.com
lguohan added a commit that referenced this pull request Jul 16, 2021
@lguohan
Copy link
Contributor

lguohan commented Jul 16, 2021

the pr failed unit test on 202012 branch, thus reverted on 202012 branch. @Blueve , can you make sure it is tested on previous branches?

@Blueve
Copy link
Contributor Author

Blueve commented Jul 16, 2021

Consider there is a known incompatible issue, I removed release branch tags for now.

Blueve added a commit to Blueve/sonic-utilities that referenced this pull request Jul 26, 2021
Blueve added a commit to Blueve/sonic-utilities that referenced this pull request Jul 26, 2021
Blueve added a commit that referenced this pull request Jul 26, 2021
…igraph (#1725)

* [minigraph][port_config] Consume port_config.json while reloading minigraph (#1705)
* Fix build issue for 201911

Signed-off-by: Jing Kan jika@microsoft.com
Blueve added a commit to Blueve/sonic-utilities that referenced this pull request Jul 27, 2021
Blueve added a commit that referenced this pull request Jul 27, 2021
… patch (#1728)

* [minigraph][port_config] Consume port_config.json while reloading minigraph (#1705)
* [minigraph][port_config] Use imported config.main and add conditional patch

Signed-off-by: Jing Kan jika@microsoft.com
Blueve added a commit that referenced this pull request Jul 29, 2021
…igraph (#1726)

* [minigraph][port_config] Consume port_config.json while reloading minigraph (#1705)
* Fix build issue for 201811
* Remove unrelated change

Signed-off-by: Jing Kan jika@microsoft.com
@abdosi
Copy link
Contributor

abdosi commented Aug 3, 2021

why is this needed for 201911 ? is there any use-case for this ?

@Blueve
Copy link
Contributor Author

Blueve commented Aug 3, 2021

why is this needed for 201911 ? is there any use-case for this ?

This is a method for keeping port state unchanged after reload minigraph.
You know, the port state will be set to UP by default after load minigraph, which is unexpected in some case.

raphaelt-nvidia pushed a commit to raphaelt-nvidia/sonic-utilities that referenced this pull request Aug 10, 2021
stepanblyschak pushed a commit to stepanblyschak/sonic-utilities that referenced this pull request Apr 28, 2022
1c12a4050fecabd88245c7aa64a61259bc00db3b (HEAD -> 201911, origin/201911)Allowing the first time FEC and AN configuration to be pushed to SAI (sonic-net#1705) (sonic-net#2196)
Signed-off-by: Abhishek Dosi <abdosi@microsoft.com>
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.

5 participants