public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH RFC guest-common/manager/docs] adapt calendar events to pbs/systemd style
@ 2020-09-10 12:57 Dominik Csapak
  2020-09-10 12:57 ` [pve-devel] [PATCH RFC guest-common 1/1] ReplicationConfig: transform schedules to include always hours Dominik Csapak
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Dominik Csapak @ 2020-09-10 12:57 UTC (permalink / raw)
  To: pve-devel

pbs cannot handle minute only calendar events
(because we support seconds there and hh:mm and mm:ss would be ambiguous)

so we want to eventually remove that in pve (in a future major version)
to have a consistent calendarevent syntax

for this we do 4 things here:

* transform such events when writing the replication config (to *:YYY)
* adapt the defaults in the gui (to include the hour as *)
* rewrite the docs to not mention that the hour is optional
* replace */x with 0/x since that works in systemd too

the parser still is the same, so existing config stay valid
and on the next config write, the syntax will automatically adapt
(this way we can have a parse/write cycle e.g. in an pve6to7 script
and can be sure we have the new syntax)

pve-guest-common:

Dominik Csapak (1):
  ReplicationConfig: transform schedules to include always hours

 PVE/ReplicationConfig.pm | 31 ++++++++++++++++++++++++++++++-
 1 file changed, 30 insertions(+), 1 deletion(-)

pve-manager:

Dominik Csapak (2):
  ui: adapt/optimize calendar event examples
  ui: grid/Replication: change the default format of schedule text

 www/manager6/form/CalendarEvent.js | 6 +++---
 www/manager6/grid/Replication.js   | 7 ++++---
 2 files changed, 7 insertions(+), 6 deletions(-)

pve-docs:

Dominik Csapak (2):
  pvesr: fix calendar event examples
  pvesr: modify examples to fit with pbs style

 pvesr.adoc | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)

-- 
2.20.1





^ permalink raw reply	[flat|nested] 6+ messages in thread

* [pve-devel] [PATCH RFC guest-common 1/1] ReplicationConfig: transform schedules to include always hours
  2020-09-10 12:57 [pve-devel] [PATCH RFC guest-common/manager/docs] adapt calendar events to pbs/systemd style Dominik Csapak
@ 2020-09-10 12:57 ` Dominik Csapak
  2020-09-10 12:57 ` [pve-devel] [PATCH RFC manager 1/2] ui: adapt/optimize calendar event examples Dominik Csapak
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Dominik Csapak @ 2020-09-10 12:57 UTC (permalink / raw)
  To: pve-devel

systemd and pbs require the hour for schedules. so to be compatible
in the future, transform all schedules that omit the hour to '*:MINSPEC'
(where MINSPEC is the given spec for the minutes)

we do this now, so we can drop the 'minutes only' syntax in the future
sometimes

also adapt the default value

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 PVE/ReplicationConfig.pm | 31 ++++++++++++++++++++++++++++++-
 1 file changed, 30 insertions(+), 1 deletion(-)

diff --git a/PVE/ReplicationConfig.pm b/PVE/ReplicationConfig.pm
index 66ef842..842aa63 100644
--- a/PVE/ReplicationConfig.pm
+++ b/PVE/ReplicationConfig.pm
@@ -76,7 +76,7 @@ my $defaultData = {
 	    description => "Storage replication schedule. The format is a subset of `systemd` calendar events.",
 	    type => 'string', format => 'pve-calendar-event',
 	    maxLength => 128,
-	    default => '*/15',
+	    default => '*:*/15',
 	    optional => 1,
 	},
 	source => {
@@ -115,6 +115,31 @@ sub get_unique_target_id {
     die "please overwrite in subclass";
 }
 
+# to have better compatibility with PBS/Systemd, we write
+# out 'minute' only calendar events with hours as *
+my $transform_calendar_event = sub {
+    my $event = shift;
+
+    my @parts = split(/\s+/, $event);
+    my $utc = (@parts && uc($parts[-1]) eq 'UTC');
+    pop @parts if $utc;
+
+    return $event if @parts < 1;
+    my $potential_time_spec = pop @parts;
+
+    # if it contains an : it already has an hour,
+    # and if it contains any charactor from a-z it is a weekday spec
+    if ($potential_time_spec !~ m/:/  && $potential_time_spec !~ m/[a-zA-Z]/) {
+	$potential_time_spec = "*:" . $potential_time_spec;
+    }
+
+    push @parts, $potential_time_spec;
+
+    push @parts, 'UTC' if $utc;
+
+    return join(' ', @parts);
+};
+
 sub parse_config {
     my ($class, $filename, $raw) = @_;
 
@@ -161,6 +186,10 @@ sub write_config {
 	my $tid = $plugin->get_unique_target_id($data);
 	my $vmid = $data->{guest};
 
+	if (defined($data->{schedule})) {
+	    $data->{schedule} = $transform_calendar_event->($data->{schedule});
+	}
+
 	die "property 'guest' has wrong value\n" if $id !~ m/^\Q$vmid\E-/;
 	die "replication job for guest '$vmid' to target '$tid' already exists\n"
 	    if defined($target_hash->{$vmid}->{$tid});
-- 
2.20.1





^ permalink raw reply	[flat|nested] 6+ messages in thread

* [pve-devel] [PATCH RFC manager 1/2] ui: adapt/optimize calendar event examples
  2020-09-10 12:57 [pve-devel] [PATCH RFC guest-common/manager/docs] adapt calendar events to pbs/systemd style Dominik Csapak
  2020-09-10 12:57 ` [pve-devel] [PATCH RFC guest-common 1/1] ReplicationConfig: transform schedules to include always hours Dominik Csapak
@ 2020-09-10 12:57 ` Dominik Csapak
  2020-09-10 12:57 ` [pve-devel] [PATCH RFC manager 2/2] ui: grid/Replication: change the default format of schedule text Dominik Csapak
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Dominik Csapak @ 2020-09-10 12:57 UTC (permalink / raw)
  To: pve-devel

pbs cannot parse minutes alone
(if the hours would be optional it would be ambiguies between hh:mm and mm:ss)

so we adapt the examples here, so that newly created schedules from the
examples include always the hour

also replace */x with 0/x. they are semantically the same, but the
latter is also valid in systemd, while the former is not

also reduce the */1 to * since the /1 does not do anything

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 www/manager6/form/CalendarEvent.js | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/www/manager6/form/CalendarEvent.js b/www/manager6/form/CalendarEvent.js
index c3b9ecab..1cb8d492 100644
--- a/www/manager6/form/CalendarEvent.js
+++ b/www/manager6/form/CalendarEvent.js
@@ -11,11 +11,11 @@ Ext.define('PVE.form.CalendarEvent', {
     store: {
 	field: [ 'value', 'text'],
 	data: [
-	    { value: '*/30', text: Ext.String.format(gettext("Every {0} minutes"), 30) },
-	    { value: '*/2:00', text: gettext("Every two hours")},
+	    { value: '*:00/30', text: Ext.String.format(gettext("Every {0} minutes"), 30) },
+	    { value: '00/2:00', text: gettext("Every two hours")},
 	    { value: '2,22:30', text: gettext("Every day") + " 02:30, 22:30"},
 	    { value: 'mon..fri', text: gettext("Monday to Friday") + " 00:00"},
-	    { value: 'mon..fri */1:00', text: gettext("Monday to Friday") + ': ' +  gettext("hourly")},
+	    { value: 'mon..fri *:00', text: gettext("Monday to Friday") + ': ' +  gettext("hourly")},
 	    { value: 'sun 01:00', text: gettext("Sunday") + " 01:00"}
 	]
     },
-- 
2.20.1





^ permalink raw reply	[flat|nested] 6+ messages in thread

* [pve-devel] [PATCH RFC manager 2/2] ui: grid/Replication: change the default format of schedule text
  2020-09-10 12:57 [pve-devel] [PATCH RFC guest-common/manager/docs] adapt calendar events to pbs/systemd style Dominik Csapak
  2020-09-10 12:57 ` [pve-devel] [PATCH RFC guest-common 1/1] ReplicationConfig: transform schedules to include always hours Dominik Csapak
  2020-09-10 12:57 ` [pve-devel] [PATCH RFC manager 1/2] ui: adapt/optimize calendar event examples Dominik Csapak
@ 2020-09-10 12:57 ` Dominik Csapak
  2020-09-10 12:57 ` [pve-devel] [PATCH docs 1/2] pvesr: fix calendar event examples Dominik Csapak
  2020-09-10 12:57 ` [pve-devel] [PATCH RFC docs 2/2] pvesr: modify examples to fit with pbs style Dominik Csapak
  4 siblings, 0 replies; 6+ messages in thread
From: Dominik Csapak @ 2020-09-10 12:57 UTC (permalink / raw)
  To: pve-devel

we want to sometimes elminiate the 'minute-only' syntax, so change
the defaults from '*/15' to the semantically identical '*:00/15'

make the replication edit window a bit wider to show the complete
empty text

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 www/manager6/grid/Replication.js | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/www/manager6/grid/Replication.js b/www/manager6/grid/Replication.js
index 19e67d90..c1f756b4 100644
--- a/www/manager6/grid/Replication.js
+++ b/www/manager6/grid/Replication.js
@@ -4,6 +4,7 @@ Ext.define('PVE.window.ReplicaEdit', {
 
     subject: gettext('Replication Job'),
 
+    width: 350,
 
     url: '/cluster/replication',
     method: 'POST',
@@ -35,7 +36,7 @@ Ext.define('PVE.window.ReplicaEdit', {
 	    {
 		xtype: 'pveCalendarEvent',
 		fieldLabel: gettext('Schedule'),
-		emptyText: '*/15 - ' + Ext.String.format(gettext('Every {0} minutes'), 15),
+		emptyText: '*:00/15 - ' + Ext.String.format(gettext('Every {0} minutes'), 15),
 		name: 'schedule'
 	    },
 	    {
@@ -74,7 +75,7 @@ Ext.define('PVE.window.ReplicaEdit', {
 
 		    PVE.Utils.delete_if_default(values, 'rate', '', me.isCreate);
 		    PVE.Utils.delete_if_default(values, 'disable', 0, me.isCreate);
-		    PVE.Utils.delete_if_default(values, 'schedule', '*/15', me.isCreate);
+		    PVE.Utils.delete_if_default(values, 'schedule', '*:00/15', me.isCreate);
 		    PVE.Utils.delete_if_default(values, 'comment', '', me.isCreate);
 
 		    if (me.isCreate) {
@@ -481,7 +482,7 @@ Ext.define('PVE.grid.ReplicaView', {
 	    'id', 'target', 'comment', 'rate', 'type',
 	    { name: 'guest', type: 'integer' },
 	    { name: 'jobnum', type: 'integer' },
-	    { name: 'schedule', defaultValue: '*/15' },
+	    { name: 'schedule', defaultValue: '*:00/15' },
 	    { name: 'disable', defaultValue: '' },
 	    { name: 'enabled', calculate: function(data) { return !data.disable; } }
 	]
-- 
2.20.1





^ permalink raw reply	[flat|nested] 6+ messages in thread

* [pve-devel] [PATCH docs 1/2] pvesr: fix calendar event examples
  2020-09-10 12:57 [pve-devel] [PATCH RFC guest-common/manager/docs] adapt calendar events to pbs/systemd style Dominik Csapak
                   ` (2 preceding siblings ...)
  2020-09-10 12:57 ` [pve-devel] [PATCH RFC manager 2/2] ui: grid/Replication: change the default format of schedule text Dominik Csapak
@ 2020-09-10 12:57 ` Dominik Csapak
  2020-09-10 12:57 ` [pve-devel] [PATCH RFC docs 2/2] pvesr: modify examples to fit with pbs style Dominik Csapak
  4 siblings, 0 replies; 6+ messages in thread
From: Dominik Csapak @ 2020-09-10 12:57 UTC (permalink / raw)
  To: pve-devel

'22' as timespec results in every hour at 22 minutes, so
0:22, 1:22, etc. not at 22:00 like the text suggests

fix the examples to match the text

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 pvesr.adoc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/pvesr.adoc b/pvesr.adoc
index a1a366c..6a2049b 100644
--- a/pvesr.adoc
+++ b/pvesr.adoc
@@ -103,8 +103,8 @@ This format allows you to configure a set of days on which the job should run.
 You can also set one or more start times. It tells the replication scheduler
 the moments in time when a job should start.
 With this information we, can create a job which runs every workday at 10
-PM: `'mon,tue,wed,thu,fri 22'` which could be abbreviated to: `'mon..fri
-22'`, most reasonable schedules can be written quite intuitive this way.
+PM: `'mon,tue,wed,thu,fri 22:00'` which could be abbreviated to: `'mon..fri
+22:00'`, most reasonable schedules can be written quite intuitive this way.
 
 NOTE: Hours are formatted in 24-hour format.
 
-- 
2.20.1





^ permalink raw reply	[flat|nested] 6+ messages in thread

* [pve-devel] [PATCH RFC docs 2/2] pvesr: modify examples to fit with pbs style
  2020-09-10 12:57 [pve-devel] [PATCH RFC guest-common/manager/docs] adapt calendar events to pbs/systemd style Dominik Csapak
                   ` (3 preceding siblings ...)
  2020-09-10 12:57 ` [pve-devel] [PATCH docs 1/2] pvesr: fix calendar event examples Dominik Csapak
@ 2020-09-10 12:57 ` Dominik Csapak
  4 siblings, 0 replies; 6+ messages in thread
From: Dominik Csapak @ 2020-09-10 12:57 UTC (permalink / raw)
  To: pve-devel

pbs cannot handle minute only calendar events, and we want to get
consistent eventually, so replace all those examples with
the hour added

also replace */x examples with 0/x as they are functually the same
and the latter is also valid in systemd (the former is not)

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 pvesr.adoc | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/pvesr.adoc b/pvesr.adoc
index 6a2049b..a316518 100644
--- a/pvesr.adoc
+++ b/pvesr.adoc
@@ -114,9 +114,6 @@ itself and the start-time(s) plus all multiples of the repetition value. If
 you want to start replication at 8 AM and repeat it every 15 minutes until
 9 AM you would use: `'8:00/15'`
 
-Here you see that if no hour separation (`:`), is used the value gets
-interpreted as minute. If such a separation is used, the value on the left
-denotes the hour(s), and the value on the right denotes the minute(s).
 Further, you can use `*` to match all possible values.
 
 To get additional ideas look at
@@ -134,8 +131,7 @@ If omitted `'*'` is assumed.
 time-format:: A time format consists of hours and minutes interval lists.
 Hours and minutes are separated by `':'`. Both hour and minute can be list
 and ranges of values, using the same format as days.
-First are hours, then minutes. Hours can be omitted if not needed. In this
-case `'*'` is assumed for the value of hours.
+First are hours, then minutes.
 The valid range for values is `0-23` for hours and `0-59` for minutes.
 
 [[pvesr_schedule_format_examples]]
@@ -149,13 +145,13 @@ Examples:
 |mon,tue,wed,thu,fri	|mon..fri		|Every working day at 0:00
 |sat,sun		|sat..sun		|Only on weekends at 0:00
 |mon,wed,fri		|--			|Only on Monday, Wednesday and Friday at 0:00
-|12:05			|12:05			|Every day at 12:05 PM
-|*/5			|0/5			|Every five minutes
-|mon..wed 30/10		|mon,tue,wed 30/10	|Monday, Tuesday, Wednesday 30, 40 and 50 minutes after every full hour
+|12:05			|--			|Every day at 12:05 PM
+|*:00/5			|*:0/5			|Every five minutes
+|mon..wed *:30/10	|mon,tue,wed *:30/10	|Monday, Tuesday, Wednesday 30, 40 and 50 minutes after every full hour
 |mon..fri 8..17,22:0/15	|--			|Every working day every 15 minutes between 8 AM and 6 PM and between 10 PM and 11 PM
 |fri 12..13:5/20	|fri 12,13:5/20		|Friday at 12:05, 12:25, 12:45, 13:05, 13:25 and 13:45
 |12,14,16,18,20,22:5	|12/2:5			|Every day starting at 12:05 until 22:05, every 2 hours
-|*			|*/1			|Every minute (minimum interval)
+|\*:*			|0/1:0/1		|Every minute (minimum interval)
 |==============================================================================
 
 Error Handling
-- 
2.20.1





^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-09-10 12:57 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-10 12:57 [pve-devel] [PATCH RFC guest-common/manager/docs] adapt calendar events to pbs/systemd style Dominik Csapak
2020-09-10 12:57 ` [pve-devel] [PATCH RFC guest-common 1/1] ReplicationConfig: transform schedules to include always hours Dominik Csapak
2020-09-10 12:57 ` [pve-devel] [PATCH RFC manager 1/2] ui: adapt/optimize calendar event examples Dominik Csapak
2020-09-10 12:57 ` [pve-devel] [PATCH RFC manager 2/2] ui: grid/Replication: change the default format of schedule text Dominik Csapak
2020-09-10 12:57 ` [pve-devel] [PATCH docs 1/2] pvesr: fix calendar event examples Dominik Csapak
2020-09-10 12:57 ` [pve-devel] [PATCH RFC docs 2/2] pvesr: modify examples to fit with pbs style Dominik Csapak

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal