Bug 878826 - [rfe] dnf could use systemd timer unit rather than crontabs
Summary: [rfe] dnf could use systemd timer unit rather than crontabs
Keywords:
Status: CLOSED NEXTRELEASE
Alias: None
Product: Fedora
Classification: Fedora
Component: dnf
Version: 18
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Ales Kozumplik
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On: 879597
Blocks:
TreeView+ depends on / blocked
 
Reported: 2012-11-21 10:35 UTC by Harald Hoyer
Modified: 2014-09-30 23:40 UTC (History)
3 users (show)

Fixed In Version: dnf-0.3.1
Clone Of:
Environment:
Last Closed: 2013-03-25 14:09:51 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
Jochen Schmitt's patch for the RFE (3.40 KB, patch)
2013-01-22 08:44 UTC, Ales Kozumplik
no flags Details | Diff

Description Harald Hoyer 2012-11-21 10:35:38 UTC
Instead of "/etc/cron.hourly/dnf-makecache.cron" and "/var/log/dnf-makecache.cron", I would suggest to use systemd timer units and make use of the logging features of systemd.

This way we do not require cron and we can deinstall it.

$ sudo rpm -e cronie cronie-anacron crontabs
error: Failed dependencies:
	crontabs is needed by (installed) dnf-0.2.15-3.git5d85f6b.fc18.noarch

dnf is the only rpm needing crontabs on my system with 2142 rpm packages installed.

$ rpm -qa | wc -l
2142


$ cat /usr/lib/systemd/system/dnf-makecache.timer
[Unit]
Description=dnf makecache timer

[Timer]
OnBootSec=10min
OnUnitInactiveSec=1h
Unit=dnf-makecache.service

[Install]
WantedBy=basic.target

$ cat /usr/lib/systemd/system/dnf-makecache.service
[Unit]
Description=dnf makecache

[Service]
Type=oneshot
Nice=19
IOSchedulingClass=2
IOSchedulingPriority=7
ExecStart=/usr/bin/dnf makecache

Comment 1 Harald Hoyer 2012-11-21 10:40:56 UTC
$ systemctl status dnf-makecache.timer  
dnf-makecache.timer - dnf makecache timer
	  Loaded: loaded (/etc/systemd/system/dnf-makecache.timer; disabled)
	  Active: active (waiting) since Wed, 2012-11-21 11:31:10 CET; 6min ago

$ systemctl status dnf-makecache.service
dnf-makecache.service - dnf makecache
	  Loaded: loaded (/etc/systemd/system/dnf-makecache.service; static)
	  Active: inactive (dead) since Wed, 2012-11-21 11:30:10 CET; 8min ago
	Main PID: 3779 (code=exited, status=0/SUCCESS)
	  CGroup: name=systemd:/system/dnf-makecache.service

Nov 21 11:30:09 lenovo systemd[1]: Starting dnf makecache...
Nov 21 11:30:10 lenovo dnf[3779]: Metadata Cache Created
Nov 21 11:30:10 lenovo systemd[1]: Started dnf makecache.

$ sudo journalctl _SYSTEMD_UNIT=dnf-makecache.service
-- Logs begin at Thu, 2012-07-19 10:37:56 CEST, end at Mon, 2012-09-10 11:09:10 CEST. --
Nov 21 09:30:10 lenovo dnf[3761]: Metadata Cache Created
Nov 21 10:30:10 lenovo dnf[3772]: Metadata Cache Created
Nov 21 11:30:10 lenovo dnf[3779]: Metadata Cache Created

Comment 2 Ales Kozumplik 2012-11-21 12:14:07 UTC
Hi Harald, thanks for the report, I had no idea that this is how the repeating tasks are done now. I've got quite a lot of things to do on DNF right now, so your patch helps a lot. One question:

[Timer]
OnBootSec=10min
OnUnitInactiveSec=1h
Unit=dnf-makecache.service

Does this mean that makecache will run 10 minutes after every boot and then every hour?

Also (and I have been wondering about how to do this for some time): could there be a timer item to specify the required network service level, e.g.:

[Timer]
...
NetworkServiceAtLeast=Ethernet

Because if people are connected via their crazy expensive 3G (and NetworkManager should have this information) I can imagine they are not cool about package manager updating itself every hour.

Comment 3 Harald Hoyer 2012-11-21 13:22:21 UTC
(In reply to comment #2)
> Hi Harald, thanks for the report, I had no idea that this is how the
> repeating tasks are done now. I've got quite a lot of things to do on DNF
> right now, so your patch helps a lot. One question:
> 
> [Timer]
> OnBootSec=10min
> OnUnitInactiveSec=1h
> Unit=dnf-makecache.service
> 
> Does this mean that makecache will run 10 minutes after every boot and then
> every hour?

yes

$ man systemd.timer
OnBootSec= defines a timer relative to when the machine was
           booted up.

> 
> Also (and I have been wondering about how to do this for some time): could
> there be a timer item to specify the required network service level, e.g.:
> 
> [Timer]
> ...
> NetworkServiceAtLeast=Ethernet
> 
> Because if people are connected via their crazy expensive 3G (and
> NetworkManager should have this information) I can imagine they are not cool
> about package manager updating itself every hour.

Well, this has to be resolved via other mechanisms than systemd. systemd does not know the current network state.

Maybe this cache polling should be removed entirely?

Comment 4 Ales Kozumplik 2012-11-23 12:35:06 UTC
> Well, this has to be resolved via other mechanisms than systemd. systemd
> does not know the current network state.
> 
> Maybe this cache polling should be removed entirely?

I don't think it would be a good thing to start dropping components' functionalities just to make them fit into the systemd's scheme of things.

Comment 5 Harald Hoyer 2012-11-23 13:41:41 UTC
(In reply to comment #4)
> > Well, this has to be resolved via other mechanisms than systemd. systemd
> > does not know the current network state.
> > 
> > Maybe this cache polling should be removed entirely?
> 
> I don't think it would be a good thing to start dropping components'
> functionalities just to make them fit into the systemd's scheme of things.

Well, the dropping suggestions was not based on systemd's functionality but your own argument "if people are connected via their crazy expensive 3G".

Even NetworkManager cannot know, if your laptop is connected to your mobile hotspot via WLAN.

Comment 6 Ales Kozumplik 2012-11-23 13:50:18 UTC
(In reply to comment #5)
> Even NetworkManager cannot know, if your laptop is connected to your mobile
> hotspot via WLAN.

Easy, add a checkbox in the NM WLAN dialog that says 'Minimize maintenance traffic through this network.' We'll need it anyway at some point---for instance most other synchronization tasks like backups.

I opened the systemd bug 879370 for this.

Comment 7 Ales Kozumplik 2013-01-07 07:56:13 UTC
Related: bug 878826.

Comment 8 Ales Kozumplik 2013-01-22 08:44:57 UTC
Created attachment 684945 [details]
Jochen Schmitt's patch for the RFE

Comment 9 Ales Kozumplik 2013-03-25 14:09:51 UTC
Addressed by commit 878826, will be included in dnf-0.3.1.

The cron file stays in the repo but only the systemd .timer file is packaged for Fedora. The custom ABRT collector stays broken, bug 879597.

Comment 10 Marcos Mello 2013-08-31 02:26:32 UTC
Nit: the "Unit=" line is optional in the .timer file if it has the same basename of the .service.

"For each timer file, a matching unit file must exist, describing the unit to activate when the timer elapses. By default, a service by the same name as the timer (except for the suffix) is activated. Example: a timer file foo.timer activates a matching service foo.service. The unit to activate may be controlled by Unit= (see below)."

http://www.freedesktop.org/software/systemd/man/systemd.timer.html

Comment 11 Ales Kozumplik 2013-09-02 06:11:58 UTC
Hi Marcos, if you prefer the service file without the Unit= line please open a new bugzilla, this one has been long closed. Thank you.


Note You need to log in before you can comment on or make changes to this bug.