DietPi icon indicating copy to clipboard operation
DietPi copied to clipboard

Cannot apply preset priority to docker service

Open scetu opened this issue 3 years ago • 4 comments

Creating a bug report/issue

Required Information

  • DietPi version | cat /boot/dietpi/.version
G_DIETPI_VERSION_CORE=8
G_DIETPI_VERSION_SUB=7
G_DIETPI_VERSION_RC=1
G_GITBRANCH='master'
G_GITOWNER='MichaIng'
G_LIVE_PATCH_STATUS[0]='not applicable'
  • Distro version | echo $G_DISTRO_NAME $G_RASPBIAN bullseye
  • Kernel version | uname -a Linux odroid 5.10.123-meson64 #22.05.3 SMP PREEMPT Wed Jun 22 07:23:04 UTC 2022 aarch64 GNU/Linux
  • SBC model | echo $G_HW_MODEL_NAME or (EG: RPi3) Odroid N2 (aarch64)
  • Power supply used | (EG: 5V 1A RAVpower) 12V A2
  • SD card used | (EG: SanDisk ultra) EEMC 64GB

Additional Information (if applicable)

  • Software title | (EG: Nextcloud) Docker
  • Was the software title installed freshly or updated/migrated? freshly installed today
  • Can this issue be replicated on a fresh installation of DietPi? Most probably yes
  • Bug report ID | echo $G_HW_UUID

Steps to reproduce

  1. Install Docker from dietpi-software
  2. Go to dietpi-services and try to apply predefined Highest priority
  3. image
  4. After service restart services fails to load image

Expected behaviour

  • Service should eb started and preset applied

Actual behaviour

  • described in "Steps to reproduce"

Extra details

  • This preset is working on RPi 4B, but not on Odroid N2+
  • High Priority preset works and service can start
  • There were other minor errors which I saw today on Odroid N2+ for the first time after getting it in addition to my Raspberry Pis, also related to Docker, so maybe it is upstream error

scetu avatar Aug 19 '22 19:08 scetu

Can you reboot your system and share following

journalctl -u docker. Service

Joulinar avatar Aug 20 '22 06:08 Joulinar

Highest priority image

after reboot...

root@odroid:~# journalctl -u docker
-- Journal begins at Sat 2022-08-20 15:12:30 CEST, ends at Sat 2022-08-20 15:13:02 CEST. --
Aug 20 15:12:38 odroid systemd[2087]: docker.service: Failed to set up CPU scheduling: Operation not permitted
Aug 20 15:12:38 odroid systemd[1]: Started Docker Application Container Engine.
Aug 20 15:12:38 odroid systemd[2087]: docker.service: Failed at step SETSCHEDULER spawning /usr/bin/dockerd: Operation not permitted
Aug 20 15:12:38 odroid systemd[1]: docker.service: Main process exited, code=exited, status=214/SETSCHEDULER
Aug 20 15:12:38 odroid systemd[1]: docker.service: Failed with result 'exit-code'.
Aug 20 15:12:40 odroid systemd[1]: docker.service: Scheduled restart job, restart counter is at 1.
Aug 20 15:12:40 odroid systemd[1]: Stopped Docker Application Container Engine.
Aug 20 15:12:40 odroid systemd[2108]: docker.service: Failed to set up CPU scheduling: Operation not permitted
Aug 20 15:12:40 odroid systemd[2108]: docker.service: Failed at step SETSCHEDULER spawning /usr/bin/dockerd: Operation not permitted
Aug 20 15:12:40 odroid systemd[1]: Started Docker Application Container Engine.
Aug 20 15:12:40 odroid systemd[1]: docker.service: Main process exited, code=exited, status=214/SETSCHEDULER
Aug 20 15:12:40 odroid systemd[1]: docker.service: Failed with result 'exit-code'.
Aug 20 15:12:42 odroid systemd[1]: docker.service: Scheduled restart job, restart counter is at 2.
Aug 20 15:12:42 odroid systemd[1]: Stopped Docker Application Container Engine.
Aug 20 15:12:42 odroid systemd[2111]: docker.service: Failed to set up CPU scheduling: Operation not permitted
Aug 20 15:12:42 odroid systemd[2111]: docker.service: Failed at step SETSCHEDULER spawning /usr/bin/dockerd: Operation not permitted
Aug 20 15:12:42 odroid systemd[1]: Started Docker Application Container Engine.
Aug 20 15:12:42 odroid systemd[1]: docker.service: Main process exited, code=exited, status=214/SETSCHEDULER
Aug 20 15:12:42 odroid systemd[1]: docker.service: Failed with result 'exit-code'.
Aug 20 15:12:44 odroid systemd[1]: docker.service: Scheduled restart job, restart counter is at 3.
Aug 20 15:12:44 odroid systemd[1]: Stopped Docker Application Container Engine.
Aug 20 15:12:44 odroid systemd[1]: docker.service: Start request repeated too quickly.
Aug 20 15:12:44 odroid systemd[1]: docker.service: Failed with result 'exit-code'.
Aug 20 15:12:44 odroid systemd[1]: Failed to start Docker Application Container Engine.

High priority image

Aug 20 15:15:58 odroid systemd[1]: Started Docker Application Container Engine.

scetu avatar Aug 20 '22 13:08 scetu

looks like Docker don't like to have CPU scheduling set

Aug 20 15:12:42 odroid systemd[2111]: docker.service: Failed to set up CPU scheduling: Operation not permitted
Aug 20 15:12:42 odroid systemd[2111]: docker.service: Failed at step SETSCHEDULER spawning /usr/bin/dockerd: Operation not permitted

Joulinar avatar Aug 20 '22 13:08 Joulinar

I guess it's the CPU scheduling class which is the issue. And to be true, giving the whole Docker engine realtime is probably dangerous, as there are a lot of low priority processes included, the engine itself and the wrapping container system services, like probably logging as such things.

However, it seems to be a kernel flag which causes this in combination with systemd: https://stackoverflow.com/questions/34018956/sched-setscheduler-error-eperm-after-installing-libpam-systemd

We need to replicate this is a simple dummy service.

MichaIng avatar Aug 22 '22 19:08 MichaIng

While it is not what I'd recommend, I just tested the highest possible CPU and I/O classes and priorities (as well as the "Highest Priority" preset) on Docker on VM and there it works without issues:

root@VM-Bullseye:~# cat /etc/systemd/system/docker.service.d/dietpi-process_tool.conf
# WARNING: Do not manually edit this file, use "dietpi-services" to adjust values!
[Service]
CPUSchedulingPolicy=fifo
CPUSchedulingPriority=99
IOSchedulingClass=realtime
IOSchedulingPriority=0
...
root@VM-Bullseye:~# cat /etc/systemd/system/docker.service.d/dietpi-process_tool.conf
# WARNING: Do not manually edit this file, use "dietpi-services" to adjust values!
[Service]
CPUSchedulingPolicy=fifo
IOSchedulingClass=realtime
CPUSchedulingPriority=50

Probably a limitation of the Odroid N2 kernel? Needs further testing.

MichaIng avatar Sep 18 '22 14:09 MichaIng

Unfortunately, I have only one Odroid N2 and it is already in production use with "High priority" preset applied. Maybe somebody else could help with testing of these tweaks.

scetu avatar Sep 19 '22 13:09 scetu

Verified: FIFO and Round Robin are both generally not permitted on Odroid N2 for whatever reason. On x86_64 VMs and Raspberry Pi it works without issues:

root@OdroidN2:~# chrt -f --pid 1 5094
chrt: failed to set pid 5094's policy: Operation not permitted
root@OdroidN2:~# chrt -r --pid 1 5094
chrt: failed to set pid 5094's policy: Operation not permitted
root@OdroidN2:~# chrt -o --pid 0 5094
root@OdroidN2:~#

Must be a kernel limitation. I'll test this on some other SBCs tomorrow.

MichaIng avatar Jan 14 '23 20:01 MichaIng