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

Fix network.traceroute exec module function #52370

Merged
merged 3 commits into from Apr 3, 2019

Conversation

@jfindlay
Copy link
Contributor

commented Apr 1, 2019

What does this PR do?

Armoring the unprotected list dereferences and redirecting the problematic lines to the log seemed like the best solution to this optimistically quixotic function. Perhaps a future enterprising adventurer can dig into the source code of the many variants of traceroute and with unit tests provide a more orthogonal result.

Previous Behavior

# salt-call --local -l warning network.traceroute gentoo.org
[ERROR   ] An un-handled exception was caught by salt's global exception handler:
IndexError: list index out of range
Traceback (most recent call last):
  File "/usr/lib/python-exec/python2.7/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 941, in traceroute
    'ms3': float(comps[4].split()[0])}
IndexError: list index out of range

New Behavior

# salt-call --local -l warning network.traceroute gentoo.org
[WARNING ] Cannot parse traceroute output line:  8  be3037.ccr21.den01.atlas.cogentco.com (154.54.41.146)  49.349 ms be3038.ccr22.den01.atlas.cogentco.com (154.54.42.98)  50.383 ms *
[WARNING ] Cannot parse traceroute output line: 15  be3579.rcr51.lba01.atlas.cogentco.com (154.54.57.250)  162.295 ms *  162.492 ms
local:
    [...]
    |_
      ----------
      count:
          19
      hostname:
          www.gentoo.org
      ip: 
          89.16.167.134
      ms1:
          168.193
      ms2:
          163.027
      ms3:
          163.405

What issues does this PR fix or reference?

#21927

Tests written?

No

Commits signed with GPG?

Yes

jfindlay added 3 commits Mar 29, 2019
@jfindlay jfindlay force-pushed the jfindlay:traceroute branch from b509671 to 2f49231 Apr 3, 2019
@dwoz
dwoz approved these changes Apr 3, 2019
@dwoz dwoz merged commit c1063cf into saltstack:2019.2 Apr 3, 2019
10 checks passed
10 checks passed
WIP Ready for review
Details
continuous-integration/jenkins/pr-merge This commit looks good
Details
jenkins/pr/docs The docs job has passed
Details
jenkins/pr/lint Python lint test has passed
Details
jenkins/pr/py2-centos-7 The py2-centos-7 job has passed
Details
jenkins/pr/py2-ubuntu-1604 The py2-ubuntu-1604 job has passed
Details
jenkins/pr/py2-windows-2016 The py2-windows-2016 job has passed
Details
jenkins/pr/py3-centos-7 The py3-centos-7 job has passed
Details
jenkins/pr/py3-ubuntu-1604 The py3-ubuntu-1604 job has passed
Details
jenkins/pr/py3-windows-2016 The py3-windows-2016 job has passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.