Bug 2132374

Summary: Timer fails due to Service unit not meeting conditions
Product: Red Hat Enterprise Linux 8 Reporter: Renaud Métrich <rmetrich>
Component: systemdAssignee: systemd-maint
Status: CLOSED DUPLICATE QA Contact: Frantisek Sumsal <fsumsal>
Severity: low Docs Contact:
Priority: low    
Version: 8.6CC: dtardon, systemd-maint-list
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-10-05 14:01:03 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Renaud Métrich 2022-10-05 12:54:08 UTC
Description of problem:

Assuming we want to use timers in replacement to cron, I would expect that a timer that elapses but doesn't start the service unit because some condition is not met wouldn't enter "failed" state:
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
# systemctl status my-timer.timer
● my-timer.timer
   Loaded: loaded (/etc/systemd/system/my-timer.timer; static; vendor preset: disabled)
   Active: failed (Result: unit-condition-failed) since Wed 2022-10-05 14:44:00 CEST; 1min 5s ago
  Trigger: n/a

Oct 05 14:42:53 vm-rhel8 systemd[1]: Started my-timer.timer.
Oct 05 14:44:00 vm-rhel8 systemd[1]: my-timer.timer: Failed with result 'unit-condition-failed'.

# systemctl status my-timer.service
● my-timer.service
   Loaded: loaded (/etc/systemd/system/my-timer.service; static; vendor preset: disabled)
   Active: inactive (dead)
Condition: start condition failed at Wed 2022-10-05 14:43:01 CEST; 2min 20s ago
           └─ ConditionPathExists=/var/run/my-timer was not met
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------

Such behavior prevents running a service regularly.

Version-Release number of selected component (if applicable):

systemd-239-58.el8_6.7.x86_64

How reproducible:

Always

Steps to Reproduce:
1. Create a dummy timer and service triggered on a non-met condition

-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
# systemctl cat my-timer.timer my-timer.service
# /etc/systemd/system/my-timer.timer
[Timer]
OnCalendar=minutely
RandomizedDelaySec=0

# /etc/systemd/system/my-timer.service
[Unit]
ConditionPathExists=/var/run/my-timer

[Service]
Type=oneshot
ExecStart=/bin/echo "HELLO FROM my-timer.service"
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------

2. Start the timer and wait for it to elapse

-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
# systemctl start my-timer.timer
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------

Actual results:

Timer enters "failed" state and doesn't elapse anymore every minute:
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
# systemctl status my-timer.timer
● my-timer.timer
   Loaded: loaded (/etc/systemd/system/my-timer.timer; static; vendor preset: disabled)
   Active: failed (Result: unit-condition-failed) since Wed 2022-10-05 14:44:00 CEST; 1min 5s ago
  Trigger: n/a

Oct 05 14:42:53 vm-rhel8 systemd[1]: Started my-timer.timer.
Oct 05 14:44:00 vm-rhel8 systemd[1]: my-timer.timer: Failed with result 'unit-condition-failed'.
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------

Expected results:

Timer doesn't fail and nothing special happens.

Comment 1 David Tardon 2022-10-05 14:01:03 UTC
This is caused by https://github.com/redhat-plumbers/systemd-rhel8/commit/2820f1706275acd787c72d9a57892200566f0bbe , which has been reverted as a part of fix of bug 2114005.

*** This bug has been marked as a duplicate of bug 2114005 ***