From 8e3886a8ae5c292d0c0ac8245f72ec55ef27bf6c Mon Sep 17 00:00:00 2001 From: Laurent Bonnans Date: Mon, 11 Mar 2019 17:39:57 +0100 Subject: Add aktualizr-resource-control For controlling systemd cgroups configuration of the aktualizr daemon Signed-off-by: Laurent Bonnans --- recipes-sota/aktualizr/aktualizr_git.bb | 26 +++++++++++++++++++++- .../aktualizr/files/10-resource-control.conf | 6 +++++ 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 recipes-sota/aktualizr/files/10-resource-control.conf diff --git a/recipes-sota/aktualizr/aktualizr_git.bb b/recipes-sota/aktualizr/aktualizr_git.bb index 49c4e5e..f2f62b5 100755 --- a/recipes-sota/aktualizr/aktualizr_git.bb +++ b/recipes-sota/aktualizr/aktualizr_git.bb @@ -25,6 +25,7 @@ SRC_URI = " \ file://aktualizr-secondary.service \ file://aktualizr-secondary.socket \ file://aktualizr-serialcan.service \ + file://10-resource-control.conf \ ${@ d.expand("https://ats-tuf-cli-releases.s3-eu-central-1.amazonaws.com/cli-${GARAGE_SIGN_PV}.tgz;unpack=0") if d.getVar('GARAGE_SIGN_AUTOVERSION') != '1' else ''} \ " @@ -62,6 +63,15 @@ PACKAGECONFIG[load-tests] = "-DBUILD_LOAD_TESTS=ON,-DBUILD_LOAD_TESTS=OFF," PACKAGECONFIG[serialcan] = ",,,slcand-start" PACKAGECONFIG[ubootenv] = ",,,u-boot-fw-utils aktualizr-uboot-env-rollback" +# can be overriden in configuration with `RESOURCE_xxx_pn-aktualizr` +# see `man systemd.resource-control` for details + +# can be used to lower aktualizr priority, default is 100 +RESOURCE_CPU_WEIGHT = "100" +# will be slowed down when it reaches 'high', killed when it reaches 'max' +RESOURCE_MEMORY_HIGH = "100M" +RESOURCE_MEMORY_MAX = "80%" + do_compile_ptest() { cmake_runcmake_build --target build_tests } @@ -118,6 +128,15 @@ do_install_append () { install -m 0755 ${B}/src/sota_tools/garage-sign/bin/* ${D}${bindir} install -m 0644 ${B}/src/sota_tools/garage-sign/lib/* ${D}${libdir} fi + + # resource control + install -d ${D}/${systemd_system_unitdir}/aktualizr.service.d + install -m 0644 ${WORKDIR}/10-resource-control.conf ${D}/${systemd_system_unitdir}/aktualizr.service.d + + sed -i -e 's|@CPU_WEIGHT@|${RESOURCE_CPU_WEIGHT}|g' \ + -e 's|@MEMORY_HIGH@|${RESOURCE_MEMORY_HIGH}|g' \ + -e 's|@MEMORY_MAX@|${RESOURCE_MEMORY_MAX}|g' \ + ${D}${systemd_system_unitdir}/aktualizr.service.d/10-resource-control.conf } PACKAGESPLITFUNCS_prepend = "split_hosttools_packages " @@ -132,7 +151,7 @@ python split_hosttools_packages () { PACKAGES_DYNAMIC = "^aktualizr-.* ^garage-.*" -PACKAGES =+ "${PN}-examples ${PN}-secondary ${PN}-configs ${PN}-host-tools" +PACKAGES =+ "${PN}-resource-control ${PN}-examples ${PN}-secondary ${PN}-configs ${PN}-host-tools" ALLOW_EMPTY_${PN}-host-tools = "1" @@ -142,6 +161,10 @@ FILES_${PN} = " \ ${systemd_unitdir}/system/aktualizr.service \ " +FILES_${PN}-resource-control = " \ + ${systemd_system_unitdir}/aktualizr.service.d/10-resource-control.conf \ + " + FILES_${PN}-configs = " \ ${sysconfdir}/sota/* \ ${libdir}/sota/* \ @@ -157,6 +180,7 @@ FILES_${PN}-secondary = " \ ${systemd_unitdir}/system/aktualizr-secondary.socket \ ${systemd_unitdir}/system/aktualizr-secondary.service \ " + BBCLASSEXTEND = "native" # vim:set ts=4 sw=4 sts=4 expandtab: diff --git a/recipes-sota/aktualizr/files/10-resource-control.conf b/recipes-sota/aktualizr/files/10-resource-control.conf new file mode 100644 index 0000000..254713c --- /dev/null +++ b/recipes-sota/aktualizr/files/10-resource-control.conf @@ -0,0 +1,6 @@ +[Service] +CPUAccounting=true +CPUWeight=@CPU_WEIGHT@ +MemoryAccounting=true +MemoryHigh=@MEMORY_HIGH@ +MemoryMax=@MEMORY_MAX@ -- cgit v1.2.3-54-g00ecf