From: Tobias Brunner Date: Tue, 27 Jun 2023 16:45:53 +0000 (+0200) Subject: testing: Fix vici updown script on Debian bookworm X-Git-Tag: android-2.4.2~22^2~11 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=995d7785b945990573e0054411a418ff5251fdee;p=thirdparty%2Fstrongswan.git testing: Fix vici updown script on Debian bookworm OOM-killer is now already triggered with `import daemon`, so set the limit before that. Also some PEP8 fixes (including an exclusion for the above fix as that causes imports to not be at the beginning of the file). --- diff --git a/testing/tests/route-based/net2net-xfrmi-ike/hosts/sun/etc/updown.py b/testing/tests/route-based/net2net-xfrmi-ike/hosts/sun/etc/updown.py index 4abc1aa548..813a3e1ac0 100755 --- a/testing/tests/route-based/net2net-xfrmi-ike/hosts/sun/etc/updown.py +++ b/testing/tests/route-based/net2net-xfrmi-ike/hosts/sun/etc/updown.py @@ -2,11 +2,18 @@ import sys import vici -import daemon import logging from logging.handlers import SysLogHandler import subprocess + +# the hard limit (second number) is the value used by python-daemon when closing +# potentially open file descriptors while daemonizing or even triggered by the +# import. since the default limit is 524288 on newer systems, this can take +# quite a while, and due to how this range of FDs is handled internally (as set) +# it can even trigger the OOM killer import resource +resource.setrlimit(resource.RLIMIT_NOFILE, (256, 256)) # noqa +import daemon logger = logging.getLogger('updownLogger') @@ -59,13 +66,6 @@ def install_routes(ike_sa): subprocess.call(["ip", "route", "add", ts, "dev", ifname_out]) -# the hard limit (second number) is the value used by python-daemon when closing -# potentially open file descriptors while daemonizing. since the default is -# 524288 on newer systems, this can take quite a while, and due to how this -# range of FDs is handled internally (as set) it can even trigger the OOM killer -resource.setrlimit(resource.RLIMIT_NOFILE, (256, 256)) - - # daemonize and run parallel to the IKE daemon with daemon.DaemonContext(): setup_logger() @@ -75,7 +75,7 @@ with daemon.DaemonContext(): ver = {k: v.decode("UTF-8") for k, v in session.version().items()} logger.info("connected to {daemon} {version} ({sysname}, {release}, " "{machine})".format(**ver)) - except: + except BaseException: logger.error("failed to get status via vici") sys.exit(1) @@ -95,6 +95,6 @@ with daemon.DaemonContext(): except IOError: logger.error("daemon disconnected") - except: + except BaseException as e: logger.error("exception while listening for events " + - repr(sys.exc_info()[1])) + repr(e))