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

[master] Do not make Salt CLI to crash when there are IPv6 established connections #55583

Conversation

meaksh
Copy link
Contributor

@meaksh meaksh commented Dec 10, 2019

This PR ports #52888 to master branch, and fixes an issue at 2019.2.x release.


What does this PR do?

This PR fixes an issue in utils/network.py which is making the Salt CLI to crash when some of the targeted minions cannot be reached.

Currently, the _netlink_tool_remote_on function is not taking care of possible IPv6 entries returned by ss -ant.

When there are minions that did not response on time, then this code is executed. In case the underlying call to ss -ant returns an IPv6 entry, this would make the Salt CLI to crash while trying to parse the host/port.

Previous Behavior

# salt '*' test.ping
minion1:
    True
minion2:
    True
[ERROR   ] An un-handled exception was caught by salt's global exception handler:
ValueError: invalid literal for int() with base 10: ':ffff:10.111.111.111]:9100'
Traceback (most recent call last):
  File "/usr/bin/salt", line 10, in <module>
    salt_main()
  File "/usr/lib/python3.6/site-packages/salt/scripts.py", line 516, in salt_main
    client.run()
  File "/usr/lib/python3.6/site-packages/salt/cli/salt.py", line 194, in run
    for full_ret in cmd_func(**kwargs):
  File "/usr/lib/python3.6/site-packages/salt/client/__init__.py", line 746, in cmd_cli
    **kwargs):
  File "/usr/lib/python3.6/site-packages/salt/client/__init__.py", line 1508, in get_cli_event_returns
    connected_minions = salt.utils.minions.CkMinions(self.opts).connected_ids()
  File "/usr/lib/python3.6/site-packages/salt/utils/minions.py", line 643, in connected_ids
    addrs = salt.utils.network.local_port_tcp(int(self.opts['publish_port']))
  File "/usr/lib/python3.6/site-packages/salt/utils/network.py", line 1384, in local_port_tcp
    ret = _remotes_on(port, 'local_port')
  File "/usr/lib/python3.6/site-packages/salt/utils/network.py", line 1402, in _remotes_on
    ret = _netlink_tool_remote_on(port, which_end)
  File "/usr/lib/python3.6/site-packages/salt/utils/network.py", line 1494, in _netlink_tool_remote_on
    if which_end == 'local_port' and int(local_port) != port:
ValueError: invalid literal for int() with base 10: ':ffff:10.111.111.111]:9100'

New Behavior

# salt '*' test.ping
minion1:
    True
minion2:
    True
minion3:
    Minion did not return. [No response]
ERROR: Minions returned with non-zero exit code

Tests written?

Yes

Commits signed with GPG?

Yes

Please review Salt's Contributing Guide for best practices.

See GitHub's page on GPG signing for more information about signing commits with GPG.

Copy link
Contributor

@dwoz dwoz left a comment

Choose a reason for hiding this comment

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

@meaksh Please address the test failures.

@meaksh
Copy link
Contributor Author

meaksh commented Jan 10, 2020

@dwoz the test failure should be fixed now 👍

@dwoz
Copy link
Contributor

dwoz commented Jan 10, 2020

@meaksh Awesome, thanks!

@dwoz dwoz merged commit 1ef11f6 into saltstack:master Jan 12, 2020
@meaksh meaksh deleted the master-prevent-crashing-if-ss-returns-ipv6-connections branch January 13, 2020 08:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants