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

saltstack network module fails with ecmp routes #58377

Open
djal opened this issue Sep 4, 2020 · 3 comments
Open

saltstack network module fails with ecmp routes #58377

djal opened this issue Sep 4, 2020 · 3 comments
Labels
Bug broken, incorrect, or confusing behavior severity-medium 3rd level, incorrect or bad functionality, confusing and lacks a work around
Milestone

Comments

@djal
Copy link

djal commented Sep 4, 2020

Description of Issue

Salt network module not working when default route has several destinations.

Setup

Routing table looks like:

default proto bird metric 32 
	nexthop via 1.2.3.4 dev eth1 weight 1 
	nexthop via 2.3.4.5 dev eth2 weight 1 

and salt-call network.routes fails with:

[ERROR   ] An un-handled exception was caught by salt's global exception handler:
ValueError: u'nexthop' does not appear to be an IPv4 or IPv6 network
Traceback (most recent call last):
  File "/usr/bin/salt-call", line 11, in <module>
    salt_call()
  File "/usr/lib/python2.7/site-packages/salt/scripts.py", line 431, in salt_call
    client.run()
  File "/usr/lib/python2.7/site-packages/salt/cli/call.py", line 57, in run
    caller.run()
  File "/usr/lib/python2.7/site-packages/salt/cli/caller.py", line 138, in run
    ret = self.call()
  File "/usr/lib/python2.7/site-packages/salt/cli/caller.py", line 237, in call
    ret['return'] = self.minion.executors[fname](self.opts, data, func, args, kwargs)
  File "/usr/lib/python2.7/site-packages/salt/executors/direct_call.py", line 12, in execute
    return func(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/salt/modules/network.py", line 1686, in default_route
    _routes = routes()
  File "/usr/lib/python2.7/site-packages/salt/modules/network.py", line 1643, in routes
    routes_ = _ip_route_linux()
  File "/usr/lib/python2.7/site-packages/salt/modules/network.py", line 514, in _ip_route_linux
    address_mask = convert_cidr(comps[0])
  File "/usr/lib/python2.7/site-packages/salt/modules/network.py", line 1145, in convert_cidr
    cidr = calc_net(cidr)
  File "/usr/lib/python2.7/site-packages/salt/modules/network.py", line 1167, in calc_net
    return salt.utils.network.calc_net(ip_addr, netmask)
  File "/usr/lib/python2.7/site-packages/salt/utils/network.py", line 1087, in calc_net
    return six.text_type(ipaddress.ip_network(ipaddr, strict=False))
  File "/usr/lib/python2.7/site-packages/salt/ext/ipaddress.py", line 150, in ip_network
    address)
ValueError: u'nexthop' does not appear to be an IPv4 or IPv6 network

Versions Report

Salt Version:
           Salt: 2019.2.2
 
Dependency Versions:
           cffi: 1.6.0
       cherrypy: Not Installed
       dateutil: Not Installed
      docker-py: 1.10.6
          gitdb: Not Installed
      gitpython: Not Installed
          ioflo: Not Installed
         Jinja2: 2.7.2
        libgit2: 0.26.3
        libnacl: Not Installed
       M2Crypto: Not Installed
           Mako: 0.8.1
   msgpack-pure: Not Installed
 msgpack-python: 0.5.6
   mysql-python: Not Installed
      pycparser: 2.14
       pycrypto: 2.6.1
   pycryptodome: 3.7.3
         pygit2: 0.26.4
         Python: 2.7.5 (default, Aug  7 2019, 00:51:29)
   python-gnupg: Not Installed
         PyYAML: 3.11
          PyZMQ: 15.3.0
           RAET: Not Installed
          smmap: Not Installed
        timelib: Not Installed
        Tornado: 4.2.1
            ZMQ: 4.1.4
 
System Versions:
           dist: centos 7.7.1908 Core
         locale: UTF-8
        machine: x86_64
        release: 4.17.6-1.el7.elrepo.x86_64
         system: Linux
        version: CentOS Linux 7.7.1908 Core
@sagetherage
Copy link
Contributor

@djal Salt v2019.2.2 is no longer supported, are you also seeing this on supported versions of Salt?

@garethgreenaway
Copy link
Contributor

This seems like a bug to me. I don't think anyone considered that there could be multiple routes on a machine running Salt.

@garethgreenaway garethgreenaway added Bug broken, incorrect, or confusing behavior severity-medium 3rd level, incorrect or bad functionality, confusing and lacks a work around and removed needs-triage labels Nov 3, 2020
@garethgreenaway garethgreenaway added this to the Approved milestone Nov 3, 2020
@fly-agaric
Copy link

Reproduced on Salt v2019.2.5 and v3002.2
If routing table looks like

::1 dev lo proto kernel metric 256 pref medium
fe80::/64 dev xxx proto kernel metric 100 pref medium
local ::1 dev lo table local proto kernel metric 0 pref medium
local fe80::250:xxxx:xxxx:xxxx dev xxx table local proto kernel metric 0 pref medium
multicast ff00::/8 dev xxx table local proto kernel metric 256 pref medium

got an error

Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/salt/utils/templates.py", line 394, in render_jinja_tmpl
output = template.render(**decoded_context)
File "/usr/lib/python3/dist-packages/jinja2/asyncsupport.py", line 76, in render
return original_render(self, *args, **kwargs)
File "/usr/lib/python3/dist-packages/jinja2/environment.py", line 1008, in render
return self.environment.handle_exception(exc_info, True)
File "/usr/lib/python3/dist-packages/jinja2/environment.py", line 780, in handle_exception
reraise(exc_type, exc_value, tb)
File "/usr/lib/python3/dist-packages/jinja2/_compat.py", line 37, in reraise
raise value.with_traceback(tb)
File "<template>", line 130, in top-level template code
File "/usr/lib/python3/dist-packages/salt/modules/network.py", line 1643, in routes
routes_ = _ip_route_linux()
File "/usr/lib/python3/dist-packages/salt/modules/network.py", line 565, in _ip_route_linux
address_mask = convert_cidr(comps[0])
File "/usr/lib/python3/dist-packages/salt/modules/network.py", line 1145, in convert_cidr
cidr = calc_net(cidr)
File "/usr/lib/python3/dist-packages/salt/modules/network.py", line 1167, in calc_net
return salt.utils.network.calc_net(ip_addr, netmask)
File "/usr/lib/python3/dist-packages/salt/utils/network.py", line 1087, in calc_net
return six.text_type(ipaddress.ip_network(ipaddr, strict=False))
File "/usr/lib/python3.7/ipaddress.py", line 84, in ip_network
address)
ValueError: 'multicast' does not appear to be an IPv4 or IPv6 network

perhaps the point is that it is used 'ip -6 route show table all’
https://github.com/saltstack/salt/blob/v2019.2.5/salt/modules/network.py#L528
instead of 'ip -4 route show table main’.
https://github.com/saltstack/salt/blob/v2019.2.5/salt/modules/network.py#L491
Why use ‘all'?

v3002.2 has the same issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug broken, incorrect, or confusing behavior severity-medium 3rd level, incorrect or bad functionality, confusing and lacks a work around
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants