Skip to content

Running salt-call on salt master would crash the master node with code level 2015.8.3 #29701

Closed

Description

@tonyyang132

We are trying to upgrade our salt packages from 2015.5.3 to 2015.8.3. One issue popped up during the evaluation. We have two lines of salt-call statements that we run on the salt master node (no salt-minion package installed on the master node). With version 2015.5.3 they ran fine. But with version 2015.8.3 the following exception was raised:

[ERROR   ] Future exception was never retrieved: Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/tornado/gen.py", line 230, in wrapper
    yielded = next(result)
  File "/usr/lib/python2.7/dist-packages/salt/minion.py", line 495, in eval_master
    pub_channel = salt.transport.client.AsyncPubChannel.factory(self.opts, **factory_kwargs)
  File "/usr/lib/python2.7/dist-packages/salt/transport/client.py", line 154, in factory
    return salt.transport.zeromq.AsyncZeroMQPubChannel(opts, **kwargs)
  File "/usr/lib/python2.7/dist-packages/salt/transport/zeromq.py", line 253, in __init__
    self.auth = salt.crypt.AsyncAuth(self.opts, io_loop=self.io_loop)
  File "/usr/lib/python2.7/dist-packages/salt/crypt.py", line 323, in __new__
    new_auth.__singleton_init__(opts, io_loop=io_loop)
  File "/usr/lib/python2.7/dist-packages/salt/crypt.py", line 361, in __singleton_init__
    self.get_keys()
  File "/usr/lib/python2.7/dist-packages/salt/crypt.py", line 575, in get_keys
    salt.utils.verify.check_path_traversal(self.opts['pki_dir'], user)
  File "/usr/lib/python2.7/dist-packages/salt/utils/verify.py", line 400, in check_path_traversal
    raise SaltClientError(msg)
SaltClientError: Could not access /etc/salt/pki/minion. Path does not exist.
Exception ValueError: 'I/O operation on closed file' in <bound method SyncWrapper.__del__ of <salt.utils.async.SyncWrapper object at 0x7f026c0a4990>> ignored
Exception ValueError: 'I/O operation on closed file' in <bound method SyncWrapper.__del__ of <salt.utils.async.SyncWrapper object at 0x7f026c0a4990>> ignored
Exception ValueError: 'I/O operation on closed file' in <bound method SyncWrapper.__del__ of <salt.utils.async.SyncWrapper object at 0x7f026c0a4990>> ignored
Exception ValueError: 'I/O operation on closed file' in <bound method SyncWrapper.__del__ of <salt.utils.async.SyncWrapper object at 0x7f026c0a4990>> ignored
...

The ValueError: 'I/O operation on closed file' kept popping to stderr until the last bit of memory was exhausted and the salt master node stopped responding.

I was actually able to reproduce the issue with a very simple salt setup.

  1. Clone salt-vagrant-demo.

  2. Run vagrant up to launch and setup the stack.

  3. vagrant ssh master to login to the master node, switch to the root user.

  4. Edit /etc/hosts and add the following line:

    192.168.50.10 salt
    
  5. Create a simple state file. Mine was like the following:

    root@saltmaster:~# cat /srv/salt/tony/init.sls
    tony_script:
      cmd.run:
        - name: date
        - user: root
        - group: root
        - shell: /bin/bash
    
  6. Run the state on the salt node.

    root@saltmaster:/srv/salt/tony# salt-call state.sls tony
    [ERROR   ] Future exception was never retrieved: Traceback (most recent call last):
      File "/usr/lib/python2.7/dist-packages/tornado/gen.py", line 230, in wrapper
        yielded = next(result)
      File "/usr/lib/python2.7/dist-packages/salt/minion.py", line 495, in eval_master
        pub_channel = salt.transport.client.AsyncPubChannel.factory(self.opts, **factory_kwargs)
      File "/usr/lib/python2.7/dist-packages/salt/transport/client.py", line 154, in factory
        return salt.transport.zeromq.AsyncZeroMQPubChannel(opts, **kwargs)
      File "/usr/lib/python2.7/dist-packages/salt/transport/zeromq.py", line 253, in __init__
        self.auth = salt.crypt.AsyncAuth(self.opts, io_loop=self.io_loop)
      File "/usr/lib/python2.7/dist-packages/salt/crypt.py", line 323, in __new__
        new_auth.__singleton_init__(opts, io_loop=io_loop)
      File "/usr/lib/python2.7/dist-packages/salt/crypt.py", line 361, in __singleton_init__
        self.get_keys()
      File "/usr/lib/python2.7/dist-packages/salt/crypt.py", line 575, in get_keys
        salt.utils.verify.check_path_traversal(self.opts['pki_dir'], user)
      File "/usr/lib/python2.7/dist-packages/salt/utils/verify.py", line 400, in check_path_traversal
        raise SaltClientError(msg)
    SaltClientError: Could not access /etc/salt/pki/minion. Path does not exist.
    Exception ValueError: 'I/O operation on closed file' in <bound method SyncWrapper.__del__ of <salt.utils.async.SyncWrapper object at 0x7f026c0a4990>> ignored
    Exception ValueError: 'I/O operation on closed file' in <bound method SyncWrapper.__del__ of <salt.utils.async.SyncWrapper object at 0x7f026c0a4990>> ignored
    Exception ValueError: 'I/O operation on closed file' in <bound method SyncWrapper.__del__ of <salt.utils.async.SyncWrapper object at 0x7f026c0a4990>> ignored
    Exception ValueError: 'I/O operation on closed file' in <bound method SyncWrapper.__del__ of <salt.utils.async.SyncWrapper object at 0x7f026c0a4990>> ignored
    ...
    

BTW here is the version report:

root@saltmaster:~# salt --versions-report
Salt Version:
           Salt: 2015.8.3

Dependency Versions:
         Jinja2: 2.7.2
       M2Crypto: Not Installed
           Mako: 0.9.1
         PyYAML: 3.10
          PyZMQ: 14.0.1
         Python: 2.7.6 (default, Jun 22 2015, 17:58:13)
           RAET: Not Installed
        Tornado: 4.2.1
            ZMQ: 4.0.4
           cffi: Not Installed
       cherrypy: Not Installed
       dateutil: 1.5
          gitdb: 0.5.4
      gitpython: 0.3.2 RC1
          ioflo: Not Installed
        libnacl: Not Installed
   msgpack-pure: Not Installed
 msgpack-python: 0.3.0
   mysql-python: 1.2.3
      pycparser: Not Installed
       pycrypto: 2.6.1
         pygit2: Not Installed
   python-gnupg: Not Installed
          smmap: 0.8.2
        timelib: Not Installed

System Versions:
           dist: Ubuntu 14.04 trusty
        machine: x86_64
        release: 3.13.0-71-generic
         system: Ubuntu 14.04 trusty

Activity

  1. added
    Packaging
    Regression
    Core
    severity-high
    Platform
    P3
    on Dec 15, 2015
  2. added this to the Approved milestone on Dec 15, 2015
  3. jfindlay commented on Dec 15, 2015

    @jfindlay
    Contributor

    @tonyyang132, thanks for the report. Ping @cachedout, @dmurphy18.

  4. dmurphy18 commented on Dec 15, 2015

    @dmurphy18
    Contributor

    @tonyyang132 this is similar to #27063. Thanks for the information. It shall be rectified in the next release.

  5. tonyyang132 commented on Dec 16, 2015

    @tonyyang132
    Author

    @jfindlay @dmurphy18 Thanks for your update. I'm sure creating relevant directories in the (un)packaging phase would make the issue go away, but I don't know if it would address the issue completely. I understand that without these directories, salt-call would not work properly and certain exceptions would be raised. But what makes the issue horrible is the non-stop complaint ValueError: 'I/O operation on closed file' and finally the exhaustion of system memory. I guess somewhere deep down certain resources are not handled properly.

    I modified the method SyncWrapper.__del__ in /usr/lib/python2.7/dist-packages/salt/utils/async.py a little bit and added a print statement.

    def __del__(self):
        '''
        On deletion of the async wrapper, make sure to clean up the async stuff
        '''
        if hasattr(self, 'async'):
            if hasattr(self.async, 'close'):
                # Certain things such as streams should be closed before
                # their associated io_loop is closed to allow for proper
                # cleanup.
                self.async.close()
            self.io_loop.close()
            # Other things should be deallocated after the io_loop closes.
            # See Issue #26889.
            del self.async
        else:
            print("running self.io_loop.close()")
            self.io_loop.close()
    

    Then I ran salt-call on the master node.

    root@saltmaster:/usr/lib/python2.7/dist-packages/salt/utils# salt-call state.sls tony
    [ERROR   ] Future exception was never retrieved: Traceback (most recent call last):
      File "/usr/lib/python2.7/dist-packages/tornado/gen.py", line 230, in wrapper
        yielded = next(result)
      File "/usr/lib/python2.7/dist-packages/salt/minion.py", line 495, in eval_master
        pub_channel = salt.transport.client.AsyncPubChannel.factory(self.opts, **factory_kwargs)
      File "/usr/lib/python2.7/dist-packages/salt/transport/client.py", line 154, in factory
        return salt.transport.zeromq.AsyncZeroMQPubChannel(opts, **kwargs)
      File "/usr/lib/python2.7/dist-packages/salt/transport/zeromq.py", line 253, in __init__
        self.auth = salt.crypt.AsyncAuth(self.opts, io_loop=self.io_loop)
      File "/usr/lib/python2.7/dist-packages/salt/crypt.py", line 323, in __new__
        new_auth.__singleton_init__(opts, io_loop=io_loop)
      File "/usr/lib/python2.7/dist-packages/salt/crypt.py", line 361, in __singleton_init__
        self.get_keys()
      File "/usr/lib/python2.7/dist-packages/salt/crypt.py", line 575, in get_keys
        salt.utils.verify.check_path_traversal(self.opts['pki_dir'], user)
      File "/usr/lib/python2.7/dist-packages/salt/utils/verify.py", line 400, in check_path_traversal
        raise SaltClientError(msg)
    SaltClientError: Could not access /etc/salt/pki/minion. Path does not exist.
    running self.io_loop.close()
    running self.io_loop.close()
    Exception ValueError: 'I/O operation on closed file' in <bound method SyncWrapper.__del__ of <salt.utils.async.SyncWrapper object at 0x7fadbc0d1990>> ignored
    running self.io_loop.close()
    Exception ValueError: 'I/O operation on closed file' in <bound method SyncWrapper.__del__ of <salt.utils.async.SyncWrapper object at 0x7fadbc0d1990>> ignored
    running self.io_loop.close()
    Exception ValueError: 'I/O operation on closed file' in <bound method SyncWrapper.__del__ of <salt.utils.async.SyncWrapper object at 0x7fadbc0d1990>> ignored
    running self.io_loop.close()
    Exception ValueError: 'I/O operation on closed file' in <bound method SyncWrapper.__del__ of <salt.utils.async.SyncWrapper object at 0x7fadbc0d1990>> ignored
    

    It looks like the first attempt of closing io_loop succeeded. Subsequent such attempts all led to the ValueError: 'I/O operation on closed file' exception. If this is the case, there shouldn't have been these subsequent attempts in the first place.

    The whole theory is just my rough guess and could very well be wrong. I'm just hoping this could provide you with more clues.

  6. tonyyang132 commented on Dec 16, 2015

    @tonyyang132
    Author

    One more question, is there any plan when the next release will roll out?

  7. dmurphy18 commented on Dec 17, 2015

    @dmurphy18
    Contributor

    @tonyyang132 The next release is currently going to be after Christmas (due to holiday period vacations), probably sometime in January.

  8. tonyyang132 commented on Dec 18, 2015

    @tonyyang132
    Author

    @dmurphy18 Thank you for sharing the plan. BTW do you or someone from your team have any comments on my concerns about certain resources not being handled properly? Or was I just being totally paranoid here and those theories were not valid?

  9. dmurphy18 commented on Dec 18, 2015

    @dmurphy18
    Contributor

    @tonyyang132 Nope not paranoid, the issues with pkl directories will be addressed in the next release and then make sure that there are no other issues

  10. self-assigned this
    on Dec 18, 2015
  11. 8 remaining items

  12. added
    fixed-pls-verify
    on Jan 14, 2016
  13. alangarf commented on Jan 21, 2016

    @alangarf
    Contributor

    Any progress on this, this is an embarrassing and annoying bug that doesn't seem to be getting any traction in getting fixed. Late January is surely post Christmas enough. A time frame would be really helpful as this bit bad when we upgraded existing machines without issue, but then a whole stack of autoscaled machines exploded when launched because the pki dir was missing on start up.

  14. dmurphy18 commented on Jan 21, 2016

    @dmurphy18
    Contributor

    @alangarf The changes are ready in packaging, but we are trying to get code tests running clean before we tag the next point release, which is very soon (issue on Arch and another on Ubuntu 15.10). Once the tests are clean, will tag, package and test immediately.

  15. alangarf commented on Jan 21, 2016

    @alangarf
    Contributor

    @dmurphy18 thanks for replying. Although should I be worried that this is appearing to be a fix in the "packaging"? Sure a mkdir in the package build puts a bandaid on the symptom but doesn't address @tonyyang132 comment about what makes the issue horrible is the non-stop complaint ValueError: 'I/O operation on closed file' and finally the exhaustion of system memory. I guess somewhere deep down certain resources are not handled properly.

    In the next release is this a proper fix to the core of the issue or just a packaging change to include the creation of the missing dir?

  16. dmurphy18 commented on Jan 22, 2016

    @dmurphy18
    Contributor

    @alangarf packaging change to include the creation of the missing dir; this is needed (fixes the infinite loop) but not the total fix which requires additional work. The packaging changes are also in conjunction with other issues arising (sorry don't have the numbers to hand).

  17. modified the milestones: B 2, Approved on Feb 17, 2016
  18. removed
    fixed-pls-verify
    on Feb 24, 2016
  19. meggiebot commented on Feb 24, 2016

    @meggiebot

    @DmitryKuzmenko can you look at this when you get back?

  20. DmitryKuzmenko commented on Feb 29, 2016

    @DmitryKuzmenko
    Contributor

    Fixed the io operation error in #31544

  21. added
    fixed-pls-verify
    on Feb 29, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

CoreP2PackagingPlatformRegressionfixed-pls-verifyseverity-high

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions