Skip to content

Feature: Systemd timers

Jakub Skořepa edited this page Jun 2, 2015 · 23 revisions

Create, inspect and (to some extent) modify systemd timers.

Notes

  • Interesting attributes for running commands: workdir, env variables, username, private tmp (+namespace), wants
  • Other interesting attributes: Acuracy, persistency, wakes system
  • Interesting man pages: systemd.service systemd.timer systemd.unit

Stories

Phillip

Wants to run custom daily cleanups every day. It doesn't really matter if it's skipped one day. But he wants to monitor when it was run last time. His cleanups require running database.

Gregory

Wants to generate summaries: every hour, day, week, month, year. He does it by running custom commands. His commands work a lot with /tmp and he doesn't want to pollute it. It's also crucial that his commands are run even if his server is not running at specified time.

Jan

Wants to run existing unit one hour after system start.

Bruce

Wants to monitor when dnf generates cache

Workflows

Phillip:

  • Opens services -> timers
  • Clicks on create button
  • Creates his timer with custom commands
  • He also select database server in wants field
  • Then he sees next time when it will be run which confirms he's done it right
  • He also might want to change cleanup frequency

Gregory:

  • Creates his timer
  • He specifies private tmp
  • Because he wants to share tmps between all his summary generators he specifies namespace

Jan:

  • Creates timer

Bruce:

  • Looks at timer summary page

Implementation Notes and Technical Limitations

  • Timers running commands will be implemented using one .service unit and one .timer unit
  • .service unit created by cockpit will have X-COCKPIT-TIMER attribute set to true
  • We are limited by systemd capabilities
  • We will need to create D-Bus API for creating and modifying timers.

D-Bus API

Method to create unit - here you specify name, and key-val pairs of config info. maybe this:

        sa{sa{ss}}
        |  |  ||
      Name |  |Value
 Section name |
             Key

Method to modify unit:

sa{sa{ss}}

Types are same as in previous. Empty value strings mean: delete this parameter.

Question: What to implement this in? Is vala OK?

This service will be D-Bus activated and will exit after first method call or timeout (1 minute?).

Bus name: How about org.cockpit-project.SystemdUnit1

Wireframes

I need something to select multiple item from (long) list. Patternfly doesn't support this. It's required for selecting units which have to be running before timer is run.

First design: First design mockup

Quick implementation:

Timer overview: Overview

Creation dialog: Creation

Implementation steps

  1. Now I'm working on creation dialog (GUI only)
  2. Next step is designing and implementing D-Bus API
  3. Implement action on create button press
  4. Next is edit button -- dialog and action.
    • This can reuse previous steps.
  5. Then page which shows up when you click on timer
    • This page should show: .timer journal, .service journal and information which you input into creation dialog

Prior art

Links to screenshots or documentation of other places this problem has been solved.

  • None?

Feedback

Please give feedback on the above! This is the place where those not working on the feature can provide insight, questions, limitations, notes etc.

  • ... (sign name)
  • ... (sign name)
Clone this wiki locally