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

[BUG] napalm minion KeyError: 'napalm.get_reboot_active' #60025

Closed
network-shark opened this issue Apr 13, 2021 · 29 comments · Fixed by #60244
Closed

[BUG] napalm minion KeyError: 'napalm.get_reboot_active' #60025

network-shark opened this issue Apr 13, 2021 · 29 comments · Fixed by #60244
Assignees
Labels
Bug broken, incorrect, or confusing behavior Confirmed Salt engineer has confirmed bug/feature - often including a MCVE lazy-loader severity-medium 3rd level, incorrect or bad functionality, confusing and lacks a work around
Milestone

Comments

@network-shark
Copy link
Contributor

Description
I just saw it in my debug log . Maybe it's just cosmetic .

napalm proxy minion connected to cisco csr1000v

Salt Version:
          Salt: 3003

Dependency Versions:
          cffi: 1.14.5
      cherrypy: Not Installed
      dateutil: 2.7.3
     docker-py: Not Installed
         gitdb: 2.0.5
     gitpython: 2.1.11
        Jinja2: 2.10
       libgit2: Not Installed
      M2Crypto: Not Installed
          Mako: Not Installed
       msgpack: 0.5.6
  msgpack-pure: Not Installed
  mysql-python: Not Installed
     pycparser: 2.20
      pycrypto: 2.6.1
  pycryptodome: 3.6.1
        pygit2: Not Installed
        Python: 3.7.3 (default, Jan 22 2021, 20:04:44)
  python-gnupg: Not Installed
        PyYAML: 3.13
         PyZMQ: 17.1.2
         smmap: 2.0.5
       timelib: Not Installed
       Tornado: 4.5.3
           ZMQ: 4.3.1

System Versions:
          dist: debian 10 buster
        locale: UTF-8
       machine: x86_64
       release: 4.19.0-13-amd64
        system: Linux
       version: Debian GNU/Linux 10 buster
DEBUG   ] Using pkg_resources to load entry points
[DEBUG   ] Using pkg_resources to load entry points
[DEBUG   ] LazyLoaded status.proxy_reconnect
[DEBUG   ] schedule.handle_func: adding this job to the jobcache with data {'id': 'r1', 'fun': 'status.proxy_reconnect', 'fun_args': [{'proxy_name': 'napalm'}], 'schedule': '__proxy_keepalive', 'jid': '20210413212712984307', 'pid': 16456}
[ERROR   ] Unhandled exception running status.proxy_reconnect
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/salt/utils/schedule.py", line 843, in handle_func
    ret["return"] = self.functions[func](*args, **kwargs)
  File "/usr/lib/python3/dist-packages/salt/loader.py", line 1235, in __call__
    return self.loader.run(run_func, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/salt/loader.py", line 2268, in run
    return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/salt/loader.py", line 2283, in _run_as
    return _func_or_method(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/salt/modules/status.py", line 1793, in proxy_reconnect
    if __proxy__[proxy_name + ".get_reboot_active"]():
  File "/usr/lib/python3/dist-packages/salt/loader_context.py", line 72, in __getitem__
    return self.value()[item]
  File "/usr/lib/python3/dist-packages/salt/loader.py", line 1403, in __getitem__
    func = super().__getitem__(item)
  File "/usr/lib/python3/dist-packages/salt/utils/lazy.py", line 110, in __getitem__
    return self._dict[key]
KeyError: 'napalm.get_reboot_active'
[DEBUG   ] schedule.handle_func: Removing /var/cache/salt/proxy/r1/proc/20210413212712984307
[DEBUG   ] LazyLoaded mine.update
@network-shark network-shark added Bug broken, incorrect, or confusing behavior needs-triage labels Apr 13, 2021
@EmberLevy
Copy link

Thank you for opening the issue. What is the relevant setup, what is the expected behavior, and what are the exact commands to reproduce the error? These details will help us reproduce the error to fix the issue.

@network-shark
Copy link
Contributor Author

network-shark commented Apr 14, 2021

@EmberLevy

***Whats the issue ?
I don't know , the debug does not look healthy

*** How to reproduce
Start a napalm proxy with salt-proxy --proxyid r1 -ldebug

The message appears more then once within a minute.

***expected behavior
I don't know

@danielrobbins
Copy link

@network-shark please ensure you have the napalm module installed:

pip3 list | grep ^napalm

You may need to use "pip". As per these docs, napalm is a requirement, so let's start the troubleshooting there: https://docs.saltproject.io/en/latest/ref/proxy/all/salt.proxy.napalm.html#dependencies

@network-shark
Copy link
Contributor Author

network-shark commented Apr 19, 2021

I can't start a napalm minion without installing napalm :) .

Thank you , but that is not the problem.

@danielrobbins
Copy link

@network-shark OK -- it was worth a shot :)

@danielrobbins
Copy link

I think this is related to #59690 -- or at least touches the same code. The __getitem__() method should be rewritten. In this particular bug, I think we are having issues because we are not using the following conditional structure:

if key not in self.dict:
  if not self.loaded:
    ...
  else:
    ...
else:
  ...

In other words, it is not handling the case where key is not in self.dict but self.loaded evaluates to true. It will then try to return self._dict[key] and fail.

@sagetherage sagetherage added the severity-medium 3rd level, incorrect or bad functionality, confusing and lacks a work around label Apr 30, 2021
@sagetherage sagetherage removed their assignment Apr 30, 2021
@sagetherage sagetherage added this to the Approved milestone Apr 30, 2021
@ggiesen
Copy link
Contributor

ggiesen commented May 12, 2021

I moved to 3003 last night and hitting this as well. Makes network proxy minions completely unusable (they don't stay connected). Any chance we can get this in the point release?

@ggiesen
Copy link
Contributor

ggiesen commented May 12, 2021

Here's output from a Junos minion. No commands run except to start the proxy:

[DEBUG   ] schedule: Job __proxy_keepalive was scheduled with jid_include, adding to cache (jid_include defaults to True)
[DEBUG   ] schedule: Job __proxy_keepalive was scheduled with a max number of 1
[INFO    ] Running scheduled job: __proxy_keepalive with jid 20210512133036049898
[DEBUG   ] Using pkg_resources to load entry points
[DEBUG   ] Subprocess Thread-146-Schedule-__proxy_keepalive added
[DEBUG   ] Using pkg_resources to load entry points
[DEBUG   ] Using pkg_resources to load entry points
[DEBUG   ] LazyLoaded status.proxy_reconnect
[DEBUG   ] schedule.handle_func: adding this job to the jobcache with data {'id': 'router', 'fun': 'status.proxy_reconnect', 'fun_args': [{'proxy_name': 'napalm'}], 'schedule': '__proxy_keepalive', 'jid': '20210512133036049898', 'pid': 2730129}
[ERROR   ] Unhandled exception running status.proxy_reconnect
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/salt/utils/schedule.py", line 843, in handle_func
    ret["return"] = self.functions[func](*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 1241, in __call__
    return self.loader.run(run_func, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 2276, in run
    return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/contextvars/__init__.py", line 38, in run
    return callable(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 2291, in _run_as
    return _func_or_method(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/modules/status.py", line 1793, in proxy_reconnect
    if __proxy__[proxy_name + ".get_reboot_active"]():
  File "/usr/lib/python3.6/site-packages/salt/loader_context.py", line 72, in __getitem__
    return self.value()[item]
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 1409, in __getitem__
    func = super().__getitem__(item)
  File "/usr/lib/python3.6/site-packages/salt/utils/lazy.py", line 110, in __getitem__
    return self._dict[key]
KeyError: 'napalm.get_reboot_active'
[DEBUG   ] schedule.handle_func: Removing /var/cache/salt/proxy/router/proc/20210512133036049898
[DEBUG   ] Subprocess Thread-146-Schedule-__proxy_keepalive cleaned up

@network-shark
Copy link
Contributor Author

network-shark commented May 12, 2021

@ggiesen I just fired up the proxy in my lab environment I can't say how this problem behaves on long running minion processes. I got theses failures , but did not have any issues. Are you sure we're talking about the same issue ? From the output it looks like the minion is still running

@ggiesen
Copy link
Contributor

ggiesen commented May 12, 2021

The minion itself is still running but not connected to the device.

Edit: Let me do some further digging to validate a few things

Edit 2: Junos connections don't show up in a show system users because it's using netconf which fooled me. show system connections | match <proxy IP> is needed to display the connection from Salt. Also tried on an IOS proxy and it stays connected. Either way proxy logs are flooded with the above message over and over. So it appears to be mostly cosmetic but makes it a real bear to troubleshoot anything

@ggiesen
Copy link
Contributor

ggiesen commented May 20, 2021

So after doing some testing with the deltaproxy in #60177 , and then going back to an unpatched 3003, I can confirm this is a real issue and not merely a comestic one.

Start the proxy minion:

# salt-proxy --proxyid=router1 -l debug
[DEBUG   ] Reading configuration from /etc/salt/proxy
[DEBUG   ] Including configuration from '/etc/salt/proxy.d/router1/_schedule.conf'
[DEBUG   ] Reading configuration from /etc/salt/proxy.d/router1/_schedule.conf
[DEBUG   ] Using pkg_resources to load entry points
[DEBUG   ] Override  __grains__: <module 'salt.loaded.int.log_handlers.sentry_mod' from '/usr/lib/python3.6/site-packages/salt/log/handlers/sentry_mod.py'>
[DEBUG   ] Configuration file path: /etc/salt/proxy
[WARNING ] Insecure logging configuration detected! Sensitive data may be logged.
[INFO    ] Setting up "router1" the Salt ProxyMinion
...
[DEBUG   ] Sending event: tag = /salt/minion/minion_pillar_refresh_complete; data = {'complete': True, '_stamp': '2021-05-20T04:21:19.043678'}
[DEBUG   ] Closing IPCMessageClient instance
[DEBUG   ] Minion of 'salt' is handling event tag '/salt/minion/minion_pillar_refresh_complete'

Proxy minion is connected:

router1#show users
    Line       User       Host(s)              Idle       Location
   1 vty 0     vagrant    idle                 00:02:40 192.168.33.167
*  2 vty 1     vagrant    idle                 00:00:00 192.168.33.2

Kill the connection:

router1#clear line 1
[confirm]
 [OK]

Logs on proxy minion show disconnect:

[DEBUG   ] [chan 0] EOF received (0)
[DEBUG   ] [chan 0] EOF sent (0)
[DEBUG   ] EOF in transport thread

We see user is disconnected on router1:

router1#show users
    Line       User       Host(s)              Idle       Location
*  2 vty 1     vagrant    idle                 00:00:00 192.168.33.2

Some tens of seconds later and proxy minion attempts to reconnect and fails:

[DEBUG   ] schedule: Job __proxy_keepalive was scheduled with jid_include, adding to cache (jid_include defaults to True)
[DEBUG   ] schedule: Job __proxy_keepalive was scheduled with a max number of 1
[INFO    ] Running scheduled job: __proxy_keepalive with jid 20210520042518634899
[DEBUG   ] Using pkg_resources to load entry points
[DEBUG   ] Subprocess Thread-53-Schedule-__proxy_keepalive added
[DEBUG   ] Using pkg_resources to load entry points
[DEBUG   ] Using pkg_resources to load entry points
[DEBUG   ] LazyLoaded status.proxy_reconnect
[DEBUG   ] schedule.handle_func: adding this job to the jobcache with data {'id': 'router1', 'fun': 'status.proxy_reconnect', 'fun_args': [{'proxy_name': 'napalm'}], 'schedule': '__proxy_keepalive', 'jid': '20210520042518634899', 'pid': 48837}
[ERROR   ] Unhandled exception running status.proxy_reconnect
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/salt/utils/schedule.py", line 843, in handle_func
    ret["return"] = self.functions[func](*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 1235, in __call__
    return self.loader.run(run_func, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 2268, in run
    return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/contextvars/__init__.py", line 38, in run
    return callable(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 2283, in _run_as
    return _func_or_method(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/modules/status.py", line 1793, in proxy_reconnect
    if __proxy__[proxy_name + ".get_reboot_active"]():
  File "/usr/lib/python3.6/site-packages/salt/loader_context.py", line 72, in __getitem__
    return self.value()[item]
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 1403, in __getitem__
    func = super().__getitem__(item)
  File "/usr/lib/python3.6/site-packages/salt/utils/lazy.py", line 110, in __getitem__
    return self._dict[key]
KeyError: 'napalm.get_reboot_active'
[DEBUG   ] schedule.handle_func: Removing /var/cache/salt/proxy/router1/proc/20210520042518634899
[DEBUG   ] LazyLoaded mine.update
[DEBUG   ] Subprocess Thread-53-Schedule-__proxy_keepalive cleaned up

Running napalm.alive confirms it's dead (but proxy minion process is still running):

# salt router1 napalm.alive
router1:
    ----------
    comment:
    out:
        ----------
        is_alive:
            False
    result:
        True

Manually run napalm.reconnect to force reconnect:

# salt router1 napalm.reconnect
router1:
    ----------
    comment:
        Connection restarted!
    out:
        None
    result:
        True

Logs from proxy minion confirm reconnect:

[DEBUG   ] Using pkg_resources to load entry points
[ERROR   ] No metaproxy key found in opts for id router1. Defaulting to standard proxy minion
[DEBUG   ] LazyLoaded proxy.handle_payload
[DEBUG   ] Using pkg_resources to load entry points
[ERROR   ] No metaproxy key found in opts for id router1. Defaulting to standard proxy minion
[DEBUG   ] LazyLoaded proxy.target_load
[DEBUG   ] Using pkg_resources to load entry points
[ERROR   ] No metaproxy key found in opts for id router1. Defaulting to standard proxy minion
[DEBUG   ] LazyLoaded proxy.handle_decoded_payload
[INFO    ] User sudo_vagrant Executing command napalm.reconnect with jid 20210520042907290843
[DEBUG   ] Command details {'fun': 'napalm.reconnect', 'arg': [], 'tgt': 'router1', 'jid': '20210520042907290843', 'ret': '', 'tgt_type': 'glob', 'user': 'sudo_vagrant'}
[DEBUG   ] Using pkg_resources to load entry points
[ERROR   ] No metaproxy key found in opts for id router1. Defaulting to standard proxy minion
[DEBUG   ] LazyLoaded proxy.target
[DEBUG   ] Using pkg_resources to load entry points
[ERROR   ] No metaproxy key found in opts for id router1. Defaulting to standard proxy minion
[DEBUG   ] LazyLoaded proxy.thread_return
[INFO    ] Starting a new job with PID 48837
[DEBUG   ] Subprocess 20210520042907290843-Job-20210520042907290843 added
[DEBUG   ] Could not LazyLoad direct_call.allow_missing_func: 'direct_call.allow_missing_func' is not available.
[DEBUG   ] Is alive fetch:
[DEBUG   ] {'out': {'is_alive': False}, 'result': True, 'comment': ''}
[INFO    ] Closing the NAPALM proxy connection with router1
[INFO    ] Re-opening the NAPALM proxy connection with router1
[DEBUG   ] starting thread (client mode): 0xb43436a0
[DEBUG   ] Local version/idstring: SSH-2.0-paramiko_2.7.2
[DEBUG   ] Remote version/idstring: SSH-2.0-Cisco-1.25
[INFO    ] Connected (version 2.0, client Cisco-1.25)
[DEBUG   ] kex algos:['diffie-hellman-group-exchange-sha1', 'diffie-hellman-group14-sha1'] server key:['ssh-rsa'] client encrypt:['aes128-ctr', 'aes192-ctr', 'aes256-ctr'] server encrypt:['aes128-ctr', 'aes192-ctr', 'aes256-ctr'] client mac:['hmac-sha2-256', 'hmac-sha2-512', 'hmac-sha1', 'hmac-sha1-96'] server mac:['hmac-sha2-256', 'hmac-sha2-512', 'hmac-sha1', 'hmac-sha1-96'] client compress:['none'] server compress:['none'] client lang:[''] server lang:[''] kex follows?False
[DEBUG   ] Kex agreed: diffie-hellman-group-exchange-sha1
[DEBUG   ] HostKey agreed: ssh-rsa
[DEBUG   ] Cipher agreed: aes128-ctr
[DEBUG   ] MAC agreed: hmac-sha2-256
[DEBUG   ] Compression agreed: none
[DEBUG   ] Got server p (2048 bits)
[DEBUG   ] kex engine KexGex specified hash_algo <built-in function openssl_sha1>
[DEBUG   ] Switch to new keys ...
[DEBUG   ] Adding ssh-rsa host key for 192.168.33.168: b'1e128dac15b49082ad116da8a3207171'
[DEBUG   ] userauth is OK
[INFO    ] Authentication (password) successful!
[DEBUG   ] [chan 0] Max packet in: 32768 bytes
[DEBUG   ] [chan 0] Max packet out: 4096 bytes
[DEBUG   ] Secsh channel 0 opened.
[DEBUG   ] [chan 0] Sesch channel 0 request ok
[DEBUG   ] [chan 0] Sesch channel 0 request ok
[DEBUG   ] write_channel: b'terminal width 511\n'
[DEBUG   ] Pattern is: terminal width 511
[DEBUG   ] _read_channel_expect read_data:


router1#t
[DEBUG   ] _read_channel_expect read_data: ermin
[DEBUG   ] _read_channel_expect read_data: al w
[DEBUG   ] _read_channel_expect read_data: i
[DEBUG   ] _read_channel_expect read_data: dth
[DEBUG   ] _read_channel_expect read_data:  511
[DEBUG   ] Pattern found: terminal width 511


router1#terminal width 511
[DEBUG   ] In disable_paging
[DEBUG   ] Command: terminal length 0

[DEBUG   ] write_channel: b'terminal length 0\n'
[DEBUG   ] Pattern is: terminal\ length\ 0
[DEBUG   ] _read_channel_expect read_data:

[DEBUG   ] _read_channel_expect read_data: router1#termi
[DEBUG   ] _read_channel_expect read_data: na
[DEBUG   ] _read_channel_expect read_data: l l
[DEBUG   ] _read_channel_expect read_data: ength 
[DEBUG   ] _read_channel_expect read_data: 0

[DEBUG   ] Pattern found: terminal\ length\ 0 
router1#terminal length 0

[DEBUG   ]
router1#terminal length 0

[DEBUG   ] Exiting disable_paging
[DEBUG   ] read_channel: router1#
[DEBUG   ] Clear buffer detects data in the channel
[DEBUG   ] read_channel: 
[DEBUG   ] write_channel: b'\n'
[DEBUG   ] read_channel: 
[DEBUG   ] read_channel:
[DEBUG   ] write_channel: b'\n'
[DEBUG   ] read_channel: 
router1#
[DEBUG   ] read_channel: 
router1#
[DEBUG   ] Clear buffer detects data in the channel
[DEBUG   ] read_channel: 
[DEBUG   ] [find_prompt()]: prompt is router1#
[DEBUG   ] write_channel: b'\n'
[DEBUG   ] Pattern is: router1
[DEBUG   ] _read_channel_expect read_data:

[DEBUG   ] _read_channel_expect read_data: router1#
[DEBUG   ] Pattern found: router1
router1#
[DEBUG   ] Minion return retry timer set to 8 seconds (randomized)
[INFO    ] Returning information for job: 20210520042907290843
[DEBUG   ] Initializing new AsyncZeroMQReqChannel for ('/etc/salt/pki/proxy', 'router1', 'tcp://127.0.1.1:4506', 'aes')
[DEBUG   ] Initializing new AsyncAuth for ('/etc/salt/pki/proxy', 'router1', 'tcp://127.0.1.1:4506')
[DEBUG   ] Connecting the Minion to the Master URI (for the return server): tcp://127.0.1.1:4506
[DEBUG   ] Trying to connect to: tcp://127.0.1.1:4506
[DEBUG   ] Closing AsyncZeroMQReqChannel instance
[DEBUG   ] minion return: {'success': True, 'return': {'out': None, 'result': True, 'comment': 'Connection restarted!'}, 'retcode': 0, 'jid': '20210520042907290843', 'fun': 'napalm.reconnect', 'fun_args': []}
[DEBUG   ] Subprocess 20210520042907290843-Job-20210520042907290843 cleaned up
[DEBUG   ] Sending global request "[email protected]"
[DEBUG   ] Global request denied.
[DEBUG   ] Sending global request "[email protected]"
[DEBUG   ] Global request denied.
[DEBUG   ] schedule: Job __proxy_keepalive was scheduled with jid_include, adding to cache (jid_include defaults to True)
[DEBUG   ] schedule: Job __proxy_keepalive was scheduled with a max number of 1
[INFO    ] Running scheduled job: __proxy_keepalive with jid 20210520042918633965
[DEBUG   ] Using pkg_resources to load entry points
[DEBUG   ] Subprocess Thread-61-Schedule-__proxy_keepalive added
[DEBUG   ] Using pkg_resources to load entry points
[DEBUG   ] Using pkg_resources to load entry points
[DEBUG   ] LazyLoaded status.proxy_reconnect
[DEBUG   ] schedule.handle_func: adding this job to the jobcache with data {'id': 'router1', 'fun': 'status.proxy_reconnect', 'fun_args': [{'proxy_name': 'napalm'}], 'schedule': '__proxy_keepalive', 'jid': '20210520042918633965', 'pid': 48837}
[ERROR   ] Unhandled exception running status.proxy_reconnect
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/salt/utils/schedule.py", line 843, in handle_func
    ret["return"] = self.functions[func](*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 1235, in __call__
    return self.loader.run(run_func, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 2268, in run
    return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/contextvars/__init__.py", line 38, in run
    return callable(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 2283, in _run_as
    return _func_or_method(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/modules/status.py", line 1793, in proxy_reconnect
    if __proxy__[proxy_name + ".get_reboot_active"]():
  File "/usr/lib/python3.6/site-packages/salt/loader_context.py", line 72, in __getitem__
    return self.value()[item]
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 1403, in __getitem__
    func = super().__getitem__(item)
  File "/usr/lib/python3.6/site-packages/salt/utils/lazy.py", line 110, in __getitem__
    return self._dict[key]
KeyError: 'napalm.get_reboot_active'
[DEBUG   ] schedule.handle_func: Removing /var/cache/salt/proxy/router1/proc/20210520042918633965
[DEBUG   ] LazyLoaded mine.update
[DEBUG   ] Subprocess Thread-61-Schedule-__proxy_keepalive cleaned up

Running napalm.alive confirms it's running again:

# salt router1 napalm.alive
router1:
    ----------
    comment:
    out:
        ----------
        is_alive:
            True
    result:
        True

And we see the connection on the router:

router1#show users
    Line       User       Host(s)              Idle       Location
   1 vty 0     vagrant    idle                 00:00:42 192.168.33.167
*  2 vty 1     vagrant    idle                 00:00:00 192.168.33.2

In short, if the SSH session gets disconnected, it will not auto-reconnect as it is supposed to (confirmed this works on 3001.7 and 3002.6). To get it to reconnect you must either run napalm.reconnect or restart the proxy minion process.

@dmurphy18
Copy link
Contributor

@ggiesen Thanks for that great debug of issue, looks like it is not related to what I originally thought, given it was working and the problem is in re-connect or similar

@ggiesen
Copy link
Contributor

ggiesen commented May 20, 2021

@dmurphy18

Just to be clear, the message also appears even proxy minion is started up and connected properly. It just seems to only impact the ability for the proxy minion to reconnect.

@dmurphy18 dmurphy18 added the Confirmed Salt engineer has confirmed bug/feature - often including a MCVE label May 21, 2021
@dmurphy18
Copy link
Contributor

Duplicated this with Arista EOS too, investigating

@dmurphy18
Copy link
Contributor

Understand the issue and should have a fix next week.

@ggiesen
Copy link
Contributor

ggiesen commented May 26, 2021

After applying the patch in #60244, I'm now getting the following:

# salt-proxy --proxyid=router2
[CRITICAL] Failed to load grains defined in grain file napalm.getos in function <salt.loader.LoadedFunc object at 0x7f4afdcebcf8>, error:
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 922, in grains
    ret = funcs[key](**kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 1241, in __call__
    return self.loader.run(run_func, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 2276, in run
    return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/contextvars/__init__.py", line 38, in run
    return callable(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 2291, in _run_as
    return _func_or_method(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/grains/napalm.py", line 128, in getos
    return {"os": _get_device_grain("driver_name", proxy=proxy)}
  File "/usr/lib/python3.6/site-packages/salt/grains/napalm.py", line 107, in _get_device_grain
    device = _retrieve_device_cache(proxy=proxy)
  File "/usr/lib/python3.6/site-packages/salt/grains/napalm.py", line 87, in _retrieve_device_cache
    DEVICE_CACHE = proxy["napalm.get_device"]()
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 1241, in __call__
    return self.loader.run(run_func, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 2276, in run
    return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/contextvars/__init__.py", line 38, in run
    return callable(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 2291, in _run_as
    return _func_or_method(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/proxy/napalm.py", line 252, in get_device
    return __context__["napalm_device"]["network_device"]
  File "/usr/lib/python3.6/site-packages/salt/loader_context.py", line 72, in __getitem__
    return self.value()[item]
  File "/usr/lib/python3.6/site-packages/salt/utils/context.py", line 223, in __getitem__
    return self._dict()[key]
KeyError: 'napalm_device'
[CRITICAL] Failed to load grains defined in grain file napalm.host in function <salt.loader.LoadedFunc object at 0x7f4afdcebd30>, error: 
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 922, in grains
    ret = funcs[key](**kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 1241, in __call__
    return self.loader.run(run_func, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 2276, in run
    return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/contextvars/__init__.py", line 38, in run
    return callable(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 2291, in _run_as
    return _func_or_method(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/grains/napalm.py", line 353, in host
    return {"host": _get_device_grain("hostname", proxy=proxy)}
  File "/usr/lib/python3.6/site-packages/salt/grains/napalm.py", line 107, in _get_device_grain
    device = _retrieve_device_cache(proxy=proxy)
  File "/usr/lib/python3.6/site-packages/salt/grains/napalm.py", line 87, in _retrieve_device_cache
    DEVICE_CACHE = proxy["napalm.get_device"]()
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 1241, in __call__
    return self.loader.run(run_func, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 2276, in run
    return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/contextvars/__init__.py", line 38, in run
    return callable(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 2291, in _run_as
    return _func_or_method(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/proxy/napalm.py", line 252, in get_device
    return __context__["napalm_device"]["network_device"]
  File "/usr/lib/python3.6/site-packages/salt/loader_context.py", line 72, in __getitem__
    return self.value()[item]
  File "/usr/lib/python3.6/site-packages/salt/utils/context.py", line 223, in __getitem__
    return self._dict()[key]
KeyError: 'napalm_device'
[CRITICAL] Failed to load grains defined in grain file napalm.hostname in function <salt.loader.LoadedFunc object at 0x7f4afdce0e48>, error:Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 922, in grains
    ret = funcs[key](**kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 1241, in __call__
    return self.loader.run(run_func, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 2276, in run
    return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/contextvars/__init__.py", line 38, in run
    return callable(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 2291, in _run_as
    return _func_or_method(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/grains/napalm.py", line 310, in hostname
    return {"hostname": _get_grain("hostname", proxy=proxy)}
  File "/usr/lib/python3.6/site-packages/salt/grains/napalm.py", line 98, in _get_grain
    grains = _retrieve_grains_cache(proxy=proxy)
  File "/usr/lib/python3.6/site-packages/salt/grains/napalm.py", line 71, in _retrieve_grains_cache
    GRAINS_CACHE = proxy["napalm.get_grains"]()
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 1241, in __call__
    return self.loader.run(run_func, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 2276, in run
    return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/contextvars/__init__.py", line 38, in run
    return callable(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 2291, in _run_as
    return _func_or_method(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/proxy/napalm.py", line 259, in get_grains
    return call("get_facts", **{})
  File "/usr/lib/python3.6/site-packages/salt/proxy/napalm.py", line 349, in call
    __context__["napalm_device"]["network_device"], method, *args, **kwargs
  File "/usr/lib/python3.6/site-packages/salt/loader_context.py", line 72, in __getitem__
    return self.value()[item]
  File "/usr/lib/python3.6/site-packages/salt/utils/context.py", line 223, in __getitem__
    return self._dict()[key]
KeyError: 'napalm_device'
[CRITICAL] Failed to load grains defined in grain file napalm.interfaces in function <salt.loader.LoadedFunc object at 0x7f4afdcac5c0>, error:
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 922, in grains
    ret = funcs[key](**kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 1241, in __call__
    return self.loader.run(run_func, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 2276, in run
    return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/contextvars/__init__.py", line 38, in run
    return callable(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 2291, in _run_as
    return _func_or_method(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/grains/napalm.py", line 259, in interfaces
    return {"interfaces": _get_grain("interface_list", proxy=proxy)}
  File "/usr/lib/python3.6/site-packages/salt/grains/napalm.py", line 98, in _get_grain
    grains = _retrieve_grains_cache(proxy=proxy)
  File "/usr/lib/python3.6/site-packages/salt/grains/napalm.py", line 71, in _retrieve_grains_cache
    GRAINS_CACHE = proxy["napalm.get_grains"]()
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 1241, in __call__
    return self.loader.run(run_func, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 2276, in run
    return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/contextvars/__init__.py", line 38, in run
    return callable(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 2291, in _run_as
    return _func_or_method(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/proxy/napalm.py", line 259, in get_grains
    return call("get_facts", **{})
  File "/usr/lib/python3.6/site-packages/salt/proxy/napalm.py", line 349, in call
    __context__["napalm_device"]["network_device"], method, *args, **kwargs
  File "/usr/lib/python3.6/site-packages/salt/loader_context.py", line 72, in __getitem__
    return self.value()[item]
  File "/usr/lib/python3.6/site-packages/salt/utils/context.py", line 223, in __getitem__
    return self._dict()[key]
KeyError: 'napalm_device'
[CRITICAL] Failed to load grains defined in grain file napalm.model in function <salt.loader.LoadedFunc object at 0x7f4afdcac9b0>, error:   
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 922, in grains
    ret = funcs[key](**kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 1241, in __call__
    return self.loader.run(run_func, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 2276, in run
    return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/contextvars/__init__.py", line 38, in run
    return callable(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 2291, in _run_as
    return _func_or_method(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/grains/napalm.py", line 171, in model
    return {"model": _get_grain("model", proxy=proxy)}
  File "/usr/lib/python3.6/site-packages/salt/grains/napalm.py", line 98, in _get_grain
    grains = _retrieve_grains_cache(proxy=proxy)
  File "/usr/lib/python3.6/site-packages/salt/grains/napalm.py", line 71, in _retrieve_grains_cache
    GRAINS_CACHE = proxy["napalm.get_grains"]()
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 1241, in __call__
    return self.loader.run(run_func, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 2276, in run
    return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/contextvars/__init__.py", line 38, in run
    return callable(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 2291, in _run_as
    return _func_or_method(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/proxy/napalm.py", line 259, in get_grains
    return call("get_facts", **{})
  File "/usr/lib/python3.6/site-packages/salt/proxy/napalm.py", line 349, in call
    __context__["napalm_device"]["network_device"], method, *args, **kwargs
  File "/usr/lib/python3.6/site-packages/salt/loader_context.py", line 72, in __getitem__
    return self.value()[item]
  File "/usr/lib/python3.6/site-packages/salt/utils/context.py", line 223, in __getitem__
    return self._dict()[key]
KeyError: 'napalm_device'
[CRITICAL] Failed to load grains defined in grain file napalm.optional_args in function <salt.loader.LoadedFunc object at 0x7f4afdcacda0>, error:
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 922, in grains
    ret = funcs[key](**kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 1241, in __call__
    return self.loader.run(run_func, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 2276, in run
    return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/contextvars/__init__.py", line 38, in run
    return callable(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 2291, in _run_as
    return _func_or_method(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/grains/napalm.py", line 442, in optional_args
    opt_args = _get_device_grain("optional_args", proxy=proxy) or {}
  File "/usr/lib/python3.6/site-packages/salt/grains/napalm.py", line 107, in _get_device_grain
    device = _retrieve_device_cache(proxy=proxy)
  File "/usr/lib/python3.6/site-packages/salt/grains/napalm.py", line 87, in _retrieve_device_cache
    DEVICE_CACHE = proxy["napalm.get_device"]()
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 1241, in __call__
    return self.loader.run(run_func, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 2276, in run
    return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/contextvars/__init__.py", line 38, in run
    return callable(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 2291, in _run_as
    return _func_or_method(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/proxy/napalm.py", line 252, in get_device
    return __context__["napalm_device"]["network_device"]
  File "/usr/lib/python3.6/site-packages/salt/loader_context.py", line 72, in __getitem__
    return self.value()[item]
  File "/usr/lib/python3.6/site-packages/salt/utils/context.py", line 223, in __getitem__
    return self._dict()[key]
KeyError: 'napalm_device'
[CRITICAL] Failed to load grains defined in grain file napalm.serial in function <salt.loader.LoadedFunc object at 0x7f4afdcace10>, error:  
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 922, in grains
    ret = funcs[key](**kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 1241, in __call__
    return self.loader.run(run_func, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 2276, in run
    return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/contextvars/__init__.py", line 38, in run
    return callable(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 2291, in _run_as
    return _func_or_method(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/grains/napalm.py", line 199, in serial
    return {"serial": _get_grain("serial_number", proxy=proxy)}
  File "/usr/lib/python3.6/site-packages/salt/grains/napalm.py", line 98, in _get_grain
    grains = _retrieve_grains_cache(proxy=proxy)
  File "/usr/lib/python3.6/site-packages/salt/grains/napalm.py", line 71, in _retrieve_grains_cache
    GRAINS_CACHE = proxy["napalm.get_grains"]()
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 1241, in __call__
    return self.loader.run(run_func, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 2276, in run
    return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/contextvars/__init__.py", line 38, in run
    return callable(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 2291, in _run_as
    return _func_or_method(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/proxy/napalm.py", line 259, in get_grains
    return call("get_facts", **{})
  File "/usr/lib/python3.6/site-packages/salt/proxy/napalm.py", line 349, in call
    __context__["napalm_device"]["network_device"], method, *args, **kwargs
  File "/usr/lib/python3.6/site-packages/salt/loader_context.py", line 72, in __getitem__
    return self.value()[item]
  File "/usr/lib/python3.6/site-packages/salt/utils/context.py", line 223, in __getitem__
    return self._dict()[key]
KeyError: 'napalm_device'
[CRITICAL] Failed to load grains defined in grain file napalm.uptime in function <salt.loader.LoadedFunc object at 0x7f4afdca85c0>, error:  
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 922, in grains
    ret = funcs[key](**kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 1241, in __call__
    return self.loader.run(run_func, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 2276, in run
    return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/contextvars/__init__.py", line 38, in run
    return callable(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 2291, in _run_as
    return _func_or_method(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/grains/napalm.py", line 227, in uptime
    return {"uptime": _get_grain("uptime", proxy=proxy)}
  File "/usr/lib/python3.6/site-packages/salt/grains/napalm.py", line 98, in _get_grain
    grains = _retrieve_grains_cache(proxy=proxy)
  File "/usr/lib/python3.6/site-packages/salt/grains/napalm.py", line 71, in _retrieve_grains_cache
    GRAINS_CACHE = proxy["napalm.get_grains"]()
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 1241, in __call__
    return self.loader.run(run_func, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 2276, in run
    return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/contextvars/__init__.py", line 38, in run
    return callable(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 2291, in _run_as
    return _func_or_method(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/proxy/napalm.py", line 259, in get_grains
    return call("get_facts", **{})
  File "/usr/lib/python3.6/site-packages/salt/proxy/napalm.py", line 349, in call
    __context__["napalm_device"]["network_device"], method, *args, **kwargs
  File "/usr/lib/python3.6/site-packages/salt/loader_context.py", line 72, in __getitem__
    return self.value()[item]
  File "/usr/lib/python3.6/site-packages/salt/utils/context.py", line 223, in __getitem__
    return self._dict()[key]
KeyError: 'napalm_device'
[CRITICAL] Failed to load grains defined in grain file napalm.username in function <salt.loader.LoadedFunc object at 0x7f4afdca89b0>, error:Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 922, in grains
    ret = funcs[key](**kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 1241, in __call__
    return self.loader.run(run_func, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 2276, in run
    return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/contextvars/__init__.py", line 38, in run
    return callable(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 2291, in _run_as
    return _func_or_method(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/grains/napalm.py", line 286, in username
    return {"username": _get_device_grain("username", proxy=proxy)}
  File "/usr/lib/python3.6/site-packages/salt/grains/napalm.py", line 107, in _get_device_grain
    device = _retrieve_device_cache(proxy=proxy)
  File "/usr/lib/python3.6/site-packages/salt/grains/napalm.py", line 87, in _retrieve_device_cache
    DEVICE_CACHE = proxy["napalm.get_device"]()
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 1241, in __call__
    return self.loader.run(run_func, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 2276, in run
    return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/contextvars/__init__.py", line 38, in run
    return callable(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 2291, in _run_as
    return _func_or_method(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/proxy/napalm.py", line 252, in get_device
    return __context__["napalm_device"]["network_device"]
  File "/usr/lib/python3.6/site-packages/salt/loader_context.py", line 72, in __getitem__
    return self.value()[item]
  File "/usr/lib/python3.6/site-packages/salt/utils/context.py", line 223, in __getitem__
    return self._dict()[key]
KeyError: 'napalm_device'
[CRITICAL] Failed to load grains defined in grain file napalm.vendor in function <salt.loader.LoadedFunc object at 0x7f4afdca8da0>, error:
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 922, in grains
    ret = funcs[key](**kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 1241, in __call__
    return self.loader.run(run_func, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 2276, in run
    return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/contextvars/__init__.py", line 38, in run
    return callable(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 2291, in _run_as
    return _func_or_method(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/grains/napalm.py", line 214, in vendor
    return {"vendor": _get_grain("vendor", proxy=proxy)}
  File "/usr/lib/python3.6/site-packages/salt/grains/napalm.py", line 98, in _get_grain
    grains = _retrieve_grains_cache(proxy=proxy)
  File "/usr/lib/python3.6/site-packages/salt/grains/napalm.py", line 71, in _retrieve_grains_cache
    GRAINS_CACHE = proxy["napalm.get_grains"]()
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 1241, in __call__
    return self.loader.run(run_func, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 2276, in run
    return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/contextvars/__init__.py", line 38, in run
    return callable(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 2291, in _run_as
    return _func_or_method(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/proxy/napalm.py", line 259, in get_grains
    return call("get_facts", **{})
  File "/usr/lib/python3.6/site-packages/salt/proxy/napalm.py", line 349, in call
    __context__["napalm_device"]["network_device"], method, *args, **kwargs
  File "/usr/lib/python3.6/site-packages/salt/loader_context.py", line 72, in __getitem__
    return self.value()[item]
  File "/usr/lib/python3.6/site-packages/salt/utils/context.py", line 223, in __getitem__
    return self._dict()[key]
KeyError: 'napalm_device'
[CRITICAL] Failed to load grains defined in grain file napalm.version in function <salt.loader.LoadedFunc object at 0x7f4afdca8e10>, error: 
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 922, in grains
    ret = funcs[key](**kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 1241, in __call__
    return self.loader.run(run_func, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 2276, in run
    return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/contextvars/__init__.py", line 38, in run
    return callable(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 2291, in _run_as
    return _func_or_method(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/grains/napalm.py", line 156, in version
    return {"version": _get_grain("os_version", proxy=proxy)}
  File "/usr/lib/python3.6/site-packages/salt/grains/napalm.py", line 98, in _get_grain
    grains = _retrieve_grains_cache(proxy=proxy)
  File "/usr/lib/python3.6/site-packages/salt/grains/napalm.py", line 71, in _retrieve_grains_cache
    GRAINS_CACHE = proxy["napalm.get_grains"]()
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 1241, in __call__
    return self.loader.run(run_func, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 2276, in run
    return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/contextvars/__init__.py", line 38, in run
    return callable(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 2291, in _run_as
    return _func_or_method(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/proxy/napalm.py", line 259, in get_grains
    return call("get_facts", **{})
  File "/usr/lib/python3.6/site-packages/salt/proxy/napalm.py", line 349, in call
    __context__["napalm_device"]["network_device"], method, *args, **kwargs
  File "/usr/lib/python3.6/site-packages/salt/loader_context.py", line 72, in __getitem__
    return self.value()[item]
  File "/usr/lib/python3.6/site-packages/salt/utils/context.py", line 223, in __getitem__
    return self._dict()[key]
KeyError: 'napalm_device'
^C[WARNING ] ProxyMinion received a SIGINT. Exiting.
The Salt ProxyMinion is shutdown. ProxyMinion received a SIGINT. Exited.
[root@salt ~]# salt-proxy --proxyid=router2
[CRITICAL] Failed to load grains defined in grain file napalm.getos in function <salt.loader.LoadedFunc object at 0x7f6338285160>, error:
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 922, in grains
    ret = funcs[key](**kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 1241, in __call__
    return self.loader.run(run_func, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 2276, in run
    return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/contextvars/__init__.py", line 38, in run
    return callable(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 2291, in _run_as
    return _func_or_method(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/grains/napalm.py", line 128, in getos
    return {"os": _get_device_grain("driver_name", proxy=proxy)}
  File "/usr/lib/python3.6/site-packages/salt/grains/napalm.py", line 107, in _get_device_grain
    device = _retrieve_device_cache(proxy=proxy)
  File "/usr/lib/python3.6/site-packages/salt/grains/napalm.py", line 87, in _retrieve_device_cache
    DEVICE_CACHE = proxy["napalm.get_device"]()
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 1241, in __call__
    return self.loader.run(run_func, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 2276, in run
    return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/contextvars/__init__.py", line 38, in run
    return callable(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 2291, in _run_as
    return _func_or_method(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/proxy/napalm.py", line 252, in get_device
    return __context__["napalm_device"]["network_device"]
  File "/usr/lib/python3.6/site-packages/salt/loader_context.py", line 72, in __getitem__
    return self.value()[item]
  File "/usr/lib/python3.6/site-packages/salt/utils/context.py", line 223, in __getitem__
    return self._dict()[key]
KeyError: 'napalm_device'
[CRITICAL] Failed to load grains defined in grain file napalm.host in function <salt.loader.LoadedFunc object at 0x7f63382920b8>, error:
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 922, in grains
    ret = funcs[key](**kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 1241, in __call__
    return self.loader.run(run_func, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 2276, in run
    return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/contextvars/__init__.py", line 38, in run
    return callable(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 2291, in _run_as
    return _func_or_method(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/grains/napalm.py", line 353, in host
    return {"host": _get_device_grain("hostname", proxy=proxy)}
  File "/usr/lib/python3.6/site-packages/salt/grains/napalm.py", line 107, in _get_device_grain
    device = _retrieve_device_cache(proxy=proxy)
  File "/usr/lib/python3.6/site-packages/salt/grains/napalm.py", line 87, in _retrieve_device_cache
    DEVICE_CACHE = proxy["napalm.get_device"]()
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 1241, in __call__
    return self.loader.run(run_func, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 2276, in run
    return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/contextvars/__init__.py", line 38, in run
    return callable(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 2291, in _run_as
    return _func_or_method(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/proxy/napalm.py", line 252, in get_device
    return __context__["napalm_device"]["network_device"]
  File "/usr/lib/python3.6/site-packages/salt/loader_context.py", line 72, in __getitem__
    return self.value()[item]
  File "/usr/lib/python3.6/site-packages/salt/utils/context.py", line 223, in __getitem__
    return self._dict()[key]
KeyError: 'napalm_device'
[CRITICAL] Failed to load grains defined in grain file napalm.hostname in function <salt.loader.LoadedFunc object at 0x7f63382521d0>, error:Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 922, in grains
    ret = funcs[key](**kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 1241, in __call__
    return self.loader.run(run_func, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 2276, in run
    return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/contextvars/__init__.py", line 38, in run
    return callable(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 2291, in _run_as
    return _func_or_method(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/grains/napalm.py", line 310, in hostname
    return {"hostname": _get_grain("hostname", proxy=proxy)}
  File "/usr/lib/python3.6/site-packages/salt/grains/napalm.py", line 98, in _get_grain
    grains = _retrieve_grains_cache(proxy=proxy)
  File "/usr/lib/python3.6/site-packages/salt/grains/napalm.py", line 71, in _retrieve_grains_cache
    GRAINS_CACHE = proxy["napalm.get_grains"]()
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 1241, in __call__
    return self.loader.run(run_func, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 2276, in run
    return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/contextvars/__init__.py", line 38, in run
    return callable(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 2291, in _run_as
    return _func_or_method(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/proxy/napalm.py", line 259, in get_grains
    return call("get_facts", **{})
  File "/usr/lib/python3.6/site-packages/salt/proxy/napalm.py", line 349, in call
    __context__["napalm_device"]["network_device"], method, *args, **kwargs
  File "/usr/lib/python3.6/site-packages/salt/loader_context.py", line 72, in __getitem__
    return self.value()[item]
  File "/usr/lib/python3.6/site-packages/salt/utils/context.py", line 223, in __getitem__
    return self._dict()[key]
KeyError: 'napalm_device'
[CRITICAL] Failed to load grains defined in grain file napalm.interfaces in function <salt.loader.LoadedFunc object at 0x7f6338252908>, error:
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 922, in grains
    ret = funcs[key](**kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 1241, in __call__
    return self.loader.run(run_func, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 2276, in run
    return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/contextvars/__init__.py", line 38, in run
    return callable(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 2291, in _run_as
    return _func_or_method(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/grains/napalm.py", line 259, in interfaces
    return {"interfaces": _get_grain("interface_list", proxy=proxy)}
  File "/usr/lib/python3.6/site-packages/salt/grains/napalm.py", line 98, in _get_grain
    grains = _retrieve_grains_cache(proxy=proxy)
  File "/usr/lib/python3.6/site-packages/salt/grains/napalm.py", line 71, in _retrieve_grains_cache
    GRAINS_CACHE = proxy["napalm.get_grains"]()
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 1241, in __call__
    return self.loader.run(run_func, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 2276, in run
    return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/contextvars/__init__.py", line 38, in run
    return callable(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 2291, in _run_as
    return _func_or_method(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/proxy/napalm.py", line 259, in get_grains
    return call("get_facts", **{})
  File "/usr/lib/python3.6/site-packages/salt/proxy/napalm.py", line 349, in call
    __context__["napalm_device"]["network_device"], method, *args, **kwargs
  File "/usr/lib/python3.6/site-packages/salt/loader_context.py", line 72, in __getitem__
    return self.value()[item]
  File "/usr/lib/python3.6/site-packages/salt/utils/context.py", line 223, in __getitem__
    return self._dict()[key]
KeyError: 'napalm_device'
[CRITICAL] Failed to load grains defined in grain file napalm.model in function <salt.loader.LoadedFunc object at 0x7f6338252cf8>, error:
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 922, in grains
    ret = funcs[key](**kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 1241, in __call__
    return self.loader.run(run_func, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 2276, in run
    return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/contextvars/__init__.py", line 38, in run
    return callable(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 2291, in _run_as
    return _func_or_method(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/grains/napalm.py", line 171, in model
    return {"model": _get_grain("model", proxy=proxy)}
  File "/usr/lib/python3.6/site-packages/salt/grains/napalm.py", line 98, in _get_grain
    grains = _retrieve_grains_cache(proxy=proxy)
  File "/usr/lib/python3.6/site-packages/salt/grains/napalm.py", line 71, in _retrieve_grains_cache
    GRAINS_CACHE = proxy["napalm.get_grains"]()
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 1241, in __call__
    return self.loader.run(run_func, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 2276, in run
    return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/contextvars/__init__.py", line 38, in run
    return callable(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 2291, in _run_as
    return _func_or_method(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/proxy/napalm.py", line 259, in get_grains
    return call("get_facts", **{})
  File "/usr/lib/python3.6/site-packages/salt/proxy/napalm.py", line 349, in call
    __context__["napalm_device"]["network_device"], method, *args, **kwargs
  File "/usr/lib/python3.6/site-packages/salt/loader_context.py", line 72, in __getitem__
    return self.value()[item]
  File "/usr/lib/python3.6/site-packages/salt/utils/context.py", line 223, in __getitem__
    return self._dict()[key]
KeyError: 'napalm_device'
[CRITICAL] Failed to load grains defined in grain file napalm.optional_args in function <salt.loader.LoadedFunc object at 0x7f6338252d68>, error:
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 922, in grains
    ret = funcs[key](**kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 1241, in __call__
    return self.loader.run(run_func, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 2276, in run
    return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/contextvars/__init__.py", line 38, in run
    return callable(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 2291, in _run_as
    return _func_or_method(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/grains/napalm.py", line 442, in optional_args
    opt_args = _get_device_grain("optional_args", proxy=proxy) or {}
  File "/usr/lib/python3.6/site-packages/salt/grains/napalm.py", line 107, in _get_device_grain
    device = _retrieve_device_cache(proxy=proxy)
  File "/usr/lib/python3.6/site-packages/salt/grains/napalm.py", line 87, in _retrieve_device_cache
    DEVICE_CACHE = proxy["napalm.get_device"]()
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 1241, in __call__
    return self.loader.run(run_func, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 2276, in run
    return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/contextvars/__init__.py", line 38, in run
    return callable(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 2291, in _run_as
    return _func_or_method(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/proxy/napalm.py", line 252, in get_device
    return __context__["napalm_device"]["network_device"]
  File "/usr/lib/python3.6/site-packages/salt/loader_context.py", line 72, in __getitem__
    return self.value()[item]
  File "/usr/lib/python3.6/site-packages/salt/utils/context.py", line 223, in __getitem__
    return self._dict()[key]
KeyError: 'napalm_device'
[CRITICAL] Failed to load grains defined in grain file napalm.serial in function <salt.loader.LoadedFunc object at 0x7f6338257518>, error:  
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 922, in grains
    ret = funcs[key](**kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 1241, in __call__
    return self.loader.run(run_func, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 2276, in run
    return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/contextvars/__init__.py", line 38, in run
    return callable(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 2291, in _run_as
    return _func_or_method(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/grains/napalm.py", line 199, in serial
    return {"serial": _get_grain("serial_number", proxy=proxy)}
  File "/usr/lib/python3.6/site-packages/salt/grains/napalm.py", line 98, in _get_grain
    grains = _retrieve_grains_cache(proxy=proxy)
  File "/usr/lib/python3.6/site-packages/salt/grains/napalm.py", line 71, in _retrieve_grains_cache
    GRAINS_CACHE = proxy["napalm.get_grains"]()
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 1241, in __call__
    return self.loader.run(run_func, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 2276, in run
    return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/contextvars/__init__.py", line 38, in run
    return callable(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 2291, in _run_as
    return _func_or_method(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/proxy/napalm.py", line 259, in get_grains
    return call("get_facts", **{})
  File "/usr/lib/python3.6/site-packages/salt/proxy/napalm.py", line 349, in call
    __context__["napalm_device"]["network_device"], method, *args, **kwargs
  File "/usr/lib/python3.6/site-packages/salt/loader_context.py", line 72, in __getitem__
    return self.value()[item]
  File "/usr/lib/python3.6/site-packages/salt/utils/context.py", line 223, in __getitem__
    return self._dict()[key]
KeyError: 'napalm_device'
[CRITICAL] Failed to load grains defined in grain file napalm.uptime in function <salt.loader.LoadedFunc object at 0x7f6338257908>, error:  
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 922, in grains
    ret = funcs[key](**kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 1241, in __call__
    return self.loader.run(run_func, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 2276, in run
    return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/contextvars/__init__.py", line 38, in run
    return callable(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 2291, in _run_as
    return _func_or_method(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/grains/napalm.py", line 227, in uptime
    return {"uptime": _get_grain("uptime", proxy=proxy)}
  File "/usr/lib/python3.6/site-packages/salt/grains/napalm.py", line 98, in _get_grain
    grains = _retrieve_grains_cache(proxy=proxy)
  File "/usr/lib/python3.6/site-packages/salt/grains/napalm.py", line 71, in _retrieve_grains_cache
    GRAINS_CACHE = proxy["napalm.get_grains"]()
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 1241, in __call__
    return self.loader.run(run_func, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 2276, in run
    return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/contextvars/__init__.py", line 38, in run
    return callable(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 2291, in _run_as
    return _func_or_method(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/proxy/napalm.py", line 259, in get_grains
    return call("get_facts", **{})
  File "/usr/lib/python3.6/site-packages/salt/proxy/napalm.py", line 349, in call
    __context__["napalm_device"]["network_device"], method, *args, **kwargs
  File "/usr/lib/python3.6/site-packages/salt/loader_context.py", line 72, in __getitem__
    return self.value()[item]
  File "/usr/lib/python3.6/site-packages/salt/utils/context.py", line 223, in __getitem__
    return self._dict()[key]
KeyError: 'napalm_device'
[CRITICAL] Failed to load grains defined in grain file napalm.username in function <salt.loader.LoadedFunc object at 0x7f6338257cf8>, error:Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 922, in grains
    ret = funcs[key](**kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 1241, in __call__
    return self.loader.run(run_func, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 2276, in run
    return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/contextvars/__init__.py", line 38, in run
    return callable(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 2291, in _run_as
    return _func_or_method(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/grains/napalm.py", line 286, in username
    return {"username": _get_device_grain("username", proxy=proxy)}
  File "/usr/lib/python3.6/site-packages/salt/grains/napalm.py", line 107, in _get_device_grain
    device = _retrieve_device_cache(proxy=proxy)
  File "/usr/lib/python3.6/site-packages/salt/grains/napalm.py", line 87, in _retrieve_device_cache
    DEVICE_CACHE = proxy["napalm.get_device"]()
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 1241, in __call__
    return self.loader.run(run_func, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 2276, in run
    return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/contextvars/__init__.py", line 38, in run
    return callable(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 2291, in _run_as
    return _func_or_method(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/proxy/napalm.py", line 252, in get_device
    return __context__["napalm_device"]["network_device"]
  File "/usr/lib/python3.6/site-packages/salt/loader_context.py", line 72, in __getitem__
    return self.value()[item]
  File "/usr/lib/python3.6/site-packages/salt/utils/context.py", line 223, in __getitem__
    return self._dict()[key]
KeyError: 'napalm_device'
[CRITICAL] Failed to load grains defined in grain file napalm.vendor in function <salt.loader.LoadedFunc object at 0x7f6338257d68>, error:  
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 922, in grains
    ret = funcs[key](**kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 1241, in __call__
    return self.loader.run(run_func, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 2276, in run
    return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/contextvars/__init__.py", line 38, in run
    return callable(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 2291, in _run_as
    return _func_or_method(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/grains/napalm.py", line 214, in vendor
    return {"vendor": _get_grain("vendor", proxy=proxy)}
  File "/usr/lib/python3.6/site-packages/salt/grains/napalm.py", line 98, in _get_grain
    grains = _retrieve_grains_cache(proxy=proxy)
  File "/usr/lib/python3.6/site-packages/salt/grains/napalm.py", line 71, in _retrieve_grains_cache
    GRAINS_CACHE = proxy["napalm.get_grains"]()
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 1241, in __call__
    return self.loader.run(run_func, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 2276, in run
    return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/contextvars/__init__.py", line 38, in run
    return callable(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 2291, in _run_as
    return _func_or_method(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/proxy/napalm.py", line 259, in get_grains
    return call("get_facts", **{})
  File "/usr/lib/python3.6/site-packages/salt/proxy/napalm.py", line 349, in call
    __context__["napalm_device"]["network_device"], method, *args, **kwargs
  File "/usr/lib/python3.6/site-packages/salt/loader_context.py", line 72, in __getitem__
    return self.value()[item]
  File "/usr/lib/python3.6/site-packages/salt/utils/context.py", line 223, in __getitem__
    return self._dict()[key]
KeyError: 'napalm_device'
[CRITICAL] Failed to load grains defined in grain file napalm.version in function <salt.loader.LoadedFunc object at 0x7f6338255518>, error:
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 922, in grains
    ret = funcs[key](**kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 1241, in __call__
    return self.loader.run(run_func, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 2276, in run
    return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/contextvars/__init__.py", line 38, in run
    return callable(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 2291, in _run_as
    return _func_or_method(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/grains/napalm.py", line 156, in version
    return {"version": _get_grain("os_version", proxy=proxy)}
  File "/usr/lib/python3.6/site-packages/salt/grains/napalm.py", line 98, in _get_grain
    grains = _retrieve_grains_cache(proxy=proxy)
  File "/usr/lib/python3.6/site-packages/salt/grains/napalm.py", line 71, in _retrieve_grains_cache
    GRAINS_CACHE = proxy["napalm.get_grains"]()
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 1241, in __call__
    return self.loader.run(run_func, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 2276, in run
    return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/contextvars/__init__.py", line 38, in run
    return callable(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 2291, in _run_as
    return _func_or_method(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/proxy/napalm.py", line 259, in get_grains
    return call("get_facts", **{})
  File "/usr/lib/python3.6/site-packages/salt/proxy/napalm.py", line 349, in call
    __context__["napalm_device"]["network_device"], method, *args, **kwargs
  File "/usr/lib/python3.6/site-packages/salt/loader_context.py", line 72, in __getitem__
    return self.value()[item]
  File "/usr/lib/python3.6/site-packages/salt/utils/context.py", line 223, in __getitem__
    return self._dict()[key]
KeyError: 'napalm_device'

@ggiesen ggiesen reopened this May 26, 2021
@ggiesen
Copy link
Contributor

ggiesen commented May 26, 2021

@dmurphy18

Note that the regular proxy minion still connects to the device, and will reconnect if the session is killed, but I get those tracebacks at startup.

@garethgreenaway With @dmurphy18's patch, deltaproxy still never reconnects if the session is killed.

@garethgreenaway
Copy link
Contributor

@ggiesen but you don't see the traceback ad you did before? Or you didn't see that traceback?

@ggiesen
Copy link
Contributor

ggiesen commented May 26, 2021

To clarify, I'm not seeing any traceback from deltaproxy. Reconnect just doesn't work, even with @garethgreenaway latest commit ( 3a577ca ).

With regular proxy minion, reconnect now works, but getting the traceback in #60025 (comment) and periodically also getting:

[ERROR   ] Future <salt.ext.tornado.concurrent.Future object at 0x7eff4261dc50> exception was never retrieved: Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/salt/ext/tornado/gen.py", line 1070, in run
    yielded = self.gen.send(value)
  File "/usr/lib/python3.6/site-packages/salt/transport/zeromq.py", line 666, in wrap_callback
    callback(payload)
  File "/usr/lib/python3.6/site-packages/salt/minion.py", line 3771, in _handle_payload
    return mp_call(self, payload)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 1241, in __call__
    return self.loader.run(run_func, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 2276, in run
    return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/contextvars/__init__.py", line 38, in run
    return callable(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader.py", line 2291, in _run_as
    return _func_or_method(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/metaproxy/deltaproxy.py", line 869, in handle_payload
    instance = self.deltaproxy_objs[_id]
KeyError: 'router2'

I'm applying the following patches:

sudo curl 'https://raw.githubusercontent.com/saltstack/salt/aab00269fa893b3bd099f863914843aff8c49598/salt/loader.py' -o /usr/lib/python3.6/site-packages/salt/loader.py
sudo curl 'https://raw.githubusercontent.com/saltstack/salt/aab00269fa893b3bd099f863914843aff8c49598/salt/metaproxy/deltaproxy.py' -o /usr/lib/python3.6/site-packages/salt/metaproxy/deltaproxy.py
sudo curl 'https://raw.githubusercontent.com/saltstack/salt/aab00269fa893b3bd099f863914843aff8c49598/salt/proxy/deltaproxy.py' -o /usr/lib/python3.6/site-packages/salt/proxy/deltaproxy.py
sudo curl 'https://raw.githubusercontent.com/saltstack/salt/aab00269fa893b3bd099f863914843aff8c49598/salt/proxy/dummy.py' -o /usr/lib/python3.6/site-packages/salt/proxy/dummy.py
sudo curl 'https://raw.githubusercontent.com/saltstack/salt/aab00269fa893b3bd099f863914843aff8c49598/salt/proxy/napalm.py' -o /usr/lib/python3.6/site-packages/salt/proxy/napalm.py
sudo curl 'https://raw.githubusercontent.com/saltstack/salt/3a577ca35dc4beac185d3e8a61d9b7d51100ce07/salt/utils/napalm.py' -o /usr/lib/python3.6/site-packages/salt/utils/napalm.py
sudo curl 'https://raw.githubusercontent.com/dmurphy18/salt/2c6e00ccb0cfc35d57cbb5109175b999a310eefb/salt/modules/status.py' -o /usr/lib/python3.6/site-packages/salt/modules/status.py

@dmurphy18
Copy link
Contributor

@ggiesen Looks as if you are encountering an additional problem which was hidden by the original problem (presuming you have applied the changes in #60244 correctly). I suggest that you open a new issue referencing the subsequent issue with the fix from #60244 applied, given the key error is not get_reboot_active

Can you open an issue as described above and re-close this, as best practice is to open issues for new items rather than tack them on to existing or re-opened issues.
Thanks

@dmurphy18
Copy link
Contributor

@ggiesen Closing this, since your issue experienced is not the original issue. Please open a new issue for the problems you have seen as outlined in the comment above.

@TheBirdsNest
Copy link

TheBirdsNest commented Jul 20, 2021

Could someone please advise how I can get this update?
I have the same issue but its still present in version 3003.. unless I am missing something?

Salt Version:
          Salt: 3003

Dependency Versions:
          cffi: 1.14.5
      cherrypy: 18.6.1
      dateutil: 2.8.1
     docker-py: Not Installed
         gitdb: Not Installed
     gitpython: Not Installed
        Jinja2: 3.0.1
       libgit2: 1.1.0
      M2Crypto: Not Installed
          Mako: Not Installed
       msgpack: 1.0.2
  msgpack-pure: Not Installed
  mysql-python: Not Installed
     pycparser: 2.20
      pycrypto: 3.10.1
  pycryptodome: 3.10.1
        pygit2: 1.4.0
        Python: 3.9.5 (default, May 12 2021, 20:44:22)
  python-gnupg: Not Installed
        PyYAML: 5.4.1
         PyZMQ: 19.0.2
         smmap: Not Installed
       timelib: Not Installed
       Tornado: 4.5.3
           ZMQ: 4.3.4
KeyError: 'napalm.get_reboot_active'
[DEBUG   ] schedule.handle_func: Removing /var/cache/salt/proxy/c40988df-1a86-4ff0-bf8d-e018cc6c55bd/proc/20210720125224866766
[DEBUG   ] LazyLoaded mine.update
[DEBUG   ] Subprocess Thread-159-Schedule-__proxy_keepalive cleaned up

Current status of /usr/lib/python3.9/site-packages/salt/modules/status.py:

    if __proxy__[proxy_name + ".get_reboot_active"]():
        # if rebooting or shutting down, don't run proxy_reconnect
        # it interferes with the connection and disrupts the shutdown/reboot
        # especially
        minion_id = opts.get("proxyid", "") or opts.get("id", "")
        log.info(
            "{} ({} proxy) is rebooting or shutting down. Don't probe connection.".format(
                minion_id, proxy_name
            )
        )
        return True

    is_alive = __proxy__[proxy_keepalive_fn](opts)
    if not is_alive:
        minion_id = opts.get("proxyid", "") or opts.get("id", "")
        log.info("%s (%s proxy) is down. Restarting.", minion_id, proxy_name)
        __proxy__[proxy_name + ".shutdown"](opts)  # safely close connection
        __proxy__[proxy_name + ".init"](opts)  # reopen connection
        log.debug("Restarted %s (%s proxy)!", minion_id, proxy_name)

    return True  # success

@dmurphy18 could you advise how to pull this?

@network-shark
Copy link
Contributor Author

network-shark commented Jul 20, 2021

@TheBirdsNest You could manually try to apply the patches to your current salt version, but it’s not clear if this will race other issues. @ggiesen tried it and got other errors and gave up on this due to lack of time. I hope we will see these fixes in 3004

@dmurphy18
Copy link
Contributor

@TheBirdsNest The fix should be available in Salt 3003.1. looking at the code for salt/modules/status.py with tag v3003.1 and

1789     chk_reboot_active_key = proxy_name + ".get_reboot_active"
1790     if chk_reboot_active_key in __proxy__ and __proxy__[chk_reboot_active_key]():
1791         # if rebooting or shutting down, don't run proxy_reconnect
1792         # it interferes with the connection and disrupts the shutdown/reboot
1793         # especially
1794         minion_id = opts.get("proxyid", "") or opts.get("id", "")
1795         log.info(
1796             "%s (%s proxy) is rebooting or shutting down. Don't probe connection.",
1797             minion_id,
1798             proxy_name,
1799         )
1800         return True

Also the fix was merged May 25th, 3003.1 released in mid June

@TheBirdsNest
Copy link

Thanks @dmurphy18

I just checked and its not in our release:

    if __proxy__[proxy_name + ".get_reboot_active"]():
        # if rebooting or shutting down, don't run proxy_reconnect
        # it interferes with the connection and disrupts the shutdown/reboot
        # especially
        minion_id = opts.get("proxyid", "") or opts.get("id", "")
        log.info(
            "{} ({} proxy) is rebooting or shutting down. Don't probe connection.".format(
                minion_id, proxy_name
            )
        )
        return True
lbird@gcp3476prdamn02 ~]$ salt --versions-report
Salt Version:
          Salt: 3003.2
 
Dependency Versions:
          cffi: 1.14.5
      cherrypy: Not Installed
      dateutil: 2.8.1
     docker-py: 4.4.4
         gitdb: Not Installed
     gitpython: Not Installed
        Jinja2: 2.11.3
       libgit2: Not Installed
      M2Crypto: 0.35.2
          Mako: Not Installed
       msgpack: 0.6.2
  msgpack-pure: Not Installed
  mysql-python: Not Installed
     pycparser: 2.20
      pycrypto: Not Installed
  pycryptodome: 3.10.1
        pygit2: Not Installed
        Python: 3.6.8 (default, Nov 16 2020, 16:55:22)
  python-gnupg: Not Installed
        PyYAML: 5.4.1
         PyZMQ: 17.0.0
         smmap: Not Installed
       timelib: Not Installed
       Tornado: 4.5.3
           ZMQ: 4.1.4
 
System Versions:
          dist: centos 7 Core
        locale: UTF-8
       machine: x86_64
       release: 3.10.0-1160.36.2.el7.x86_64
        system: Linux
       version: CentOS Linux 7 Core
```

@dmurphy18
Copy link
Contributor

I checked out the tagged release and it was in the copy of the code. Let me check installed code.

@network-shark
Copy link
Contributor Author

network-shark commented Aug 23, 2021

I still see those messages on my proxy minions 3002.2

[ERROR   ] Unhandled exception running status.proxy_reconnect
Traceback (most recent call last):
  File "/Users/sharky/.pyenv/versions/3.8.6/envs/salt3003_2/lib/python3.8/site-packages/salt/utils/schedule.py", line 843, in handle_func
    ret["return"] = self.functions[func](*args, **kwargs)
  File "/Users/sharky/.pyenv/versions/3.8.6/envs/salt3003_2/lib/python3.8/site-packages/salt/loader.py", line 1241, in __call__
    return self.loader.run(run_func, *args, **kwargs)
  File "/Users/sharky/.pyenv/versions/3.8.6/envs/salt3003_2/lib/python3.8/site-packages/salt/loader.py", line 2274, in run
    return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
  File "/Users/sharky/.pyenv/versions/3.8.6/envs/salt3003_2/lib/python3.8/site-packages/salt/loader.py", line 2289, in _run_as
    return _func_or_method(*args, **kwargs)
  File "/Users/sharky/.pyenv/versions/3.8.6/envs/salt3003_2/lib/python3.8/site-packages/salt/modules/status.py", line 1793, in proxy_reconnect
    if __proxy__[proxy_name + ".get_reboot_active"]():
  File "/Users/sharky/.pyenv/versions/3.8.6/envs/salt3003_2/lib/python3.8/site-packages/salt/loader_context.py", line 78, in __getitem__
    return self.value()[item]
  File "/Users/sharky/.pyenv/versions/3.8.6/envs/salt3003_2/lib/python3.8/site-packages/salt/loader.py", line 1409, in __getitem__
    func = super().__getitem__(item)
  File "/Users/sharky/.pyenv/versions/3.8.6/envs/salt3003_2/lib/python3.8/site-packages/salt/utils/lazy.py", line 110, in __getitem__
    return self._dict[key]
KeyError: 'napalm.get_reboot_active'

@dmurphy18
Copy link
Contributor

@TheBirdsNest @network-shark Apologies, I must have fat-fingered the git checkout for tag v3003.2 and got master branch when I thought I had v3003.2. You are correct, the fix will appear in the Silicon release, see a5d9545

Apologies for the confusion. I thought it had made it into 3003.2 but must have just missed the cutoff date.

@kzorba
Copy link

kzorba commented Sep 8, 2021

Just bumped into this issue, I consider it serious enough in network automation cases as the network proxies become unusable as mentioned.
I can confirm that by applying just the patch in a5d9545 in v3003.1 fixes the issue. No problems / exceptions also shown in debug logs of the proxy. Unfortunately I see the fix is not on the latest v3003.3. We expect it only on v3004 (Silicon) or also in the next point release of v3003?
For now I will need to rollback to a v3002.x that works I guess.
Thank you for the fix!

My running version:

root@salt-master:~# salt -V
Salt Version:
          Salt: 3003.1
 
Dependency Versions:
          cffi: 1.14.5
      cherrypy: unknown
      dateutil: 2.6.1
     docker-py: Not Installed
         gitdb: 2.0.3
     gitpython: 2.1.8
        Jinja2: 3.0.1
       libgit2: Not Installed
      M2Crypto: Not Installed
          Mako: Not Installed
       msgpack: 0.5.6
  msgpack-pure: Not Installed
  mysql-python: Not Installed
     pycparser: 2.18
      pycrypto: 2.6.1
  pycryptodome: 3.4.7
        pygit2: Not Installed
        Python: 3.6.9 (default, Jan 26 2021, 15:33:00)
  python-gnupg: 0.4.1
        PyYAML: 5.4.1
         PyZMQ: 17.1.2
         smmap: 2.0.3
       timelib: Not Installed
       Tornado: 4.5.3
           ZMQ: 4.2.5
 
System Versions:
          dist: ubuntu 18.04 Bionic Beaver
        locale: UTF-8
       machine: x86_64
       release: 4.15.0-139-generic
        system: Linux
       version: Ubuntu 18.04 Bionic Beaver

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 Confirmed Salt engineer has confirmed bug/feature - often including a MCVE lazy-loader severity-medium 3rd level, incorrect or bad functionality, confusing and lacks a work around
Projects
None yet
9 participants