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

[frr] fix pfx_filter in sonic-cfggen #2994

Merged
merged 1 commit into from
Jun 14, 2019

Conversation

stepanblyschak
Copy link
Collaborator

Otherwise:

Traceback (most recent call last):
  File "/usr/local/bin/sonic-cfggen", line 276, in <module>
    main()
  File "/usr/local/bin/sonic-cfggen", line 253, in main
    print(template.render(sort_data(data)))
  File "/usr/local/lib/python2.7/dist-packages/jinja2/environment.py", line 1008, in render
    return self.environment.handle_exception(exc_info, True)
  File "/usr/local/lib/python2.7/dist-packages/jinja2/environment.py", line 780, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/share/sonic/templates/bgpd.conf.j2", line 49, in top-level template code
    {% block vlan_advertisement %}
  File "/usr/share/sonic/templates/bgpd.conf.j2", line 50, in block "vlan_advertisement"
    {% for (name, prefix) in VLAN_INTERFACE|pfx_filter %}
  File "/usr/local/bin/sonic-cfggen", line 96, in pfx_filter
    for key,val in value.items():
jinja2.exceptions.UndefinedError: 'VLAN_INTERFACE' is undefined

and

root@arc-switch1004:/# vtysh

Hello, this is FRRouting (version 7.0.1-sonic).
Copyright 1996-2005 Kunihiro Ishiguro, et al.

arc-switch1004# show bgp su
% BGP instance not found
arc-switch1004#
root@arc-switch1004:/# cat /etc/frr/bgpd.conf
root@arc-switch1004:/#

Signed-off-by: Stepan Blyschak stepanb@mellanox.com

- What I did

- How I did it

- How to verify it
Run on DUT on topology without VLAN

- Description for the changelog

- A picture of a cute animal (not mandatory but encouraged)

@lguohan
Copy link
Collaborator

lguohan commented Jun 13, 2019

I do not see this configuration in the quagga bgpd.conf.j2, not sure why this is not a problem for that?

@lguohan lguohan requested a review from prsunny June 13, 2019 05:56
@lguohan
Copy link
Collaborator

lguohan commented Jun 13, 2019

@prsunny, it looks like the root cause is this pfx_filter should expect None value. Since pfx_filter is added in many places, I think it is better to fix pfx_filter instead of here.

def pfx_filter(value):
    """INTERFACE Table can have keys in one of the two formats:
       string or tuple - This filter skips the string keys and only
       take into account the tuple.
       For eg - VLAN_INTERFACE|Vlan1000 vs VLAN_INTERFACE|Vlan1000|192.168.0.1/21
    """
    table = OrderedDict()
    for key,val in value.items():
        if not isinstance(key, tuple):
            continue
        table[key] = val
    return table

Copy link
Collaborator

@lguohan lguohan left a comment

Choose a reason for hiding this comment

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

need to fix the root problem. the root cause is the new function introduced in pfx_filter.

interfaces

Otherwise:

"
Traceback (most recent call last):
  File "/usr/local/bin/sonic-cfggen", line 276, in <module>
    main()
  File "/usr/local/bin/sonic-cfggen", line 253, in main
    print(template.render(sort_data(data)))
  File "/usr/local/lib/python2.7/dist-packages/jinja2/environment.py", line 1008, in render
    return self.environment.handle_exception(exc_info, True)
  File "/usr/local/lib/python2.7/dist-packages/jinja2/environment.py", line 780, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/share/sonic/templates/bgpd.conf.j2", line 49, in top-level template code
    {% block vlan_advertisement %}
  File "/usr/share/sonic/templates/bgpd.conf.j2", line 50, in block "vlan_advertisement"
    {% for (name, prefix) in VLAN_INTERFACE|pfx_filter %}
  File "/usr/local/bin/sonic-cfggen", line 96, in pfx_filter
    for key,val in value.items():
jinja2.exceptions.UndefinedError: 'VLAN_INTERFACE' is undefined
"

and

"
root@arc-switch1004:/# vtysh

Hello, this is FRRouting (version 7.0.1-sonic).
Copyright 1996-2005 Kunihiro Ishiguro, et al.

arc-switch1004# show bgp su
% BGP instance not found
arc-switch1004#
root@arc-switch1004:/# cat /etc/frr/bgpd.conf
root@arc-switch1004:/#
"

Signed-off-by: Stepan Blyschak <stepanb@mellanox.com>
@NStetskovych-zz
Copy link
Contributor

NStetskovych-zz commented Jun 13, 2019

pfx_filter issue also seen for arp_update:

Jun 13 15:27:04.959117 cab18-3-switch3 INFO swss#supervisord: arp_update Traceback (most recent call last): Jun 13 15:27:04.959117 cab18-3-switch3 INFO swss#supervisord: arp_update File "/usr/local/bin/sonic-cfggen", line 276, in <module> Jun 13 15:27:04.959625 cab18-3-switch3 INFO swss#supervisord: arp_update main() Jun 13 15:27:04.959710 cab18-3-switch3 INFO swss#supervisord: arp_update File "/usr/local/bin/sonic-cfggen", line 253, in main Jun 13 15:27:04.959710 cab18-3-switch3 INFO swss#supervisord: arp_update print(template.render(sort_data(data))) Jun 13 15:27:04.959710 cab18-3-switch3 INFO swss#supervisord: arp_update File "/usr/local/lib/python2.7/dist-packages/jinja2/environment.py", line 1008, in render Jun 13 15:27:04.959710 cab18-3-switch3 INFO swss#supervisord: arp_update return self.environment.handle_exception(exc_info, True) Jun 13 15:27:04.959710 cab18-3-switch3 INFO swss#supervisord: arp_update File "/usr/local/lib/python2.7/dist-packages/jinja2/environment.py", line 780, in handle_exception Jun 13 15:27:04.959710 cab18-3-switch3 INFO swss#supervisord: arp_update reraise(exc_type, exc_value, tb) Jun 13 15:27:04.959710 cab18-3-switch3 INFO swss#supervisord: arp_update File "/tmp/intf_tmp.j2", line 1, in top-level template code Jun 13 15:27:04.959710 cab18-3-switch3 INFO swss#supervisord: arp_update {% for (name, prefix) in INTERFACE|pfx_filter %} {{name}} {% endfor %} Jun 13 15:27:04.959710 cab18-3-switch3 INFO swss#supervisord: arp_update File "/usr/local/bin/sonic-cfggen", line 96, in pfx_filter Jun 13 15:27:04.959737 cab18-3-switch3 INFO swss#supervisord: arp_update for key,val in value.items(): Jun 13 15:27:04.959737 cab18-3-switch3 INFO swss#supervisord: arp_update jinja2.exceptions.UndefinedError: 'INTERFACE' is undefined

@stepanblyschak stepanblyschak changed the title [frr] fix bgpd.conf.j2 rendering when there is no vlan interface [frr] fix pfx_filter in sonic-cfggen Jun 13, 2019
@lguohan
Copy link
Collaborator

lguohan commented Jun 13, 2019

@prsunny, please review.

@lguohan lguohan merged commit 383fc0f into sonic-net:master Jun 14, 2019
@stepanblyschak stepanblyschak deleted the fix_bgpdconf branch September 23, 2022 13:30
yxieca pushed a commit that referenced this pull request Dec 18, 2023
…lly (#17545)

src/sonic-swss

* 19affd32 - (HEAD -> 202205, origin/202205) [muxorch][202205] Fixing cache bug in updateRoute logic (#2994) (3 hours ago) [Nikola Dancejic]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants