Merge pull request #383 from mschout/feature/ignore-missing-filesystems
Gracefully handle error when source dataset disappeared
This commit is contained in:
commit
69d6ae21d7
34
syncoid
34
syncoid
|
@ -285,11 +285,20 @@ sub syncdataset {
|
||||||
|
|
||||||
if ($debug) { print "DEBUG: syncing source $sourcefs to target $targetfs.\n"; }
|
if ($debug) { print "DEBUG: syncing source $sourcefs to target $targetfs.\n"; }
|
||||||
|
|
||||||
my $sync = getzfsvalue($sourcehost,$sourcefs,$sourceisroot,'syncoid:sync');
|
my ($sync, $error) = getzfsvalue($sourcehost,$sourcefs,$sourceisroot,'syncoid:sync');
|
||||||
|
|
||||||
if (!defined $sync) {
|
if (!defined $sync) {
|
||||||
# zfs already printed the corresponding error
|
# zfs already printed the corresponding error
|
||||||
if ($exitcode < 2) { $exitcode = 2; }
|
if ($error =~ /\bdataset does not exist\b/) {
|
||||||
|
if (!$quiet) { print "WARN Skipping dataset (dataset no longer exists): $sourcefs...\n"; }
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
# print the error out and set exit code
|
||||||
|
print "ERROR: $error\n";
|
||||||
|
if ($exitcode < 2) { $exitcode = 2 }
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1143,17 +1152,22 @@ sub getzfsvalue {
|
||||||
my $mysudocmd;
|
my $mysudocmd;
|
||||||
if ($isroot) { $mysudocmd = ''; } else { $mysudocmd = $sudocmd; }
|
if ($isroot) { $mysudocmd = ''; } else { $mysudocmd = $sudocmd; }
|
||||||
if ($debug) { print "$rhost $mysudocmd $zfscmd get -H $property $fsescaped\n"; }
|
if ($debug) { print "$rhost $mysudocmd $zfscmd get -H $property $fsescaped\n"; }
|
||||||
open FH, "$rhost $mysudocmd $zfscmd get -H $property $fsescaped |";
|
my ($value, $error, $exit) = capture {
|
||||||
my $value = <FH>;
|
system("$rhost $mysudocmd $zfscmd get -H $property $fsescaped");
|
||||||
close FH;
|
};
|
||||||
|
|
||||||
if (!defined $value) {
|
|
||||||
return undef;
|
|
||||||
}
|
|
||||||
|
|
||||||
my @values = split(/\t/,$value);
|
my @values = split(/\t/,$value);
|
||||||
$value = $values[2];
|
$value = $values[2];
|
||||||
return $value;
|
|
||||||
|
my $wantarray = wantarray || 0;
|
||||||
|
|
||||||
|
# If we are in scalar context and there is an error, print it out.
|
||||||
|
# Otherwise we assume the caller will deal with it.
|
||||||
|
if (!$wantarray and $error) {
|
||||||
|
print "ERROR getzfsvalue $fs $property: $error\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
return $wantarray ? ($value, $error) : $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub readablebytes {
|
sub readablebytes {
|
||||||
|
|
Loading…
Reference in New Issue