Skip to content

Commit

Permalink
Systemd processes not being moved to cpuset/systemd.slice fix
Browse files Browse the repository at this point in the history
The script cpuset-configure.sh is responsible to move the
systemd processes to the cpuset/systemd.slice cgroup and  is executed
in a form of a service (cpuset-configure.service).

In the current implementation, the script is executed too early - some
system processes are yet to be created.
This in turn leads to them not being moved to the custom system slice.

Moreover, in the current implementation, the script is executed before
the network-online.target. The intention was to execute the script before
kubelet and crio services are initialized, by the fact network-online.target
is a common parent.

The fix I'm proposing consist of the following changes:
1. Adding an After statements - The script will start once the late starting
processes as NetworkManager, sshd, etc... are started.
Thereby we can ensure processes as such do not fall between the cracks.
2. Narrowing down the Before statement to a more accurate
one, reflecting its original intention.

Signed-off-by: Ronny Baturov <rbaturov@redhat.com>
  • Loading branch information
rbaturov committed Mar 17, 2024
1 parent eb35a4e commit a04faf5
Show file tree
Hide file tree
Showing 11 changed files with 90 additions and 18 deletions.
Expand Up @@ -80,6 +80,7 @@ const (
systemdSectionInstall = "Install"
systemdDescription = "Description"
systemdBefore = "Before"
systemdAfter = "After"
systemdEnvironment = "Environment"
systemdType = "Type"
systemdRemainAfterExit = "RemainAfterExit"
Expand All @@ -88,13 +89,17 @@ const (
)

const (
systemdServiceIRQBalance = "irqbalance.service"
systemdServiceKubelet = "kubelet.service"
systemdServiceCrio = "crio.service"
systemdServiceTypeOneshot = "oneshot"
systemdTargetMultiUser = "multi-user.target"
systemdTargetNetworkOnline = "network-online.target"
systemdTrue = "true"
systemdServiceIRQBalance = "irqbalance.service"
systemdServiceKubelet = "kubelet.service"
systemdServiceCrio = "crio.service"
systemdServiceTypeOneshot = "oneshot"
systemdTargetMultiUser = "multi-user.target"
systemdTrue = "true"
systemdServiceNetworkManager = "NetworkManager.service"
systemdServiceSSHD = "sshd.service"
systemdServiceDnsmasq = "dnsmasq.service"
systemdServiceDbusBroker = "dbus-broker.service"
systemdServiceGetty = "getty@tty1.service.service"
)

const (
Expand Down Expand Up @@ -451,7 +456,14 @@ func getCpusetConfigureServiceOptions() []*unit.UnitOption {
// Description
unit.NewUnitOption(systemdSectionUnit, systemdDescription, "Move services to reserved cpuset"),
// Before
unit.NewUnitOption(systemdSectionUnit, systemdBefore, systemdTargetNetworkOnline),
unit.NewUnitOption(systemdSectionUnit, systemdBefore, systemdServiceKubelet),
unit.NewUnitOption(systemdSectionUnit, systemdBefore, systemdServiceCrio),
// After
unit.NewUnitOption(systemdSectionUnit, systemdAfter, systemdServiceNetworkManager),
unit.NewUnitOption(systemdSectionUnit, systemdAfter, systemdServiceSSHD),
unit.NewUnitOption(systemdSectionUnit, systemdAfter, systemdServiceDnsmasq),
unit.NewUnitOption(systemdSectionUnit, systemdAfter, systemdServiceDbusBroker),
unit.NewUnitOption(systemdSectionUnit, systemdAfter, systemdServiceGetty),
// Type
unit.NewUnitOption(systemdSectionService, systemdType, systemdServiceTypeOneshot),
// ExecStart
Expand Down
Expand Up @@ -139,7 +139,13 @@ spec:
- contents: |
[Unit]
Description=Move services to reserved cpuset
Before=network-online.target
Before=kubelet.service
Before=crio.service
After=NetworkManager.service
After=sshd.service
After=dnsmasq.service
After=dbus-broker.service
After=getty@tty1.service.service
[Service]
Type=oneshot
Expand Down
Expand Up @@ -139,7 +139,13 @@ spec:
- contents: |
[Unit]
Description=Move services to reserved cpuset
Before=network-online.target
Before=kubelet.service
Before=crio.service
After=NetworkManager.service
After=sshd.service
After=dnsmasq.service
After=dbus-broker.service
After=getty@tty1.service.service
[Service]
Type=oneshot
Expand Down
Expand Up @@ -139,7 +139,13 @@ spec:
- contents: |
[Unit]
Description=Move services to reserved cpuset
Before=network-online.target
Before=kubelet.service
Before=crio.service
After=NetworkManager.service
After=sshd.service
After=dnsmasq.service
After=dbus-broker.service
After=getty@tty1.service.service
[Service]
Type=oneshot
Expand Down
Expand Up @@ -139,7 +139,13 @@ spec:
- contents: |
[Unit]
Description=Move services to reserved cpuset
Before=network-online.target
Before=kubelet.service
Before=crio.service
After=NetworkManager.service
After=sshd.service
After=dnsmasq.service
After=dbus-broker.service
After=getty@tty1.service.service
[Service]
Type=oneshot
Expand Down
Expand Up @@ -139,7 +139,13 @@ spec:
- contents: |
[Unit]
Description=Move services to reserved cpuset
Before=network-online.target
Before=kubelet.service
Before=crio.service
After=NetworkManager.service
After=sshd.service
After=dnsmasq.service
After=dbus-broker.service
After=getty@tty1.service.service
[Service]
Type=oneshot
Expand Down
Expand Up @@ -139,7 +139,13 @@ spec:
- contents: |
[Unit]
Description=Move services to reserved cpuset
Before=network-online.target
Before=kubelet.service
Before=crio.service
After=NetworkManager.service
After=sshd.service
After=dnsmasq.service
After=dbus-broker.service
After=getty@tty1.service.service
[Service]
Type=oneshot
Expand Down
Expand Up @@ -141,7 +141,13 @@ spec:
- contents: |
[Unit]
Description=Move services to reserved cpuset
Before=network-online.target
Before=kubelet.service
Before=crio.service
After=NetworkManager.service
After=sshd.service
After=dnsmasq.service
After=dbus-broker.service
After=getty@tty1.service.service
[Service]
Type=oneshot
Expand Down
Expand Up @@ -142,7 +142,13 @@ spec:
- contents: |
[Unit]
Description=Move services to reserved cpuset
Before=network-online.target
Before=kubelet.service
Before=crio.service
After=NetworkManager.service
After=sshd.service
After=dnsmasq.service
After=dbus-broker.service
After=getty@tty1.service.service
[Service]
Type=oneshot
Expand Down
Expand Up @@ -146,7 +146,13 @@ spec:
- contents: |
[Unit]
Description=Move services to reserved cpuset
Before=network-online.target
Before=kubelet.service
Before=crio.service
After=NetworkManager.service
After=sshd.service
After=dnsmasq.service
After=dbus-broker.service
After=getty@tty1.service.service
[Service]
Type=oneshot
Expand Down
Expand Up @@ -141,7 +141,13 @@ spec:
- contents: |
[Unit]
Description=Move services to reserved cpuset
Before=network-online.target
Before=kubelet.service
Before=crio.service
After=NetworkManager.service
After=sshd.service
After=dnsmasq.service
After=dbus-broker.service
After=getty@tty1.service.service
[Service]
Type=oneshot
Expand Down

0 comments on commit a04faf5

Please sign in to comment.