Skip to content

salt-minion memory leak waiting on master to accept key #32201

Closed

Description

@boltronics

I deployed salt-minion to a bunch of new machines one week ago (before the Easter holidays). When I came back, I noticed that one of my machines was running 656Mb into swap. As it turned out, I forgot to accept the key for that particular minion on the master, which has revealed a salt-minion memory leak.

This is on Jessie AMD64 using the official http://repo.saltstack.com/apt/debian/8/amd64/latest repository.

user@host:~$ cat /proc/463/status
Name:   salt-minion
State:  S (sleeping)
Tgid:   463
Ngid:   0
Pid:    463
PPid:   443
TracerPid:  0
Uid:    0   0   0   0
Gid:    0   0   0   0
FDSize: 64
Groups: 
VmPeak:  2171368 kB
VmSize:  2171364 kB
VmLck:         0 kB
VmPin:         0 kB
VmHWM:   1565592 kB
VmRSS:   1093244 kB
VmData:  2002084 kB
VmStk:       136 kB
VmExe:      3196 kB
VmLib:     14344 kB
VmPTE:      3660 kB
VmSwap:   590524 kB
Threads:    6
SigQ:   1/7825
SigPnd: 0000000000000000
ShdPnd: 0000000000000000
SigBlk: 0000000000000000
SigIgn: 0000000001001000
SigCgt: 0000000180004002
CapInh: 0000000000000000
CapPrm: 0000003fffffffff
CapEff: 0000003fffffffff
CapBnd: 0000003fffffffff
Seccomp:    0
Cpus_allowed:   1
Cpus_allowed_list:  0
Mems_allowed:   00000000,00000001
Mems_allowed_list:  0
voluntary_ctxt_switches:    611226
nonvoluntary_ctxt_switches: 7736
user@host:~$ cat /proc/463/status
Name:   salt-minion
State:  S (sleeping)
Tgid:   463
Ngid:   0
Pid:    463
PPid:   443
TracerPid:  0
Uid:    0   0   0   0
Gid:    0   0   0   0
FDSize: 64
Groups: 
VmPeak:  2171368 kB
VmSize:  2171364 kB
VmLck:         0 kB
VmPin:         0 kB
VmHWM:   1565592 kB
VmRSS:   1093244 kB
VmData:  2002084 kB
VmStk:       136 kB
VmExe:      3196 kB
VmLib:     14344 kB
VmPTE:      3660 kB
VmSwap:   590524 kB
Threads:    6
SigQ:   1/7825
SigPnd: 0000000000000000
ShdPnd: 0000000000000000
SigBlk: 0000000000000000
SigIgn: 0000000001001000
SigCgt: 0000000180004002
CapInh: 0000000000000000
CapPrm: 0000003fffffffff
CapEff: 0000003fffffffff
CapBnd: 0000003fffffffff
Seccomp:    0
Cpus_allowed:   1
Cpus_allowed_list:  0
Mems_allowed:   00000000,00000001
Mems_allowed_list:  0
voluntary_ctxt_switches:    611226
nonvoluntary_ctxt_switches: 7736
user@host:~$ apt-cache policy salt-minion
salt-minion:
  Installed: 2015.8.7+ds-1
  Candidate: 2015.8.7+ds-1
  Version table:
 *** 2015.8.7+ds-1 0
        100 /var/lib/dpkg/status
     2014.1.13+ds-3 0
        500 http://apt-cacher-ng.domain:3142/debian/ jessie/main amd64 Packages
user@host:~$ free -m -t
             total       used       free     shared    buffers     cached
Mem:          2002       1943         59         15         18        214
-/+ buffers/cache:       1710        291
Swap:         1023        656        367
Total:        3026       2599        426
user@host:~$

Steps to Reproduce Issue

On the minion:
$ sudo apt-get install salt-minion

From the logs:
2016-03-29 11:23:29,816 [salt.crypt ][ERROR ][463] The Salt Master has cached the public key for this node, this salt minion will wait for 10 seconds before attempting to re-authenticate (repeated over and over).

Versions Report

user@host:~$ sudo salt-call --versions-report
Salt Version:
           Salt: 2015.8.7

Dependency Versions:
         Jinja2: 2.7.3
       M2Crypto: Not Installed
           Mako: Not Installed
         PyYAML: 3.11
          PyZMQ: 14.4.0
         Python: 2.7.9 (default, Mar  1 2015, 12:57:24)
           RAET: Not Installed
        Tornado: 4.2.1
            ZMQ: 4.0.5
           cffi: 0.8.6
       cherrypy: Not Installed
       dateutil: 2.2
          gitdb: Not Installed
      gitpython: Not Installed
          ioflo: Not Installed
        libgit2: Not Installed
        libnacl: Not Installed
   msgpack-pure: Not Installed
 msgpack-python: 0.4.2
   mysql-python: 1.2.3
      pycparser: 2.10
       pycrypto: 2.6.1
         pygit2: Not Installed
   python-gnupg: Not Installed
          smmap: Not Installed
        timelib: Not Installed

System Versions:
           dist: debian 8.3 
        machine: x86_64
        release: 3.16.0-4-amd64
         system: debian 8.3 

user@host:~$

The salt-master is basically identical:

user@host:~$ sudo salt --versions-report
Salt Version:
           Salt: 2015.8.7

Dependency Versions:
         Jinja2: 2.7.3
       M2Crypto: Not Installed
           Mako: Not Installed
         PyYAML: 3.11
          PyZMQ: 14.4.0
         Python: 2.7.9 (default, Mar  1 2015, 12:57:24)
           RAET: Not Installed
        Tornado: 4.2.1
            ZMQ: 4.0.5
           cffi: 0.8.6
       cherrypy: Not Installed
       dateutil: 2.2
          gitdb: 0.5.4
      gitpython: 0.3.2 RC1
          ioflo: Not Installed
        libgit2: Not Installed
        libnacl: Not Installed
   msgpack-pure: Not Installed
 msgpack-python: 0.4.2
   mysql-python: 1.2.3
      pycparser: 2.10
       pycrypto: 2.6.1
         pygit2: Not Installed
   python-gnupg: Not Installed
          smmap: 0.8.2
        timelib: Not Installed

System Versions:
           dist: debian 8.3 
        machine: x86_64
        release: 3.16.0-4-amd64
         system: debian 8.3 

user@host:~$ 

There is a new salt-minion version that has since been pushed to the repo (2015.8.8). However running watch 'ps auxf | grep [s]alt-minion' after upgrading shows the RSS memory value is still climbing, suggesting this is still a problem.

Activity

  1. changed the title [-]Salt minion memory leak while waiting on the master to accept the key[/-] [+]salt-minion memory leak waiting on master to accept key[/+] on Mar 29, 2016
  2. added
    bug
    Core
    severity-high
    P3
    on Mar 29, 2016
  3. added this to the Approved milestone on Mar 29, 2016
  4. jfindlay commented on Mar 29, 2016

    @jfindlay
    Contributor

    @boltronics, thanks for the report.

  5. cachedout commented on Apr 5, 2016

    @cachedout
    Contributor

    I think the problem here was that we were holding open ZeroMQ contexts because we were just stacking up TCP connections instead of re-using them. I have modified our authentication routines to pass in a single reference to a channel instead of creating them each time. Under a typical scenario, the channel would be re-used because it could be looked up in the singleton map, but this failed because we lost the reference to the channel each time through the sign-in loop, which wiped out the weak key dictionary class attribute on the asyncreqchannel.

    I will submit a PR as soon as Github comes back online. :]

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    CoreP3bugfixed-pls-verifyseverity-high

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions