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

Cannot simultaneously set/delete NTP server/peers with NAPALM proxy in EOS #39149

Closed
bewing opened this issue Feb 2, 2017 · 4 comments
Closed
Labels
info-needed waiting for more info
Milestone

Comments

@bewing
Copy link
Contributor

bewing commented Feb 2, 2017

Description of Issue/Question

Using netntp.managed, I am able to successfully call state.sls to add a new NTP server, or remove an NTP server, but if I need to simultaneously add and delete at the same time, an exception is returned.

Setup

root@saltmaster:~# salt-master --version
salt-master 2016.11.2 (Carbon)
root@saltmaster:~# salt veos1 test.versions
veos1:
    Salt Version:
               Salt: 2016.11.2

    Dependency Versions:
               cffi: Not Installed
           cherrypy: Not Installed
           dateutil: 1.5
              gitdb: Not Installed
          gitpython: Not Installed
              ioflo: Not Installed
             Jinja2: 2.7.2
            libgit2: Not Installed
            libnacl: Not Installed
           M2Crypto: Not Installed
               Mako: 0.9.1
       msgpack-pure: Not Installed
     msgpack-python: 0.4.6
       mysql-python: 1.2.3
          pycparser: Not Installed
           pycrypto: 2.6.1
             pygit2: Not Installed
             Python: 2.7.6 (default, Oct 26 2016, 20:30:19)
       python-gnupg: Not Installed
             PyYAML: 3.10
              PyZMQ: 14.0.1
               RAET: Not Installed
              smmap: Not Installed
            timelib: Not Installed
            Tornado: 4.2.1
                ZMQ: 4.0.5

    System Versions:
               dist: Ubuntu 14.04 trusty
            machine: x86_64
            release: 3.13.0-43-generic
             system: Linux
            version: Ubuntu 14.04 trusty

root@saltmaster:~# cat /srv/salt/router/ntp.sls
{% set ntp_peers = pillar.get('ntp.peers', {}) -%}
{% set ntp_servers = pillar.get('ntp.servers', {}) -%}

cf_ntp:
  netntp.managed:
    - peers: {{ntp_peers}}
    - servers: {{ntp_servers}}

Steps to Reproduce Issue

Edit /srv/pillar/veos1.sls to cause both an add and a remove operation to occur at the same time, and call the state.

root@saltmaster:/srv/salt# salt veos1 state.sls router.ntp
veos1:
----------
          ID: cf_ntp
    Function: netntp.managed
      Result: False
     Comment: Cannot remove NTP servers: Cannot execute "load_template" on veos1 as bewing. Reason: Session is already in use by napalm!
              Configuration discarded.Configuration was not changed on the device.
     Started: 14:43:22.809419
    Duration: 3546.171 ms
     Changes:
              ----------
              servers:
                  ----------
                  added:
                      - 192.168.0.1
                  removed:
                      - 10.194.2.17

Summary for veos1
------------
Succeeded: 0 (changed=1)
Failed:    1
------------
Total states run:     1
Total run time:   3.546 s
ERROR: Minions returned with non-zero exit code

Debug log from the proxy:

[INFO    ] User root Executing command state.sls with jid 20170202145500184830
[DEBUG   ] Command details {'tgt_type': 'glob', 'jid': '20170202145500184830', 'tgt': 'veos1', 'ret': '', 'user': 'root', 'arg': ['router.ntp'], 'fun': 'state.sls'}
[INFO    ] Starting a new job with PID 46431
[DEBUG   ] Initializing new AsyncZeroMQReqChannel for ('/etc/salt/pki/minion', 'veos1', 'tcp://10.192.100.75:4506', 'aes')
[DEBUG   ] Initializing new AsyncAuth for ('/etc/salt/pki/minion', 'veos1', 'tcp://10.192.100.75:4506')
[DEBUG   ] Determining pillar cache
[DEBUG   ] Initializing new AsyncZeroMQReqChannel for ('/etc/salt/pki/minion', 'veos1', 'tcp://10.192.100.75:4506', 'aes')
[DEBUG   ] Initializing new AsyncAuth for ('/etc/salt/pki/minion', 'veos1', 'tcp://10.192.100.75:4506')
[DEBUG   ] Loaded minion key: /etc/salt/pki/minion/minion.pem
[INFO    ] Loading fresh modules for state activity
[DEBUG   ] LazyLoaded jinja.render
[DEBUG   ] LazyLoaded yaml.render
[DEBUG   ] In saltenv 'base', looking at rel_path 'router/ntp.sls' to resolve 'salt://router/ntp.sls'
[DEBUG   ] In saltenv 'base', ** considering ** path '/var/cache/salt/minion/veos1/files/base/router/ntp.sls' to resolve 'salt://router/ntp.sls'
[INFO    ] Fetching file from saltenv 'base', ** skipped ** latest already in cache 'salt://router/ntp.sls', mode up-to-date
[DEBUG   ] compile template: /var/cache/salt/minion/veos1/files/base/router/ntp.sls
[DEBUG   ] Jinja search path: ['/var/cache/salt/minion/veos1/files/base']
[PROFILE ] Time (in seconds) to render '/var/cache/salt/minion/veos1/files/base/router/ntp.sls' using 'jinja' renderer: 0.00273108482361
[DEBUG   ] Rendered data from file: /var/cache/salt/minion/veos1/files/base/router/ntp.sls:
cf_ntp:
  netntp.managed:
    - peers: {}
    - servers: ['10.203.7.37', '192.168.0.1']

[DEBUG   ] LazyLoaded config.get
[DEBUG   ] Results of YAML rendering:
OrderedDict([('cf_ntp', OrderedDict([('netntp.managed', [OrderedDict([('peers', OrderedDict())]), OrderedDict([('servers', ['10.203.7.37', '192.168.0.1'])])])]))])
[PROFILE ] Time (in seconds) to render '/var/cache/salt/minion/veos1/files/base/router/ntp.sls' using 'yaml' renderer: 0.00290894508362
[DEBUG   ] LazyLoaded netntp.managed
[INFO    ] Running state [cf_ntp] at time 14:55:00.337600
[INFO    ] Executing state netntp.managed for cf_ntp
[DEBUG   ] LazyLoaded ntp.servers
[DEBUG   ] Request content: {"params": {"format": "text", "version": 1, "cmds": ["enable", "show running-config | section ntp"]}, "jsonrpc": "2.0", "method": "runCmds", "id": "140089577211984"}
[DEBUG   ] Response: status:200, reason:OK
[DEBUG   ] Response content: {"jsonrpc": "2.0", "result": [{"output": ""}, {"output": "ntp server 10.194.2.17\nntp server 10.203.7.37\n", "warnings": ["Command: show running-config"]}], "id": "140089577211984"}
[DEBUG   ] eapi_response: {u'jsonrpc': u'2.0', u'result': [{u'output': u''}, {u'output': u'ntp server 10.194.2.17\nntp server 10.203.7.37\n', u'warnings': [u'Command: show running-config']}], u'id': u'140089577211984'}
[DEBUG   ] LazyLoaded net.load_template
[DEBUG   ] LazyLoaded file.file_exists
[DEBUG   ] Request content: {"params": {"format": "json", "version": 1, "cmds": ["enable", "configure session napalm_842136", "ntp server 192.168.0.1"]}, "jsonrpc": "2.0", "method": "runCmds", "id": "140089577211984"}
[DEBUG   ] Response: status:200, reason:OK
[DEBUG   ] Response content: {"jsonrpc": "2.0", "result": [{}, {}, {}], "id": "140089577211984"}
[DEBUG   ] eapi_response: {u'jsonrpc': u'2.0', u'result': [{}, {}, {}], u'id': u'140089577211984'}
[DEBUG   ] Request content: {"params": {"format": "text", "version": 1, "cmds": ["enable", "show session-config named napalm_842136 diffs"]}, "jsonrpc": "2.0", "method": "runCmds", "id": "140089577211984"}
[DEBUG   ] Response: status:200, reason:OK
[DEBUG   ] Response content: {"jsonrpc": "2.0", "result": [{"output": ""}, {"output": "--- system:/running-config\n+++ session:/napalm_842136-session-config\n@@ -13,6 +13,7 @@\n !\n ntp server 10.194.2.17\n ntp server 10.203.7.37\n+ntp server 192.168.0.1\n !\n snmp-server contact netdc@contoso.com\n snmp-server location atlantis\n\n"}], "id": "140089577211984"}
[DEBUG   ] eapi_response: {u'jsonrpc': u'2.0', u'result': [{u'output': u''}, {u'output': u'--- system:/running-config\n+++ session:/napalm_842136-session-config\n@@ -13,6 +13,7 @@\n !\n ntp server 10.194.2.17\n ntp server 10.203.7.37\n+ntp server 192.168.0.1\n !\n snmp-server contact netdc@contoso.com\n snmp-server location atlantis\n\n'}], u'id': u'140089577211984'}
[ERROR   ] Cannot execute "load_template" on veos1 as bewing. Reason: Session is already in use by napalm!
[ERROR   ] Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/salt/proxy/napalm.py", line 294, in call
    out = getattr(NETWORK_DEVICE.get('DRIVER'), method)(**params)  # calls the method with the specified parameters
  File "/usr/local/lib/python2.7/dist-packages/napalm_base/base.py", line 127, in load_template
    **template_vars)
  File "/usr/local/lib/python2.7/dist-packages/napalm_base/helpers.py", line 86, in load_template
    return cls.load_merge_candidate(config=configuration)
  File "/usr/local/lib/python2.7/dist-packages/napalm_eos/eos.py", line 170, in load_merge_candidate
    self._load_config(filename, config, False)
  File "/usr/local/lib/python2.7/dist-packages/napalm_eos/eos.py", line 127, in _load_config
    raise SessionLockedException('Session is already in use by napalm')
SessionLockedException: Session is already in use by napalm

[DEBUG   ] Request content: {"params": {"format": "text", "version": 1, "cmds": ["enable", "show session-config named napalm_842136 diffs"]}, "jsonrpc": "2.0", "method": "runCmds", "id": "140089577211984"}
[DEBUG   ] Response: status:200, reason:OK
[DEBUG   ] Response content: {"jsonrpc": "2.0", "result": [{"output": ""}, {"output": "--- system:/running-config\n+++ session:/napalm_842136-session-config\n@@ -13,6 +13,7 @@\n !\n ntp server 10.194.2.17\n ntp server 10.203.7.37\n+ntp server 192.168.0.1\n !\n snmp-server contact netdc@contoso.com\n snmp-server location atlantis\n\n"}], "id": "140089577211984"}
[DEBUG   ] eapi_response: {u'jsonrpc': u'2.0', u'result': [{u'output': u''}, {u'output': u'--- system:/running-config\n+++ session:/napalm_842136-session-config\n@@ -13,6 +13,7 @@\n !\n ntp server 10.194.2.17\n ntp server 10.203.7.37\n+ntp server 192.168.0.1\n !\n snmp-server contact netdc@contoso.com\n snmp-server location atlantis\n\n'}], u'id': u'140089577211984'}
[DEBUG   ] Request content: {"params": {"format": "json", "version": 1, "cmds": ["enable", "configure session napalm_842136", "abort"]}, "jsonrpc": "2.0", "method": "runCmds", "id": "140089577211984"}
[DEBUG   ] Response: status:200, reason:OK
[DEBUG   ] Response content: {"jsonrpc": "2.0", "result": [{}, {}, {}], "id": "140089577211984"}
[DEBUG   ] eapi_response: {u'jsonrpc': u'2.0', u'result': [{}, {}, {}], u'id': u'140089577211984'}
[ERROR   ] {'servers': {'removed': [u'10.194.2.17'], 'added': ['192.168.0.1']}}
[INFO    ] Completed state [cf_ntp] at time 14:55:04.320105 duration_in_ms=3982.445
[DEBUG   ] File /var/cache/salt/minion/veos1/accumulator/140089295142480 does not exist, no need to cleanup.
[DEBUG   ] Minion return retry timer set to 9 seconds (randomized)
[INFO    ] Returning information for job: 20170202145500184830
[DEBUG   ] Initializing new AsyncZeroMQReqChannel for ('/etc/salt/pki/minion', 'veos1', 'tcp://10.192.100.75:4506', 'aes')
[DEBUG   ] Initializing new AsyncAuth for ('/etc/salt/pki/minion', 'veos1', 'tcp://10.192.100.75:4506')

Versions Report

root@saltminion1:~# pip freeze | grep napalm
napalm==1.1.0
napalm-base==0.22.0
napalm-eos==0.5.3
napalm-fortios==0.3.1
napalm-ibm==0.1.6
napalm-ios==0.6.0
napalm-iosxr==0.4.7
napalm-junos==0.6.3
napalm-nxos==0.5.0
napalm-panos==0.3.0
napalm-pluribus==0.5.0
@bewing
Copy link
Contributor Author

bewing commented Feb 2, 2017

@mirceaulinic

@Ch3LL
Copy link
Contributor

Ch3LL commented Feb 3, 2017

@bewing it seems that PR has resolved the issue. are you okay to close this issue?

@Ch3LL Ch3LL added the info-needed waiting for more info label Feb 3, 2017
@Ch3LL Ch3LL added this to the Blocked milestone Feb 3, 2017
@mirceaulinic
Copy link
Contributor

Yes, I think we can close this one!

Thanks @bewing @Ch3LL

@Ch3LL
Copy link
Contributor

Ch3LL commented Feb 8, 2017

Thanks!

@Ch3LL Ch3LL closed this as completed Feb 8, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
info-needed waiting for more info
Projects
None yet
Development

No branches or pull requests

3 participants