Re: [systemd-devel] Restart=on-failure and SuccessAction=reboot-force causing reboots on every exit of Main PID

2022-02-17 Thread Michał Rudowicz
Hi,

The minimal file with which I was able to reproduce the issue is:

[Unit]
Description="Example"
SuccessAction=reboot-force

[Service]
Type=simple
ExecStart=/bin/false
Restart=on-failure

I can reproduce it both on my buildroot system with systemd 247 and fresh
Fedora 35 minimal install with v249.9-1.fc35 .

After commenting out "Restart=on-failure" the reboots are not happening,
and the service is "failed" as expected.
Commenting out "SuccessAction=reboot-force" but leaving "Restart=on-failure"
not commented causes the service to restart without a system reboot, as
expected.

Michał


Re: [systemd-devel] Restart=on-failure and SuccessAction=reboot-force causing reboots on every exit of Main PID

2022-02-16 Thread Lennart Poettering
On Mi, 16.02.22 11:45, Michał Rudowicz (michal.rudow...@fl9.eu) wrote:

> Hi,
>
> I am trying to write a .service file for an application which is supposed to
> run indefinitely. The approach I have is:
>
>  - if the application crashes (exits with a non-zero exit code), I want
>it to be restarted. This can be achieved easily using the Restart
>directive, like Restart=on-failure in the [Service] section.

>  - if the application exits cleanly (with a zero exit code), I want the
>whole device to reboot (eg. because a software update was done). I've
>found the SuccessAction directive, which - after being set to reboot or
>reboot-force in the [Unit] section - seems to do what I want.
>
> The issue I have is: when I use both SuccessAction=reboot-force and
> Restart=on-failure in one .service file, the system reboots when I kill
> the Main PID of the service (causing non-clean exit for testing).

Can you provide a minimal .service file that shows the issue? Smells
like a bug. SuccessAction= should not be triggred if a service process
exits with SIGKILL...

Lennart

--
Lennart Poettering, Berlin


[systemd-devel] Restart=on-failure and SuccessAction=reboot-force causing reboots on every exit of Main PID

2022-02-16 Thread Michał Rudowicz
Hi,

I am trying to write a .service file for an application which is supposed to
run indefinitely. The approach I have is:

 - if the application crashes (exits with a non-zero exit code), I want
   it to be restarted. This can be achieved easily using the Restart
   directive, like Restart=on-failure in the [Service] section.
 - if the application exits cleanly (with a zero exit code), I want the
   whole device to reboot (eg. because a software update was done). I've
   found the SuccessAction directive, which - after being set to reboot or
   reboot-force in the [Unit] section - seems to do what I want.

The issue I have is: when I use both SuccessAction=reboot-force and
Restart=on-failure in one .service file, the system reboots when I kill
the Main PID of the service (causing non-clean exit for testing).

If I comment out the Restart=on-failure line from the .service file, then
after kill -9 of the Main PID of the service it stays failed as expected.
No reboot is happening.
But if I uncomment that line, then the same kill -9 causes a reboot.

Is this the expected behavior?

If yes, then how should I approach this issue? What would be the preferred
way of setting up the .service file to achieve what I have described?

I am using systemd-stable 247.3 from Buildroot. I've looked through the
changelogs on github for systemd, but didn't find anything that seemed
related - did I miss something?

Thanks in advance,
Michał