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

Proxy times out when calling function from Salt Engine #58

Open
TheBirdsNest opened this issue Mar 25, 2019 · 5 comments
Open

Proxy times out when calling function from Salt Engine #58

TheBirdsNest opened this issue Mar 25, 2019 · 5 comments

Comments

@TheBirdsNest
Copy link

TheBirdsNest commented Mar 25, 2019

Hi,

I'm trying to use a Salt Engine running within a Proxy Minion process to periodically execute remote commands. Every 10 seconds the engine attempts to call net.ping on the router as follows:

while True:
   test = __salt__['net.ping']('8.8.8.8')
   log.info(test)
   time.sleep(10)

When executing, it causes the connection to end and the proxy restarts.. Looking at the debug, I see in the write_channel the command is issued but a reply is not ready for 60 seconds at which point the keepalive function is called and assumes the proxy is down.

@TheBirdsNest TheBirdsNest changed the title Question: Correct use of Napalm in Proxy Engine Proxy times out when calling function from Salt Engine Mar 25, 2019
@TheBirdsNest
Copy link
Author

TheBirdsNest commented Mar 25, 2019

From looking at the command history, I can see when executing the above command via the engine, the following appears on the router:

%SSH-3-BAD_PACK_LEN: Bad packet length -1118152816

@TheBirdsNest
Copy link
Author

TheBirdsNest commented Mar 25, 2019

[ERROR   ] Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/salt/utils/napalm.py", line 178, in call
    out = getattr(napalm_device.get('DRIVER'), method)(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/napalm/ios/ios.py", line 2491, in ping
    output = self._send_command(command)
  File "/usr/lib/python2.7/site-packages/napalm/ios/ios.py", line 189, in _send_command
    raise ConnectionClosedException(str(e))
ConnectionClosedException

@TheBirdsNest
Copy link
Author

TheBirdsNest commented Mar 25, 2019

[DEBUG   ] read_channel:
[DEBUG   ] write_channel: ping 8.8.8.8 timeout 2 size 100 repeat 5

[DEBUG   ] read_channel:
[DEBUG   ] read_channel:
[DEBUG   ] read_channel:
[DEBUG   ] read_channel:

@TheBirdsNest
Copy link
Author

Note this also does not work if I call the module directly:

 test = __proxy__['napalm.call'](
                'ping',
                **{
                'destination': params['opts']['target'],
                'source': None,
                'ttl': None,
                'timeout': 2,
                'size': 100,
                'count': 5
                }
            )

@mirceaulinic
Copy link
Member

mirceaulinic commented Apr 30, 2019

Hey @TheBirdsNest. Have you looked at the Scheduler: https://docs.saltstack.com/en/latest/topics/jobs/. Unless you need to dynamically change the targets, you can schedule the example you shared in #58 (comment), as follows:

schedule:
  run_pings:
    function: net.ping
    args:
       - 8.8.8.8
    seconds: 10

Alternatively, if you need to run towards various targets, you can indeed have an Engine (although you can equally have a scheduled custom Execution Module, or Runner on the Master). I'd recommend you to use __salt__ instead of __proxy__, as the latter is rather unpredictable and not sufficiently flexible (especially if you're running in mixed environments). Something like this should work:

 test = __salt__['net.ping'](
    params['opts']['target'],
    timeout=2,
    size=100,
    count=5
)

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

No branches or pull requests

2 participants