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

salt minion won't start: Non valid IP address match on BSD alias format #29833

Closed
iMilnb opened this issue Dec 18, 2015 · 7 comments
Closed

salt minion won't start: Non valid IP address match on BSD alias format #29833

iMilnb opened this issue Dec 18, 2015 · 7 comments
Assignees
Labels
Bug broken, incorrect, or confusing behavior Core relates to code central or existential to Salt info-needed waiting for more info P4 Priority 4 Platform Relates to OS, containers, platform-based utilities like FS, system based apps severity-high 2nd top severity, seen by most users, causes major problems
Milestone

Comments

@iMilnb
Copy link
Contributor

iMilnb commented Dec 18, 2015

While starting a minion on NetBSD with a couple of IP aliases (will probably happen on FreeBSD and OpenBSD in this scenario) I get the following traceback:

2015-12-18 11:03:40,410 [salt.scripts                             ][ERROR   ][18580] Minion failed to start: 
Traceback (most recent call last):
  File "/usr/pkg/lib/python2.7/site-packages/salt/scripts.py", line 81, in minion_process
    minion.start()
  File "/usr/pkg/lib/python2.7/site-packages/salt/cli/daemons.py", line 272, in start
    self.prepare()
  File "/usr/pkg/lib/python2.7/site-packages/salt/cli/daemons.py", line 254, in prepare
    self.minion = salt.minion.Minion(self.config)
  File "/usr/pkg/lib/python2.7/site-packages/salt/minion.py", line 708, in __init__
    self.opts['grains'] = salt.loader.grains(opts)
  File "/usr/pkg/lib/python2.7/site-packages/salt/loader.py", line 613, in grains
    ret = fun()
  File "/usr/pkg/lib/python2.7/site-packages/salt/grains/core.py", line 1430, in ip4
    return {'ipv4': salt.utils.network.ip_addrs(include_loopback=True)}
  File "/usr/pkg/lib/python2.7/site-packages/salt/utils/network.py", line 993, in ip_addrs
    return _ip_addrs(interface, include_loopback, interface_data, 'inet')
  File "/usr/pkg/lib/python2.7/site-packages/salt/utils/network.py", line 981, in _ip_addrs
    addr = ipaddress.ip_address(addr.get('address'))
  File "/usr/pkg/lib/python2.7/site-packages/salt/ext/ipaddress.py", line 117, in ip_address
    address)
ValueError: 'alias' does not appear to be an IPv4 or IPv6 address
2015-12-18 11:03:40,420 [salt.scripts                             ][WARNING ][18580] ** Restarting minion **

This error probably comes from the fact that BSD IP aliases are shown this way:

xennet0: flags=8863<UP,BROADCAST,NOTRAILERS,RUNNING,SIMPLEX,MULTICAST> mtu 1500
        capabilities=2800<TCP4CSUM_Tx,UDP4CSUM_Tx>
        enabled=0
        address: 00:50:57:19:e0:a0
        inet 192.168.0.2 netmask 0xffffff00 broadcast 192.168.0.255
        inet alias 172.16.0.1 netmask 0xffffffff broadcast 172.16.0.1
[...]
@jfindlay jfindlay added the info-needed waiting for more info label Dec 18, 2015
@jfindlay jfindlay added this to the Blocked milestone Dec 18, 2015
@jfindlay
Copy link
Contributor

@iMilnb, thanks for the report. What version of salt are you using?

@iMilnb
Copy link
Contributor Author

iMilnb commented Dec 21, 2015

@jfindlay salt 2015.8.3

@jfindlay jfindlay modified the milestones: Approved, Blocked Dec 22, 2015
@jfindlay jfindlay added Bug broken, incorrect, or confusing behavior severity-high 2nd top severity, seen by most users, causes major problems P4 Priority 4 Platform Relates to OS, containers, platform-based utilities like FS, system based apps Core relates to code central or existential to Salt and removed info-needed waiting for more info labels Dec 22, 2015
@meggiebot meggiebot modified the milestones: B 6, Approved Dec 22, 2015
@cachedout
Copy link
Contributor

I'm not a FreeBSD user, so forgive my ignorance, but I'm not seeing that same output from ifconfig that you seem to be showing. After I add some aliases like follows:

root@mp-bsd:~ # ifconfig xn1 127.0.0.129 netmask 255.255.255.255 alias

I see ifconfig output like this:

root@mp-bsd:~ # ifconfig -a
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
    options=600003<RXCSUM,TXCSUM,RXCSUM_IPV6,TXCSUM_IPV6>
    inet6 ::1 prefixlen 128 
    inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1 
    inet 127.0.0.1 netmask 0xff000000 
    nd6 options=23<PERFORMNUD,ACCEPT_RTADV,AUTO_LINKLOCAL>
xn0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
    options=503<RXCSUM,TXCSUM,TSO4,LRO>
    ether bc:76:4e:11:d4:2b
    inet6 fe80::be76:4eff:fe11:d42b%xn0 prefixlen 64 scopeid 0x2 
    inet 192.237.188.54 netmask 0xffffff00 broadcast 192.237.188.255 
    inet6 2001:4801:7821:77:be76:4eff:fe11:d42b prefixlen 64 
    nd6 options=23<PERFORMNUD,ACCEPT_RTADV,AUTO_LINKLOCAL>
    media: Ethernet manual
    status: active
xn1: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
    options=503<RXCSUM,TXCSUM,TSO4,LRO>
    ether bc:76:4e:11:b2:8f
    inet6 fe80::be76:4eff:fe11:b28f%xn1 prefixlen 64 scopeid 0x3 
    inet 10.208.130.111 netmask 0xffff8000 broadcast 10.208.255.255 
    inet 127.0.0.127 netmask 0xffffffff broadcast 127.0.0.127 
    inet 127.0.0.128 netmask 0xffffffff broadcast 127.0.0.128 
    inet 127.0.0.129 netmask 0xffffffff broadcast 127.0.0.129 
    nd6 options=23<PERFORMNUD,ACCEPT_RTADV,AUTO_LINKLOCAL>
    media: Ethernet manual
    status: active

Salt's utility functions seem to have no problem with this:

root@mp-bsd:~ # python2
Python 2.7.10 (default, Jul 23 2015, 01:22:23) 
[GCC 4.2.1 Compatible FreeBSD Clang 3.4.1 (tags/RELEASE_34/dot1-final 208032)] on freebsd10
Type "help", "copyright", "credits" or "license" for more information.
>>> import salt.utils.network
>>> salt.utils.network.ip_addrs
<function ip_addrs at 0x807511aa0>
>>> salt.utils.network.ip_addrs()
['10.208.130.111', '192.237.188.54']
>>> salt.utils.network.ip_addrs(include_loopback=True)
['10.208.130.111', '127.0.0.1', '127.0.0.127', '127.0.0.128', '127.0.0.129', '192.237.188.54']
>>> quit
Use quit() or Ctrl-D (i.e. EOF) to exit
>>> 

Where am I going wrong here?

@cachedout cachedout added the info-needed waiting for more info label Dec 22, 2015
@iMilnb
Copy link
Contributor Author

iMilnb commented Dec 23, 2015

@cachedout seems like FreeBSD does not indicate if an IP address is an alias or not. In NetBSD we have the following:

xennet0: flags=8863<UP,BROADCAST,NOTRAILERS,RUNNING,SIMPLEX,MULTICAST> mtu 1500
        capabilities=2800<TCP4CSUM_Tx,UDP4CSUM_Tx>
        enabled=0
        address: 00:50:57:0a:00:04
        inet 192.168.0.1 netmask 0xffffff00 broadcast 192.168.0.255
        inet alias 172.16.0.1 netmask 0xffffffff broadcast 172.16.0.1
        inet alias 172.16.1.1 netmask 0xffffff00 broadcast 172.16.1.255
[...]

Obviously FreeBSD != NetBSD. Don't know how OpenBSD shows it.

I can confirm I have the same behaviour while using salt functions:

Python 2.7.10 (default, Nov 26 2015, 14:07:58) 
[GCC 4.5.3] on netbsd6
Type "help", "copyright", "credits" or "license" for more information.
>>> import salt.utils.network
>>> salt.utils.network.ip_addrs
<function ip_addrs at 0x7f7ff4bada28>
>>> salt.utils.network.ip_addrs()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/pkg/lib/python2.7/site-packages/salt/utils/network.py", line 993, in ip_addrs
    return _ip_addrs(interface, include_loopback, interface_data, 'inet')
  File "/usr/pkg/lib/python2.7/site-packages/salt/utils/network.py", line 981, in _ip_addrs
    addr = ipaddress.ip_address(addr.get('address'))
  File "/usr/pkg/lib/python2.7/site-packages/salt/ext/ipaddress.py", line 117, in ip_address
    address)
ValueError: 'alias' does not appear to be an IPv4 or IPv6 address

@iMilnb
Copy link
Contributor Author

iMilnb commented Dec 28, 2015

A simple fix consists in replacing:

pip = re.compile(r'.*?(?:inet addr:|inet )(.*?)\s')

with:

pip = re.compile(r'.*?(?:inet addr:|inet [^\d]*)(.*?)\s')

in salt/utils/network.py

@cachedout
Copy link
Contributor

@iMilnb Would you like to send that change over as a PR? We can run the test suite on it and see how things go.

abednarik added a commit to abednarik/salt that referenced this issue Jan 2, 2016
As suggested by @iMilnb regex updated. The other way around is fix this would be
to use the same approach as for Solaris systems adding a elif statement when system
is OpenBSD.

Fixes saltstack#29833.
@cachedout
Copy link
Contributor

Fixed by #30124. Closing.

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 Core relates to code central or existential to Salt info-needed waiting for more info P4 Priority 4 Platform Relates to OS, containers, platform-based utilities like FS, system based apps severity-high 2nd top severity, seen by most users, causes major problems
Projects
None yet
Development

No branches or pull requests

4 participants