mirror of https://github.com/jimsalterjrs/sanoid
Gracefully handle error when source dataset disappeared
If the source dataset dissappeared before we were able to get the sanoid:sync property, do not set an error exit code. Handle this gracefully as this should not be considered an error. Fixes #380
This commit is contained in:
parent
681820ceab
commit
fd71e794ad
36
syncoid
36
syncoid
|
|
@ -290,7 +290,10 @@ sub syncdataset {
|
|||
|
||||
if (!defined $sync) {
|
||||
# zfs already printed the corresponding error
|
||||
if ($exitcode < 2) { $exitcode = 2; }
|
||||
if (dataset_exists($sourcehost, $sourcefs, $sourceisroot) and $exitcode < 2) {
|
||||
$exitcode = 2;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -1147,6 +1150,37 @@ sub getzfsvalue {
|
|||
return $value;
|
||||
}
|
||||
|
||||
sub dataset_exists {
|
||||
my ($rhost, $fs, $isroot) = @_;
|
||||
|
||||
my $fsescaped = escapeshellparam($fs);
|
||||
|
||||
my $mysudocmd;
|
||||
if ($isroot) {
|
||||
$mysudocmd = '';
|
||||
}
|
||||
else {
|
||||
$mysudocmd = $sudocmd;
|
||||
}
|
||||
|
||||
my $command = "$rhost $mysudocmd $zfscmd get -H creation $fsescaped";
|
||||
|
||||
if ($debug) {
|
||||
print "$command\n";
|
||||
}
|
||||
|
||||
open my $fh, '-|', "$command 2>&1";
|
||||
my $result = <$fh>;
|
||||
close $fh;
|
||||
|
||||
if ($result =~ /dataset does not exist/) {
|
||||
warn "$fsescaped does not exist...\n";
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
sub readablebytes {
|
||||
my $bytes = shift;
|
||||
my $disp;
|
||||
|
|
|
|||
Loading…
Reference in New Issue