cockpit icon indicating copy to clipboard operation
cockpit copied to clipboard

services: No ability to edit timers

Open andreasn opened this issue 7 years ago • 17 comments
trafficstars

This came up in the usability testing. There is apparently no way to edit a timer. Either if you did something wrong during the creation of it, or if you want to change the time it runs. Also we might want to enable users to delete them.

andreasn avatar Jun 21 '18 15:06 andreasn

The details page also doesn't show timer specific things like when it will trigger next.

mvollmer avatar Jun 06 '19 11:06 mvollmer

Ability to delete timers also appreciated!

kaushalyap avatar Jan 26 '22 08:01 kaushalyap

Altogether, a complete editing experience should include:

  • Edit timers (most likely implemented with a prefill of the new timer with the previous settings, then when saving: remove the old one and create the new one with the sa,e filename)
  • Delete timers (probably for Cockpit-created / manually created timers)
  • Show manually added (probably Cockpit-added timers, really) at the top of the list, so they're easier to see (versus the system-installed timers)

garrett avatar Mar 21 '22 14:03 garrett

I wonder if it's possible to add a custom field to the [Timer] section, such as CockpitEditable=true, which would allow us to find out which ones were custom made by Cockpit and are allowed to be edited in Cockpit. (I'm not sure if this would be fine with systemd, but I imagine it would be? We'd need to make sure.)

We probably don't want to edit system timers, right? Or if we "edit" system ones, we probably would want to create a custom timer based on the settings in the system-installed one and disable the original when enabling our custom one.

garrett avatar Mar 21 '22 14:03 garrett

possible to add a custom field to the [Timer] section, such as CockpitEditable=true.

Yes, that's possible with the common X- prefix convention, i.e. X-Cockpit-Editable.

martinpitt avatar Mar 21 '22 14:03 martinpitt

Oh, that's really neat, but people might already have custom timers. My WiP PR for deleting timers checks for timers in /etc/systemd/system so we don't edit system timers.

jelly avatar Mar 21 '22 14:03 jelly

@jelly: Ah cool! Then we could use that instead. Even better!

garrett avatar Mar 21 '22 14:03 garrett

Another issue is that timers currently overwrite existing timers, so ideally it would not allow that too.

jelly avatar Mar 25 '22 08:03 jelly

Another issue is that timers currently overwrite existing timers, so ideally it would not allow that too.

Yeah, we should definitely check for that. We could use a force overwrite pattern of sorts (perhaps like the account's force weak password in the account password modal) where the main button is disabled (to prevent accidental misclicks) and a secondary button shows up to force overwrite it. I suppose we'd want to have an error message of sorts show up, like an inline alert at the top of the modal showing that the timer's filename already exists.

garrett avatar Mar 28 '22 16:03 garrett

@garrett, @jelly, @martinpitt Another feature that would be a great add (maybe there is already a way im not seeing) is the ability for the timer to repeat at a certain frequency. more specifically every x seconds, minutes, hours from creation. something like image

thoughts?

should I finish pounding this out and submit a PR or is there other larger changes in progress?

dphaas2004 avatar Jul 18 '22 18:07 dphaas2004

@garrett, @jelly, @martinpitt Another feature that would be a great add (maybe there is already a way im not seeing) is the ability for the timer to repeat at a certain frequency. more specifically every x seconds, minutes, hours from creation. something like image

thoughts?

I wonder how is this different from adding Minutely next to `Hourly. Currently hourly with 5 minutes generates:

[jelle@t14s][~]%systemd-analyze calendar '*-*-* *:5' --iterations=5
  Original form: *-*-* *:5
Normalized form: *-*-* *:05:00
    Next elapse: Tue 2022-07-19 18:05:00 CEST
       (in UTC): Tue 2022-07-19 16:05:00 UTC
       From now: 59min left
       Iter. #2: Tue 2022-07-19 19:05:00 CEST
       (in UTC): Tue 2022-07-19 17:05:00 UTC
       From now: 1h 59min left
       Iter. #3: Tue 2022-07-19 20:05:00 CEST
       (in UTC): Tue 2022-07-19 18:05:00 UTC
       From now: 2h 59min left
       Iter. #4: Tue 2022-07-19 21:05:00 CEST
       (in UTC): Tue 2022-07-19 19:05:00 UTC
       From now: 3h 59min left
       Iter. #5: Tue 2022-07-19 22:05:00 CEST
       (in UTC): Tue 2022-07-19 20:05:00 UTC
       From now: 4h 59min left

So minutely could generate:

[jelle@t14s][~]%systemd-analyze calendar '*-*-* *:*:5' --iterations=5
  Original form: *-*-* *:*:5
Normalized form: *-*-* *:*:05
    Next elapse: Tue 2022-07-19 17:09:05 CEST
       (in UTC): Tue 2022-07-19 15:09:05 UTC
       From now: 59s left
       Iter. #2: Tue 2022-07-19 17:10:05 CEST
       (in UTC): Tue 2022-07-19 15:10:05 UTC
       From now: 1min 59s left
       Iter. #3: Tue 2022-07-19 17:11:05 CEST
       (in UTC): Tue 2022-07-19 15:11:05 UTC
       From now: 2min 59s left
       Iter. #4: Tue 2022-07-19 17:12:05 CEST
       (in UTC): Tue 2022-07-19 15:12:05 UTC
       From now: 3min 59s left
       Iter. #5: Tue 2022-07-19 17:13:05 CEST
       (in UTC): Tue 2022-07-19 15:13:05 UTC
       From now: 4min 59s left

should I finish pounding this out and submit a PR or is there other larger changes in progress?

Afaik there are currently no changes being made to how the timers work.

jelly avatar Jul 19 '22 15:07 jelly

@jelly This would work for my use case. Main difference between what I suggested and yours is mine wouldn't use OnCalendar but rather OnUnitActiveSec. but maybe that should be a different trigger option?

dphaas2004 avatar Jul 19 '22 17:07 dphaas2004

@jelly This would work for my use case. Main difference between what I suggested and yours is mine wouldn't use OnCalendar but rather OnUnitActiveSec. but maybe that should be a different trigger option?

OnUnitActiveSec would be something different, we already have OnBootSec which is the After system boot option. We could add OnUnitActiveSec, not sure how we would label the checkbox option.

jelly avatar Jul 20 '22 07:07 jelly

What would happen after a reboot if OnUnitActiveSec is used? Does it basically equate to being the same as OnBootSec in that scenario? Or does the timer go away?

What's the expected use? Do this every X time units from now... on current boot only? or for every X time units "forever", starting from now?

garrett avatar Jul 20 '22 07:07 garrett

It's explained in systemd.timer https://man.archlinux.org/man/systemd.timer.5#OPTIONS

jelly avatar Jul 20 '22 09:07 jelly

It's explained in systemd.timer https://man.archlinux.org/man/systemd.timer.5#OPTIONS

I don't see any answers to the questions I asked on the page.

I want to know what people expect (such as @dphaas2004) and if it is still active after a boot. And if it is active after a boot, is it still relative to the time it was set or relative to boot time. The page doesn't answer these questions.

garrett avatar Jul 20 '22 10:07 garrett

@garrett my expected behavior is that it happens at some regular frequency. Most typically for me its every minute or every 5 minutes. The specific start time of that service is irrelevant to my use case. It is expected to be persistent and continue after a reboot. In my case I need it reoccurring. isn't OnBootSec a single firing of the timer? Also when I tested OnBootSec it didnt launch automatically as I would have expected either. this may be related to #1 below.

Side notes:

  1. There is no options to make a timer persistent either. may want to look at adding that
  2. I implemented the minutely option as suggested but that doesnt really do much as it only allows for one minute intervals starting at a specific second. Does not allow for every 5 minutes. This can be done via hourly and selecting every five minute intervals but is tedious versus OnCalendar=*:0/5 or OnUnitActiveSec=5min

I was thinking just having a custom option for on calendar and then using systemd-analyze calendar to validate the entry prior to savings? Which brings me to another point. Should the timer_unit.OnCalendar or timer_unit.boot_time be validated using this method?

dphaas2004 avatar Jul 20 '22 12:07 dphaas2004

Editing should be an item in the kebab menu (probably with a separator, so it's Restart, Stop, Separator, Edit, and the rest) and it should bring up a modal similar to the create, but titled "Editing timer: timername" and have the values prefilled with the existing settings.

garrett avatar Mar 02 '23 11:03 garrett

And only for systemd timers created in /etc/systemd/system/ I assume.

jelly avatar Mar 02 '23 13:03 jelly