saltstack / saltstack/salt

[BUG] Deltaproxy and napalm.junos_cli

Open
#63,599 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug Delta-Proxy help-wanted needs-triage
Dominant language
Python
Stars
15.7k
Forks
5.6k
Avg merge
2d 44m
Merged PRs (30d)
80

Description

Description
We've encountered some issues with using the junos execution module with the junos napalm proxy.

There seem to be some kind of autovivification-issue, or similar, affecting the timeout-wrapper in the junos execution module. The wrapper expects the kwarg "dev_timeout" to exist and be defined, when in reality it is 'None' when not specifying it.

salt hostname napalm.junos_cli 'show version' format=xml
hostname:
    Passed invalid arguments to napalm.junos_cli: '>' not supported between instances of 'int' and 'NoneType'
salt hostname napalm.junos_cli 'show version' format=xml dev_timeout=30
hostname:
    <works>

Setup
(Please provide relevant configs and/or SLS files (be sure to remove sensitive info. There is no general set-up of Salt.)

Please be as specific as possible and give set-up details.

  • on-prem machine
  • VM (Virtualbox, KVM, etc. please specify)
  • VM running on a cloud service, please be explicit and add details
  • container (Kubernetes, Docker, containerd, etc. please specify): 1x Master container, 1x Deltaproxy container.
  • or a combination, please be explicit
  • jails if it is FreeBSD
  • classic packaging
  • onedir packaging
  • used bootstrap to install

Steps to Reproduce the behavior
One master running in docker container.
One delta-proxy running in docker container.
One Juniper MX204

Traceback from the host running the delta proxy:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/salt/metaproxy/deltaproxy.py", line 669, in thread_return
    opts, data, func, args, kwargs
  File "/usr/local/lib/python3.7/site-packages/salt/loader/lazy.py", line 149, in __call__
    return self.loader.run(run_func, *args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/salt/loader/lazy.py", line 1228, in run
    return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/salt/loader/lazy.py", line 1243, in _run_as
    return _func_or_method(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/salt/executors/direct_call.py", line 10, in execute
    return func(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/salt/loader/lazy.py", line 149, in __call__
    return self.loader.run(run_func, *args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/salt/loader/lazy.py", line 1228, in run
    return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/salt/loader/lazy.py", line 1243, in _run_as
    return _func_or_method(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/salt/utils/napalm.py", line 512, in func_wrapper
    ret = func(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/salt/modules/napalm_mod.py", line 980, in junos_cli
    command, format=format, dev_timeout=dev_timeout, dest=dest, **kwargs
  File "/usr/local/lib/python3.7/site-packages/salt/loader/lazy.py", line 149, in __call__
    return self.loader.run(run_func, *args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/salt/loader/lazy.py", line 1228, in run
    return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/salt/loader/lazy.py", line 1243, in _run_as
    return _func_or_method(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/salt/modules/junos.py", line 156, in wrapper
    ldev_timeout = max(kwargs.pop("dev_timeout", 0), kwargs.pop("timeout", 0))
TypeError: '>' not supported between instances of 'int' and 'NoneType'

Expected behavior
Expecting the junos execution modul not to throw a TypeError when looking at dev_timeout.

Versions Report

salt --versions-report (Provided by running salt --versions-report. Please also mention any differences in master/minion versions.)
Salt Version:
          Salt: 3005.1

Dependency Versions:
          cffi: 1.14.6
      cherrypy: unknown
      dateutil: 2.8.1
     docker-py: Not Installed
         gitdb: Not Installed
     gitpython: Not Installed
        Jinja2: 3.1.0
       libgit2: 1.1.0
      M2Crypto: Not Installed
          Mako: Not Installed
       msgpack: 1.0.2
  msgpack-pure: Not Installed
  mysql-python: Not Installed
     pycparser: 2.17
      pycrypto: Not Installed
  pycryptodome: 3.9.8
        pygit2: 1.6.1
        Python: 3.7.13 (default, Apr 20 2022, 03:16:50)
  python-gnupg: 0.4.8
        PyYAML: 5.4.1
         PyZMQ: 18.0.1
         smmap: Not Installed
       timelib: 0.2.4
       Tornado: 4.5.3
           ZMQ: 4.3.1

System Versions:
          dist: alpine 3.14.6
        locale: UTF-8
       machine: x86_64
       release: 4.18.0-372.9.1.el8.x86_64
        system: Linux
       version: Alpine Linux 3.14.6

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the timeout wrapper in salt/modules/junos.py and the junos_cli entry point in salt/modules/napalm_mod.py, using the reported traceback and reproduction commands as the first reference. The work is done when invoking napalm.junos_cli without dev_timeout no longer raises a TypeError, while the explicit dev_timeout=30 case continues to work.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
networking
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.