#2039 mailman: Create systemd timers for tasks
Merged 11 months ago by zlopez. Opened 11 months ago by lenkaseg.
fedora-infra/ lenkaseg/ansible timers  into  main

@@ -0,0 +1,7 @@ 

+ [Unit]

+ Description=hyperkitty daily maintenance

+ 

+ [Service]

+ Type=oneshot

+ User=mailman

+ ExecStart=mailman-web runjobs daily

@@ -0,0 +1,8 @@ 

+ [Unit]

+ Description=Run hyperkitty daily maintenance every day

+ Requires=hyperkitty.target

+ PartOf=hyperkitty.target

+ 

+ [Timer]

+ OnCalendar=*-*-* 00:00:00

+ RandomizedDelaySec=1h

@@ -0,0 +1,7 @@ 

+ [Unit]

+ Description=hyperkitty hourly maintenance

+ 

+ [Service]

+ Type=oneshot

+ User=mailman

+ ExecStart=mailman-web runjobs hourly

@@ -0,0 +1,8 @@ 

+ [Unit]

+ Description=Run hyperkitty hourly maintenance every hour

+ Requires=hyperkitty.target

+ PartOf=hyperkitty.target

+ 

+ [Timer]

+ OnCalendar=*-*-* *:00:00

+ RandomizedDelaySec=10m

@@ -0,0 +1,7 @@ 

+ [Unit]

+ Description=hyperkitty minutely maintenance

+ 

+ [Service]

+ Type=oneshot

+ User=mailman

+ ExecStart=mailman-web runjobs minutely

@@ -0,0 +1,7 @@ 

+ [Unit]

+ Description=Run hyperkitty minutely maintenance every minute

+ Requires=hyperkitty.target

+ PartOf=hyperkitty.target

+ 

+ [Timer]

+ OnCalendar=*-*-* *:*:00

@@ -0,0 +1,7 @@ 

+ [Unit]

+ Description=hyperkitty monthly maintenance

+ 

+ [Service]

+ Type=oneshot

+ User=mailman

+ ExecStart=mailman-web runjobs monthly

@@ -0,0 +1,9 @@ 

+ [Unit]

+ Description=Run hyperkitty monthly maintenance every month

+ Requires=hyperkitty.target

+ PartOf=hyperkitty.target

+ 

+ [Timer]

+ OnCalendar=*-*-01 00:00:00

+ RandomizedDelaySec=6h

+ Persistent=true

@@ -0,0 +1,7 @@ 

+ [Unit]

+ Description=hyperkitty maintenance every 15 minutes

+ 

+ [Service]

+ Type=oneshot

+ User=mailman

+ ExecStart=mailman-web runjobs quarter_hourly

@@ -0,0 +1,9 @@ 

+ [Unit]

+ Description=Run hyperkitty maintenance every 15 minutes

+ Requires=hyperkitty.target

+ PartOf=hyperkitty.target

+ 

+ [Timer]

+ OnCalendar=*-*-* *:*/15:00

+ Persistent=true

+ RandomizedDelaySec=5m

@@ -0,0 +1,7 @@ 

+ [Unit]

+ Description=hyperkitty weekly maintenance

+ 

+ [Service]

+ Type=oneshot

+ User=mailman

+ ExecStart=mailman-web runjobs weekly

@@ -0,0 +1,9 @@ 

+ [Unit]

+ Description=Run hyperkitty weekly maintenance every week

+ Requires=hyperkitty.target

+ PartOf=hyperkitty.target

+ 

+ [Timer]

+ OnCalendar=Mon *-*-* 00:00:00

+ RandomizedDelaySec=3h

+ Persistent=true

@@ -0,0 +1,7 @@ 

+ [Unit]

+ Description=hyperkitty yearly maintenance

+ 

+ [Service]

+ Type=oneshot

+ User=mailman

+ ExecStart=mailman-web runjobs yearly

@@ -0,0 +1,9 @@ 

+ [Unit]

+ Description=Run hyperkitty yearly maintenance every year

+ Requires=hyperkitty.target

+ PartOf=hyperkitty.target

+ 

+ [Timer]

+ OnCalendar=*-01-01 00:00:00

+ RandomizedDelaySec=12h

+ Persistent=true

@@ -0,0 +1,13 @@ 

+ [Unit]

+ Description=hyperkitty timed maintenance

+ After=mailman3.service

+ Wants=hyperkitty-minutely.timer

+ Wants=hyperkitty-quarter_hourly.timer

This should be quarterly

+ Wants=hyperkitty-hourly.timer

+ Wants=hyperkitty-daily.timer

+ Wants=hyperkitty-monthly.timer

+ Wants=hyperkitty-weekly.timer

+ Wants=hyperkitty-yearly.timer

+ 

+ [Install]

+ WantedBy=timers.target

@@ -450,6 +450,44 @@ 

      - mailman

      - systemd

  

+ - name: Install the systemd cron services

+   ansible.builtin.file:

+     src: "systemd/{{ item }}.service"

+     dest: "/etc/systemd/system/{{ item }}.service"

+   with_items:

+     - hyperkitty-daily

+     - hyperkitty-hourly

+     - hyperkitty-minutely

+     - hyperkitty-monthly

+     - hyperkitty-quarter_hourly

+     - hyperkitty-weekly

+     - hyperkitty-yearly

+   notify:

+     - systemctl daemon-reload

+   tags:

+     - config

+     - mailman

+     - systemd

+ 

+ - name: Install the systemd timers

+   ansible.builtin.file:

+     src: "systemd/{{ item }}.timer"

+     dest: "/etc/systemd/system/{{ item }}.timer"

+   with_items:

+     - hyperkitty-daily

+     - hyperkitty-hourly

+     - hyperkitty-minutely

+     - hyperkitty-monthly

+     - hyperkitty-quarter_hourly

+     - hyperkitty-weekly

+     - hyperkitty-yearly

+   notify:

+     - systemctl daemon-reload

+   tags:

+     - config

+     - mailman

+     - systemd

+ 

  # Memcached

  - name: Set the memcached sysconfig file

    ansible.builtin.copy:

Creating systemd timers for tasks, so they would not be executed in parallel which is not ideal as it's causing OOM killer to kill some of the tasks

Part of issue #8455

Signed-off-by: Lenka Segura lsegura@redhat.com

rebased onto 287a2934c1833130d8334d65dd69c9a47d6f5ce4

11 months ago

This looks good, just found one service that shouldn't be there.

rebased onto 780ff3d99199e6a5215c7e1a46931c3ac39c3eaa

11 months ago

Thanks for the review!
hyperkitty-qcluster.service removed

mmm, I guess this should be renamed to webui-qcluster?
And should there be a timer for the webui-warm-up-cache.service?

This should be removed at all, as we already have the systemd service for that in the role. No timer is needed forwebui-warm-up-cache.service as it's not OneShot service.

And no timer is needed for webui-qcluster as well for the same reason.

rebased onto da5e4cbae5fa6c4f4a32659d4a6044bd0966770d

11 months ago

ahhh, typo, should be hyperkitty-quarter_hourly

rebased onto dc6df11d5da0f8299bc79080d6f3301092f5c07c

11 months ago

This is not a quarter_hourly, but quarterly job.

rebased onto bd09f4f3794a0ab107a0cdb09288919983954d71

11 months ago

rebased onto 8fa96c87e0184ebc54f24d761daac83ccdbe2246

11 months ago

Only thing that remains now is to correct the quarterly timer + service description. It still says quarter hourly.

I think I renamed those too... git grep "quarter_hourly" neither find . -name *quarter_hourly*.* don't return anything

You renamed them, but the description in the files is still same.

The description still says quarters of hour.

I don't think the timer is correct for quarterly job.

rebased onto f2ad0e1fbc0b53ec766b70344af84bfdeef29afe

11 months ago

I don't think the timer is correct for quarterly job.

Trying to read about it...it seems that OnActiveSec should trigger the job after 15 mins from when the unit was activated, e.g. first run, the OnUnitActiveSec should then handle the following runs.

Or would you set the first run closer to the activation of the unit, like in the first minute?

What I mean, that the quarterly doesn't have OnCalendar option. Look at the original cron job table from mailman

Hm, looking at it there actually isn't any quarterly job, only quarter_hourly. I was confused that you were running mailman-web runjobs quarterly in hyperkitty-quarterly.service. So you have it right, but you had the wrong mailman-web runjobs commands specified in the service.

My mistake, the services and timers should correspond with the cron job table in the mailman3 docs.

Ah, I see, yes, there is quarterly in the command of the service. Fixing!
Thanks for spotting that!

rebased onto e65be09

11 months ago

What I mean, that the quarterly doesn't have OnCalendar option. Look at the original cron job table from mailman

Yeah, here it is defined as relative to the unit start.
Let's use OnCalendar?
Probably like this:OnCalendar=* *-*-* *:*/15:00

rebased onto 57d0329

11 months ago

rebased onto 57d0329

11 months ago

rebased onto 824aa68

11 months ago

rebased onto 824aa68

11 months ago

Pull-Request has been merged by zlopez

11 months ago

When trying to run it, I saw this error:

failed: [mailman01.stg.iad2.fedoraproject.org] (item=hyperkitty-daily) => {"ansible_loop_var": "item", "changed": false, "item": "hyperkitty-daily", "msg": "src option requi
res state to be 'link' or 'hard'", "path": "/etc/systemd/system/hyperkitty-daily.service"}
failed: [mailman01.stg.iad2.fedoraproject.org] (item=hyperkitty-hourly) => {"ansible_loop_var": "item", "changed": false, "item": "hyperkitty-hourly", "msg": "src option req
uires state to be 'link' or 'hard'", "path": "/etc/systemd/system/hyperkitty-hourly.service"}
failed: [mailman01.stg.iad2.fedoraproject.org] (item=hyperkitty-minutely) => {"ansible_loop_var": "item", "changed": false, "item": "hyperkitty-minutely", "msg": "src option
 requires state to be 'link' or 'hard'", "path": "/etc/systemd/system/hyperkitty-minutely.service"}
failed: [mailman01.stg.iad2.fedoraproject.org] (item=hyperkitty-monthly) => {"ansible_loop_var": "item", "changed": false, "item": "hyperkitty-monthly", "msg": "src option r
equires state to be 'link' or 'hard'", "path": "/etc/systemd/system/hyperkitty-monthly.service"}
failed: [mailman01.stg.iad2.fedoraproject.org] (item=hyperkitty-quarter_hourly) => {"ansible_loop_var": "item", "changed": false, "item": "hyperkitty-quarter_hourly", "msg":
 "src option requires state to be 'link' or 'hard'", "path": "/etc/systemd/system/hyperkitty-quarter_hourly.service"}
failed: [mailman01.stg.iad2.fedoraproject.org] (item=hyperkitty-weekly) => {"ansible_loop_var": "item", "changed": false, "item": "hyperkitty-weekly", "msg": "src option req
uires state to be 'link' or 'hard'", "path": "/etc/systemd/system/hyperkitty-weekly.service"}
failed: [mailman01.stg.iad2.fedoraproject.org] (item=hyperkitty-yearly) => {"ansible_loop_var": "item", "changed": false, "item": "hyperkitty-yearly", "msg": "src option req
uires state to be 'link' or 'hard'", "path": "/etc/systemd/system/hyperkitty-yearly.service"}

And now I can see it, you are using ansible.builtin.file command instead of ansible.builtin.copy

Ah, fixing.
That came from looking at the paragraph above, when the services are copied from templates, using the ansible template module. Since the timers and their servces are in files, I checked if there is a file module in ansible, and there was, so I though it's gonna work...well, didn't :/
Changing to copy.

It's usually good to look at the playbook and see how it is done for other files :-)