mirror of
https://git.proxmox.com/git/pve-manager
synced 2025-05-31 16:27:43 +00:00
replication: sent always mail for first three tries and move helper
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
parent
237f00be03
commit
fa4bb659a3
@ -70,23 +70,24 @@ sub run_single_job {
|
|||||||
die $@ if $@;
|
die $@ if $@;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
my sub _should_mail_at_failcount {
|
||||||
|
my ($fail_count) = @_;
|
||||||
|
|
||||||
|
return 1 if $fail_count <= 3; # always send the first few for better visibility of the issue
|
||||||
|
|
||||||
|
# failing job is re-tried every half hour, try to send one mail after 1, 2, 4, 8, etc. days
|
||||||
|
my $i = 1;
|
||||||
|
while ($i * 48 < $fail_count) {
|
||||||
|
$i = $i * 2;
|
||||||
|
}
|
||||||
|
return $i * 48 == $fail_count;
|
||||||
|
};
|
||||||
|
|
||||||
# passing $now and $verbose is useful for regression testing
|
# passing $now and $verbose is useful for regression testing
|
||||||
sub run_jobs {
|
sub run_jobs {
|
||||||
my ($now, $logfunc, $verbose, $mail) = @_;
|
my ($now, $logfunc, $verbose, $mail) = @_;
|
||||||
|
|
||||||
my $mail_at_fail_count = sub {
|
|
||||||
my ($fail_count) = @_;
|
|
||||||
|
|
||||||
return 1 if $fail_count == 1;
|
|
||||||
|
|
||||||
# failing job is re-tried every half hour, try to send one mail after 1, 2, 4, 8, etc. days
|
|
||||||
my $i = 1;
|
|
||||||
while ($i * 48 < $fail_count) {
|
|
||||||
$i = $i * 2;
|
|
||||||
}
|
|
||||||
return $i * 48 == $fail_count;
|
|
||||||
};
|
|
||||||
|
|
||||||
my $iteration = $now // time();
|
my $iteration = $now // time();
|
||||||
|
|
||||||
my $code = sub {
|
my $code = sub {
|
||||||
@ -106,7 +107,7 @@ sub run_jobs {
|
|||||||
my $jobstate = PVE::ReplicationState::extract_job_state($state, $jobcfg);
|
my $jobstate = PVE::ReplicationState::extract_job_state($state, $jobcfg);
|
||||||
eval {
|
eval {
|
||||||
PVE::Tools::sendmail('root', "Replication Job: $jobcfg->{id} failed", $err)
|
PVE::Tools::sendmail('root', "Replication Job: $jobcfg->{id} failed", $err)
|
||||||
if $mail && $mail_at_fail_count->($jobstate->{fail_count});
|
if $mail && _should_mail_at_failcount($jobstate->{fail_count});
|
||||||
};
|
};
|
||||||
warn ": $@" if $@;
|
warn ": $@" if $@;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user