Comment 2 for bug 1835044

Revision history for this message
Candido Campos Rivas (ccamposr) wrote : Re: [Rocky]Memory leak in privsep-helper(neutron agents)

this script reproduces the leak or part of the leak:

    )[root@controller-0 /]# cat leak3.py
    #!/usr/bin/env python2

    from pyroute2 import netns, NetNS, IPDB, IPRoute
    import time
    import objgraph
    from pyroute2.netlink import rtnl
    from pyroute2.netlink.rtnl import ifinfmsg
    from pyroute2.netlink.rtnl import ndmsg
    import socket

    family = socket.AF_INET

    def get_scope_name(scope):
        """Return the name of the scope (given as a number), or the scope number
        if the name is unknown.

        For backward compatibility (with "ip" tool) "global" scope is converted to
        "universe" before converting to number
        """
        scope = 'universe' if scope == 'global' else scope
        return rtnl.rt_scope.get(scope, scope)

    while True:

        with IPDB() as ipdb:
            ipdb_routes = ipdb.routes
            ipdb_interfaces = ipdb.interfaces
            routes = [{'destination': route['dst'],
                       'nexthop': route.get('gateway'),
                       'device': ipdb_interfaces[route['oif']]['ifname'],
                       'scope': get_scope_name(route['scope'])}
                      for route in ipdb_routes if route['family'] == family]
            print routes
            time.sleep(0.2)
    #With IPDB() as a:
    # a.release()
    # print(objgraph.growth(10))
    # time.sleep(0.2)
    # print("...")

()[root@controller-0 /]# ps -ef | grep leak
root 118083 53454 54 10:08 ? 00:00:02 python leak3.py
root 118895 66070 0 10:09 ? 00:00:00 grep --color=auto leak
()[root@controller-0 /]# while true; do top -p 64897 -n1 -b ; sleep 60 ; done
top - 10:09:35 up 15 days, 16:31, 0 users, load average: 5.81, 5.38, 4.75
Tasks: 0 total, 0 running, 0 sleeping, 0 stopped, 0 zombie
%Cpu(s): 41.7 us, 4.2 sy, 0.0 ni, 52.5 id, 0.0 wa, 0.0 hi, 1.7 si, 0.0 st
KiB Mem : 32779936 total, 644984 free, 15815812 used, 16319140 buff/cache
KiB Swap: 0 total, 0 free, 0 used. 15120388 avail Mem

    PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
^C
()[root@controller-0 /]# while true; do top -p 118083 -n1 -b ; sleep 60 ; done
top - 10:09:56 up 15 days, 16:31, 0 users, load average: 5.55, 5.35, 4.75
Tasks: 1 total, 1 running, 0 sleeping, 0 stopped, 0 zombie
%Cpu(s): 44.5 us, 8.4 sy, 0.0 ni, 45.4 id, 0.0 wa, 0.0 hi, 1.7 si, 0.0 st
KiB Mem : 32779936 total, 606604 free, 15854788 used, 16318544 buff/cache
KiB Swap: 0 total, 0 free, 0 used. 15081184 avail Mem

    PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
 118083 root 20 0 281960 34188 4208 R 106.7 0.1 0:32.64 python
top - 10:10:57 up 15 days, 16:32, 0 users, load average: 6.45, 5.61, 4.88
Tasks: 1 total, 0 running, 1 sleeping, 0 stopped, 0 zombie
%Cpu(s): 47.1 us, 19.3 sy, 0.0 ni, 31.9 id, 0.0 wa, 0.0 hi, 1.7 si, 0.0 st
KiB Mem : 32779936 total, 606032 free, 15858556 used, 16315348 buff/cache
KiB Swap: 0 total, 0 free, 0 used. 15078224 avail Mem

    PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
 118083 root 20 0 285388 38008 4208 S 0.0 0.1 1:07.53 python
top - 10:11:57 up 15 days, 16:33, 0 users, load average: 6.32, 5.71, 4.96
Tasks: 1 total, 1 running, 0 sleeping, 0 stopped, 0 zombie
%Cpu(s): 57.9 us, 9.9 sy, 0.0 ni, 31.4 id, 0.0 wa, 0.0 hi, 0.8 si, 0.0 st
KiB Mem : 32779936 total, 611880 free, 15854576 used, 16313480 buff/cache
KiB Swap: 0 total, 0 free, 0 used. 15082184 avail Mem

    PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
 118083 root 20 0 290056 42260 4208 R 100.0 0.1 1:42.45 python
top - 10:12:57 up 15 days, 16:34, 0 users, load average: 7.35, 6.05, 5.12
Tasks: 1 total, 1 running, 0 sleeping, 0 stopped, 0 zombie
%Cpu(s): 60.8 us, 15.8 sy, 0.0 ni, 22.5 id, 0.0 wa, 0.0 hi, 0.8 si, 0.0 st
KiB Mem : 32779936 total, 599080 free, 15874328 used, 16306528 buff/cache
KiB Swap: 0 total, 0 free, 0 used. 15063332 avail Mem