Uploaded image for project: 'RHEL'
  1. RHEL
  2. RHEL-2484

[RFE] use cgroup-v2 hierarchy to set memory limits for insights-client.service

Linking RHIVOS CVEs to...Migration: Automation ...Sync from "Extern...XMLWordPrintable

    • None
    • subs-client-tools
    • 0
    • False
    • False
    • Hide

      None

      Show
      None
    • None
    • None
    • None
    • None
    • If docs needed, set a value
    • None
    • 57,005

      On the RHEL9 Edge VM with `insights-client-3.1.7-6.el9_0.noarch` installed, the `insights-client.service` is trying to set memory limits in the ExecStartPost of the service using the cgroup-v1 hierarchy.

      ```
      $ sudo systemctl cat insights-client.service

      1. /usr/lib/systemd/system/insights-client.service
      2. This file is part of insights-client.
        #
      3. Any changes made to this file will be overwritten during a software update. To
      4. override a parameter in this file, create a drop-in file, typically located at
      5. /etc/systemd/system/insights-client.service.d/override.conf. Put the desired
      6. overrides in that file and reload systemd. The next time this service is run
      7. (either manually or via a systemd timer), the overridden values will be in
      8. effect.
        #
      9. For more information about systemd drop-in files, see systemd.unit(5).

      [Unit]
      Description=Insights Client
      Documentation=man:insights-client(8)
      After=network.target

      [Service]
      Type=simple
      ExecStart=/usr/bin/insights-client --retry 3
      Restart=no
      WatchdogSec=900
      CPUQuota=30%
      MemoryLimit=2G
      TasksMax=300
      BlockIOWeight=100
      ExecStartPost=-/bin/bash -c "echo 2G >/dev/null 2>&1 > /sys/fs/cgroup/memory/system.slice/insights-client.service/memory.memsw.limit_in_bytes"
      ExecStartPost=-/bin/bash -c "echo 1G >/dev/null 2>&1 > /sys/fs/cgroup/memory/system.slice/insights-client.service/memory.soft_limit_in_bytes"
      ```

      Since RHEL 9 is mounting the cgroup-v2 hierarchy by default, these commands in the ExecStartPost fields will always fail.

      Unfortunately, I am not a cgroup-v2 expert, but I believe that changing the unit file to use the systemd memory options for cgroup-v2 would be the right path forward.

      See: https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/managing_monitoring_and_updating_the_kernel/assembly_configuring-resource-management-using-systemd_managing-monitoring-and-updating-the-kernel#ref_memory-allocation-configuration-options-with-systemd_assembly_configuring-resource-management-using-systemd_managing-monitoring-and-updating-the-kernel

      My proposal:

      ```
      $ sudo systemctl cat insights-client.service

      1. /usr/lib/systemd/system/insights-client.service
      2. This file is part of insights-client.
        #
      3. Any changes made to this file will be overwritten during a software update. To
      4. override a parameter in this file, create a drop-in file, typically located at
      5. /etc/systemd/system/insights-client.service.d/override.conf. Put the desired
      6. overrides in that file and reload systemd. The next time this service is run
      7. (either manually or via a systemd timer), the overridden values will be in
      8. effect.
        #
      9. For more information about systemd drop-in files, see systemd.unit(5).

      [Unit]
      Description=Insights Client
      Documentation=man:insights-client(8)
      After=network.target

      [Service]
      Type=simple
      ExecStart=/usr/bin/insights-client --retry 3
      Restart=no
      WatchdogSec=900
      CPUQuota=30%
      MemoryLimit=1G
      MemorySwapMax=2G
      TasksMax=300
      BlockIOWeight=100
      ```

      This does the following:

      • removes the ExecStartPost entries
      • reduces MemoryLimit to 1G to match the value of `memory.soft_limit_in_bytes` from the removed ExecStartPost command
      • adds MemorySwapMax=2G to match the value of `memory.memsw.limit_in_bytes` from the removed ExecStartPost command

      I'm not certain that MemoryLimit and MemorySwapMax are direct replacements for the cgroup=-v1 options, but it was the best guess that I made after consulting the Memory Resource Controller docs - https://www.kernel.org/doc/html/latest/admin-guide/cgroup-v1/memory.html#benefits-and-purpose-of-the-memory-controller

      NOTE: this change would only be applicable for RHEL9 as RHEL8 still mounts cgroup-v1 by default

              jira-bugzilla-migration RH Bugzilla Integration
              miabbott@redhat.com Micah Abbott
              RH Bugzilla Integration RH Bugzilla Integration
              RH Bugzilla Integration RH Bugzilla Integration
              Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

                Created:
                Updated:
                Resolved: