From f21a45b68aa09e088d4149b63e3836246540dc30 Mon Sep 17 00:00:00 2001 From: Mohamed Ghoneim Date: Mon, 21 Feb 2022 11:07:29 -0800 Subject: [PATCH] [build] fix build exception and revert #9136 (#10037) #### Why I did it 1. Fix Build exception [example](https://dev.azure.com/mssonic/build/_build/results?buildId=73911&view=logs&jobId=88ce9a53-729c-5fa9-7b6e-3d98f2488e3f&j=cef3d8a9-152e-5193-620b-567dc18af272&t=ac3bce9f-b126-5a26-3fee-28ce0ec1679d) ``` 2022-02-19T01:54:23.4200556Z ImportError: cannot import name 'soft_unicode' from 'markupsafe' (/usr/local/lib/python3.8/dist-packages/markupsafe/__init__.py) ``` This is because Jinja2 uses MarkupSafe without specifying an upper limit to the version, MarkupSafe version that was released today removed 'soft_unicode'. So now Jinja2 is complaining. Related issues: https://github.com/pallets/jinja/issues/1591 https://github.com/aws/aws-sam-cli/issues/3661 2. Reverts #9136 Fixing build failures in SONiC utils [example](https://dev.azure.com/mssonic/build/_build/results?buildId=73784&view=logs&jobId=83516c17-6666-5250-abde-63983ce72a49&j=83516c17-6666-5250-abde-63983ce72a49&t=6177235f-d4f1-5f72-835a-90ebb93a1784) One of the errors: ``` TestPathAddressing.test_find_ref_paths__ref_is_the_whole_key__returns_ref_paths self = def test_find_ref_paths__ref_is_the_whole_key__returns_ref_paths(self): # Arrange path = "/PORT/Ethernet0" expected = [ "/ACL_TABLE/NO-NSW-PACL-V4/ports/0", "/VLAN_MEMBER/Vlan1000|Ethernet0", ] # Act actual = self.path_addressing.find_ref_paths(path, Files.CROPPED_CONFIG_DB_AS_JSON) # Assert > self.assertEqual(expected, actual) E AssertionError: Lists differ: ['/ACL_TABLE/NO-NSW-PACL-V4/ports/0', '/VLAN_MEMBER/Vlan1000|Ethernet0'] != ['/ACL_TABLE/NO-NSW-PACL-V4/ports/0'] E E First list contains 1 additional elements. E First extra element 1: E '/VLAN_MEMBER/Vlan1000|Ethernet0' E E - ['/ACL_TABLE/NO-NSW-PACL-V4/ports/0', '/VLAN_MEMBER/Vlan1000|Ethernet0'] E + ['/ACL_TABLE/NO-NSW-PACL-V4/ports/0'] ``` The VLAN_MEMBER backlink (can be called referrer link or ref link) is not found. Issue introduced by https://github.com/Azure/sonic-buildimage/pull/9136 I don't know how this PR passed the build system, it should have failed. Known YANG issue https://github.com/Azure/sonic-buildimage/issues/9312 #### How I did it The import to `sonic-vlan` is breaking the build ``` import sonic-vlan { prefix vlan; } ``` I am not sure if that's the only issue, so I think reverting the whole PR should be the safer option. #### How to verify it Ran sonic-utils tests locally. --- .../azure-pipelines-image-template.yml | 1 + src/sonic-yang-models/setup.py | 2 - .../tests/files/sample_config_db.json | 21 +-- .../tests/yang_model_tests/tests/nvgre.json | 25 ---- .../yang_model_tests/tests_config/nvgre.json | 125 ------------------ .../yang-models/sonic-nvgre-tunnel.yang | 114 ---------------- 6 files changed, 3 insertions(+), 285 deletions(-) delete mode 100644 src/sonic-yang-models/tests/yang_model_tests/tests/nvgre.json delete mode 100644 src/sonic-yang-models/tests/yang_model_tests/tests_config/nvgre.json delete mode 100644 src/sonic-yang-models/yang-models/sonic-nvgre-tunnel.yang diff --git a/.azure-pipelines/azure-pipelines-image-template.yml b/.azure-pipelines/azure-pipelines-image-template.yml index 0a83c334074..70c40d64b6a 100644 --- a/.azure-pipelines/azure-pipelines-image-template.yml +++ b/.azure-pipelines/azure-pipelines-image-template.yml @@ -43,6 +43,7 @@ jobs: [ -n "$SYSTEM_PULLREQUEST_PULLREQUESTID" ] && BRANCH_NAME="$SYSTEM_PULLREQUEST_TARGETBRANCH-$SYSTEM_PULLREQUEST_PULLREQUESTNUMBER" git checkout -b $BRANCH_NAME sudo modprobe overlay + pip3 install MarkupSafe==2.0.1 --force-reinstall sudo apt-get install -y acl sudo bash -c "echo 1 > /proc/sys/vm/compact_memory" ENABLE_DOCKER_BASE_PULL=y make PLATFORM=$(PLATFORM_AZP) PLATFORM_ARCH=$(PLATFORM_ARCH) $(BUILD_OPTIONS) configure diff --git a/src/sonic-yang-models/setup.py b/src/sonic-yang-models/setup.py index 17dcdeeaa5b..1f9b51b0c56 100644 --- a/src/sonic-yang-models/setup.py +++ b/src/sonic-yang-models/setup.py @@ -108,7 +108,6 @@ def run(self): './yang-models/sonic-mirror-session.yang', './yang-models/sonic-ntp.yang', './yang-models/sonic-nat.yang', - './yang-models/sonic-nvgre-tunnel.yang', './yang-models/sonic-pbh.yang', './yang-models/sonic-port.yang', './yang-models/sonic-policer.yang', @@ -166,7 +165,6 @@ def run(self): './cvlyang-models/sonic-mgmt_vrf.yang', './cvlyang-models/sonic-ntp.yang', './cvlyang-models/sonic-nat.yang', - './cvlyang-models/sonic-nvgre-tunnel.yang', './cvlyang-models/sonic-pbh.yang', './cvlyang-models/sonic-policer.yang', './cvlyang-models/sonic-port.yang', diff --git a/src/sonic-yang-models/tests/files/sample_config_db.json b/src/sonic-yang-models/tests/files/sample_config_db.json index 6c27047c9bc..e64b241349b 100644 --- a/src/sonic-yang-models/tests/files/sample_config_db.json +++ b/src/sonic-yang-models/tests/files/sample_config_db.json @@ -1540,7 +1540,7 @@ } }, - + "MCLAG_DOMAIN": { "123": { "source_ip": "12.1.1.1", @@ -1584,8 +1584,6 @@ } }, - - "POLICER": { "everflow_static_policer": { "meter_type": "bytes", @@ -1594,23 +1592,8 @@ "cbs": "12500000", "color": "aware", "red_packet_action": "drop" - } - }, - - - "NVGRE_TUNNEL": { - "tunnel_1": { - "src_ip": "10.0.0.1" - } - }, - "NVGRE_TUNNEL_MAP": { - "tunnel_1|Vlan111": { - "vlan_id": "111", - "vsid": "5000" - } + } } - - }, "SAMPLE_CONFIG_DB_UNKNOWN": { "UNKNOWN_TABLE": { diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/nvgre.json b/src/sonic-yang-models/tests/yang_model_tests/tests/nvgre.json deleted file mode 100644 index e776b0d9064..00000000000 --- a/src/sonic-yang-models/tests/yang_model_tests/tests/nvgre.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "NVGRE_TUNNEL_AND_TUNNEL_MAP": { - "desc": "NVGRE_TUNNEL with NVGRE_TUNNEL_MAP" - }, - - "NVGRE_TUNNEL_INVALID_SRC_IP": { - "desc": "INVALID src_ip value for NVGRE_TUNNEL", - "eStrKey": "InvalidValue" - }, - - "NVGRE_TUNNEL_MAP_UNEXISTING_NVGRE_TUNNEL_NAME": { - "desc": "Unexisting NVGRE_TUNNEL", - "eStrKey": "LeafRef" - }, - - "NVGRE_TUNNEL_MAP_INVALID_VLAN_ID": { - "desc": "Invalid VLAN ID", - "eStrKey": "Pattern" - }, - - "NVGRE_TUNNEL_MAP_INVALID_VSID": { - "desc": "INVALID VSID value for NVGRE_TUNNEL_MAP", - "eStrKey": "Pattern" - } -} \ No newline at end of file diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/nvgre.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/nvgre.json deleted file mode 100644 index 8c2588fa7d3..00000000000 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/nvgre.json +++ /dev/null @@ -1,125 +0,0 @@ -{ - "NVGRE_TUNNEL_AND_TUNNEL_MAP": { - "sonic-vlan:sonic-vlan": { - "sonic-vlan:VLAN": { - "VLAN_LIST": [ - { - "name": "Vlan200" - } - ] - } - }, - "sonic-nvgre-tunnel:sonic-nvgre-tunnel": { - "sonic-nvgre-tunnel:NVGRE_TUNNEL": { - "NVGRE_TUNNEL_LIST": [ - { - "tunnel_name": "tunnel_1", - "src_ip": "10.0.0.1" - } - ] - }, - "sonic-nvgre-tunnel:NVGRE_TUNNEL_MAP": { - "NVGRE_TUNNEL_MAP_LIST": [ - { - "tunnel_name": "tunnel_1", - "tunnel_map_name": "Vlan200", - "vlan_id": 200, - "vsid": 5000 - } - ] - } - } - }, - - "NVGRE_TUNNEL_INVALID_SRC_IP": { - "sonic-nvgre-tunnel:sonic-nvgre-tunnel": { - "sonic-nvgre-tunnel:NVGRE_TUNNEL": { - "NVGRE_TUNNEL_LIST": [ - { - "tunnel_name": "tunnel_1", - "src_ip": "INVALID" - } - ] - } - } - }, - - "NVGRE_TUNNEL_MAP_UNEXISTING_NVGRE_TUNNEL_NAME": { - "sonic-vlan:sonic-vlan": { - "sonic-vlan:VLAN": { - "VLAN_LIST": [ - { - "name": "Vlan200" - } - ] - } - }, - "sonic-nvgre-tunnel:sonic-nvgre-tunnel": { - "sonic-nvgre-tunnel:NVGRE_TUNNEL_MAP": { - "NVGRE_TUNNEL_MAP_LIST": [ - { - "tunnel_name": "INVALID", - "tunnel_map_name": "Vlan200", - "vlan_id": 200, - "vsid": 5000 - } - ] - } - } - }, - - "NVGRE_TUNNEL_MAP_INVALID_VLAN_ID": { - "sonic-nvgre-tunnel:sonic-nvgre-tunnel": { - "sonic-nvgre-tunnel:NVGRE_TUNNEL": { - "NVGRE_TUNNEL_LIST": [ - { - "tunnel_name": "tunnel_1", - "src_ip": "10.0.0.1" - } - ] - }, - "sonic-nvgre-tunnel:NVGRE_TUNNEL_MAP": { - "NVGRE_TUNNEL_MAP_LIST": [ - { - "tunnel_name": "tunnel_1", - "tunnel_map_name": "Vlan200", - "vlan_id": 5000, - "vsid": 5000 - } - ] - } - } - }, - - "NVGRE_TUNNEL_MAP_INVALID_VSID": { - "sonic-vlan:sonic-vlan": { - "sonic-vlan:VLAN": { - "VLAN_LIST": [ - { - "name": "Vlan200" - } - ] - } - }, - "sonic-nvgre-tunnel:sonic-nvgre-tunnel": { - "sonic-nvgre-tunnel:NVGRE_TUNNEL": { - "NVGRE_TUNNEL_LIST": [ - { - "tunnel_name": "tunnel_1", - "src_ip": "10.0.0.1" - } - ] - }, - "sonic-nvgre-tunnel:NVGRE_TUNNEL_MAP": { - "NVGRE_TUNNEL_MAP_LIST": [ - { - "tunnel_name": "tunnel_1", - "tunnel_map_name": "Vlan200", - "vlan_id": 200, - "vsid": 999999999 - } - ] - } - } - } -} \ No newline at end of file diff --git a/src/sonic-yang-models/yang-models/sonic-nvgre-tunnel.yang b/src/sonic-yang-models/yang-models/sonic-nvgre-tunnel.yang deleted file mode 100644 index 42ab3921a4a..00000000000 --- a/src/sonic-yang-models/yang-models/sonic-nvgre-tunnel.yang +++ /dev/null @@ -1,114 +0,0 @@ -module sonic-nvgre-tunnel { - - yang-version 1.1; - - namespace "http://github.com/Azure/sonic-nvgre-tunnel"; - prefix nvgre; - - import ietf-inet-types { - prefix inet; - } - - import sonic-vlan { - prefix vlan; - } - - - organization - "SONiC"; - - contact - "SONiC"; - - description - "NVGRE Tunnel YANG Module for SONiC OS"; - - revision 2021-10-31 { - description - "First Revision"; - } - - container sonic-nvgre-tunnel { - - container NVGRE_TUNNEL { - - description "NVGRE_TUNNEL part of config_db.json"; - - list NVGRE_TUNNEL_LIST { - - key "tunnel_name"; - - leaf tunnel_name { - description "NVGRE Tunnel name"; - - type string { - length 1..255; - } - } - - leaf src_ip { - description "Source IP address"; - - mandatory true; - type inet:ip-address; - } - - } - /* end of NVGRE_TUNNEL_LIST */ - - } - /* end of container NVGRE_TUNNEL */ - - container NVGRE_TUNNEL_MAP { - - description "NVGRE_TUNNEL_MAP part of config_db.json"; - - list NVGRE_TUNNEL_MAP_LIST { - - key "tunnel_name tunnel_map_name"; - - leaf tunnel_name { - description "NVGRE Tunnel name"; - - type leafref { - path /nvgre:sonic-nvgre-tunnel/nvgre:NVGRE_TUNNEL/nvgre:NVGRE_TUNNEL_LIST/nvgre:tunnel_name; - } - } - - leaf tunnel_map_name { - description "NVGRE Tunnel map name"; - - type string { - length 1..255; - } - } - - leaf vlan_id { - description "VLAN identifier"; - - mandatory true; - type uint16 { - range 1..4094; - } - } - - leaf vsid { - description "Virtual Subnet Identifier"; - - mandatory true; - type uint32 { - range 0..16777214; - } - } - - } - /* end of NVGRE_TUNNEL_MAP_LIST */ - - } - /* end of container NVGRE_TUNNEL_MAP */ - - } - /* end of container sonic-nvgre-tunnel */ - -} -/* end of module sonic-nvgre-tunnel */