From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 35203703B2 for ; Mon, 13 Jun 2022 14:32:19 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 27B67B0E1 for ; Mon, 13 Jun 2022 14:32:19 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id CD2F8B0C9 for ; Mon, 13 Jun 2022 14:32:17 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 9BEE442DD2 for ; Mon, 13 Jun 2022 14:32:17 +0200 (CEST) Message-ID: Date: Mon, 13 Jun 2022 14:32:16 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.0 Content-Language: en-US To: pve-devel@lists.proxmox.com, Dominik Csapak References: <20220602074206.814493-1-d.csapak@proxmox.com> <20220602074206.814493-2-d.csapak@proxmox.com> From: Fabian Ebner In-Reply-To: <20220602074206.814493-2-d.csapak@proxmox.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.916 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment NICE_REPLY_A -1.732 Looks like a legit reply (A) SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record T_SCC_BODY_TEXT_LINE -0.01 - Subject: Re: [pve-devel] [PATCH manager v2 1/3] fix #4026: add 'repeat-missed' option for jobs X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 13 Jun 2022 12:32:19 -0000 Am 02.06.22 um 09:42 schrieb Dominik Csapak: > diff --git a/PVE/API2/Backup.pm b/PVE/API2/Backup.pm > index 5d36789a..ced48977 100644 > --- a/PVE/API2/Backup.pm > +++ b/PVE/API2/Backup.pm > @@ -180,6 +180,13 @@ __PACKAGE__->register_method({ > description => "Enable or disable the job.", > default => '1', > }, > + 'repeat-missed' => { > + optional => 1, > + type => 'boolean', > + description => "If true, the job will be run as soon as possible if it was missed while". > + " the scheduler was not running.", Style nit: Line too long and continuation should be indented once more. > + default => 0, > + }, > comment => { > optional => 1, > type => 'string', > @@ -381,6 +388,13 @@ __PACKAGE__->register_method({ > description => "Enable or disable the job.", > default => '1', > }, > + 'repeat-missed' => { > + optional => 1, > + type => 'boolean', > + description => "If true, the job will be run as soon as possible if it was missed while". > + " the scheduler was not running.", Same here. > + default => 0, > + }, > comment => { > optional => 1, > type => 'string', > diff --git a/PVE/Jobs.pm b/PVE/Jobs.pm > index da648630..ac44df00 100644 > --- a/PVE/Jobs.pm > +++ b/PVE/Jobs.pm > @@ -209,6 +209,7 @@ sub get_last_runtime { > } > > sub run_jobs { > + my ($first_run) = @_; Style nit: could use a blank line > synchronize_job_states_with_config(); > > my $jobs_cfg = cfs_read_file('jobs.cfg'); > @@ -228,6 +229,10 @@ sub run_jobs { > next; > } > > + # update last_run_time on the first run when 'repeat-missed' is 0, so that a missed job will not What is last_run_time ;)? Style nit: line too long. > + # start immediately after boot > + updated_job_schedule($id, $type) if $first_run && !$cfg->{'repeat-missed'}; Can we rename the function? updated_job_schedule() sounds like something that's only called when the job schedule was updated (and the next patch introduces yet another code path calling it). > + > next if defined($cfg->{enabled}) && !$cfg->{enabled}; # only schedule actually enabled jobs > > my $last_run = get_last_runtime($id, $type); > diff --git a/PVE/Jobs/Plugin.pm b/PVE/Jobs/Plugin.pm > index 6098360b..b8cbef1e 100644 > --- a/PVE/Jobs/Plugin.pm > +++ b/PVE/Jobs/Plugin.pm > @@ -39,6 +39,13 @@ my $defaultData = { > description => "Description for the Job.", > maxLength => 512, > }, > + 'repeat-missed' => { > + optional => 1, > + type => 'boolean', > + description => "If true, the job will be run as soon as possible if it was missed while". Style nit: also one char too long. > + " the scheduler was not running.", > + default => 0, Do we plan to change the behavior for replication jobs in the future too? Otherwise, the documented default here will not apply to those. > + }, > }, > }; >