public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH storage 1/2] avoid output of zfs get command on volume import
@ 2020-10-01  8:11 Fabian Ebner
  2020-10-01  8:11 ` [pve-devel] [PATCH storage 2/2] fix #1452: also log stderr of remote command with insecure storage migration Fabian Ebner
  0 siblings, 1 reply; 3+ messages in thread
From: Fabian Ebner @ 2020-10-01  8:11 UTC (permalink / raw)
  To: pve-devel

quiet takes care of both the error and success case.
Without this, there are lines like:
myzpool/vm-4352-disk-0@__replicate_4352-7_1601538554__	name	myzpool/vm-4352-disk-0@__replicate_4352-7_1601538554__	-
in the log if the dataset exists, and this information is
already present in more readable form.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
---
 PVE/Storage/ZFSPoolPlugin.pm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/PVE/Storage/ZFSPoolPlugin.pm b/PVE/Storage/ZFSPoolPlugin.pm
index 6ac05b4..07540b3 100644
--- a/PVE/Storage/ZFSPoolPlugin.pm
+++ b/PVE/Storage/ZFSPoolPlugin.pm
@@ -731,7 +731,7 @@ sub volume_import {
     my $zfspath = "$scfg->{pool}/$dataset";
     my $suffix = defined($base_snapshot) ? "\@$base_snapshot" : '';
     my $exists = 0 == run_command(['zfs', 'get', '-H', 'name', $zfspath.$suffix],
-			     noerr => 1, errfunc => sub {});
+				  noerr => 1, quiet => 1);
     if (defined($base_snapshot)) {
 	die "base snapshot '$zfspath\@$base_snapshot' doesn't exist\n" if !$exists;
     } elsif ($exists) {
-- 
2.20.1





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

* [pve-devel] [PATCH storage 2/2] fix #1452: also log stderr of remote command with insecure storage migration
  2020-10-01  8:11 [pve-devel] [PATCH storage 1/2] avoid output of zfs get command on volume import Fabian Ebner
@ 2020-10-01  8:11 ` Fabian Ebner
  2020-10-28 13:08   ` [pve-devel] applied-series: " Fabian Grünbichler
  0 siblings, 1 reply; 3+ messages in thread
From: Fabian Ebner @ 2020-10-01  8:11 UTC (permalink / raw)
  To: pve-devel

Commit 8fe00d99449b7c80e81ab3c9826625a4fcd89aa4 already
introduced the necessary logging for the secure code path,
so presumably the bug was already fixed for most people.

Delay the potential die for the send command to be able to log
the ouput+error from the receive command. Like this we also see e.g.
'volume ... already exists' instead of just 'broken pipe'.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
---
 PVE/Storage.pm | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/PVE/Storage.pm b/PVE/Storage.pm
index 4a60615..cd7b5ff 100755
--- a/PVE/Storage.pm
+++ b/PVE/Storage.pm
@@ -8,6 +8,7 @@ use POSIX;
 use IO::Select;
 use IO::File;
 use IO::Socket::IP;
+use IPC::Open3;
 use File::Basename;
 use File::Path;
 use Cwd 'abs_path';
@@ -698,15 +699,22 @@ sub storage_migrate {
     volume_snapshot($cfg, $volid, $snapshot) if $migration_snapshot;
     eval {
 	if ($insecure) {
-	    open(my $info, '-|', @$recv)
+	    my $input = IO::File->new();
+	    my $info = IO::File->new();
+	    open3($input, $info, $info, @{$recv})
 		or die "receive command failed: $!\n";
+	    close($input);
+
 	    my ($ip) = <$info> =~ /^($PVE::Tools::IPRE)$/ or die "no tunnel IP received\n";
 	    my ($port) = <$info> =~ /^(\d+)$/ or die "no tunnel port received\n";
 	    my $socket = IO::Socket::IP->new(PeerHost => $ip, PeerPort => $port, Type => SOCK_STREAM)
 		or die "failed to connect to tunnel at $ip:$port\n";
 	    # we won't be reading from the socket
 	    shutdown($socket, 0);
-	    run_command([$send, @cstream], output => '>&'.fileno($socket), errfunc => $logfunc);
+
+	    eval { run_command([$send, @cstream], output => '>&'.fileno($socket), errfunc => $logfunc); };
+	    my $send_error = $@;
+
 	    # don't close the connection entirely otherwise the receiving end
 	    # might not get all buffered data (and fails with 'connection reset by peer')
 	    shutdown($socket, 1);
@@ -722,6 +730,8 @@ sub storage_migrate {
 		die "import failed: $!\n" if $!;
 		die "import failed: exit code ".($?>>8)."\n";
 	    }
+
+	    die $send_error if $send_error;
 	} else {
 	    run_command([$send, @cstream, $recv], logfunc => $match_volid_and_log);
 	}
-- 
2.20.1





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

* [pve-devel] applied-series: [PATCH storage 2/2] fix #1452: also log stderr of remote command with insecure storage migration
  2020-10-01  8:11 ` [pve-devel] [PATCH storage 2/2] fix #1452: also log stderr of remote command with insecure storage migration Fabian Ebner
@ 2020-10-28 13:08   ` Fabian Grünbichler
  0 siblings, 0 replies; 3+ messages in thread
From: Fabian Grünbichler @ 2020-10-28 13:08 UTC (permalink / raw)
  To: Proxmox VE development discussion

On October 1, 2020 10:11 am, Fabian Ebner wrote:
> Commit 8fe00d99449b7c80e81ab3c9826625a4fcd89aa4 already
> introduced the necessary logging for the secure code path,
> so presumably the bug was already fixed for most people.
> 
> Delay the potential die for the send command to be able to log
> the ouput+error from the receive command. Like this we also see e.g.
> 'volume ... already exists' instead of just 'broken pipe'.
> 
> Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
> ---
>  PVE/Storage.pm | 14 ++++++++++++--
>  1 file changed, 12 insertions(+), 2 deletions(-)
> 
> diff --git a/PVE/Storage.pm b/PVE/Storage.pm
> index 4a60615..cd7b5ff 100755
> --- a/PVE/Storage.pm
> +++ b/PVE/Storage.pm
> @@ -8,6 +8,7 @@ use POSIX;
>  use IO::Select;
>  use IO::File;
>  use IO::Socket::IP;
> +use IPC::Open3;
>  use File::Basename;
>  use File::Path;
>  use Cwd 'abs_path';
> @@ -698,15 +699,22 @@ sub storage_migrate {
>      volume_snapshot($cfg, $volid, $snapshot) if $migration_snapshot;
>      eval {
>  	if ($insecure) {
> -	    open(my $info, '-|', @$recv)
> +	    my $input = IO::File->new();
> +	    my $info = IO::File->new();
> +	    open3($input, $info, $info, @{$recv})
>  		or die "receive command failed: $!\n";
> +	    close($input);
> +
>  	    my ($ip) = <$info> =~ /^($PVE::Tools::IPRE)$/ or die "no tunnel IP received\n";
>  	    my ($port) = <$info> =~ /^(\d+)$/ or die "no tunnel port received\n";
>  	    my $socket = IO::Socket::IP->new(PeerHost => $ip, PeerPort => $port, Type => SOCK_STREAM)
>  		or die "failed to connect to tunnel at $ip:$port\n";
>  	    # we won't be reading from the socket
>  	    shutdown($socket, 0);
> -	    run_command([$send, @cstream], output => '>&'.fileno($socket), errfunc => $logfunc);
> +
> +	    eval { run_command([$send, @cstream], output => '>&'.fileno($socket), errfunc => $logfunc); };
> +	    my $send_error = $@;
> +
>  	    # don't close the connection entirely otherwise the receiving end
>  	    # might not get all buffered data (and fails with 'connection reset by peer')
>  	    shutdown($socket, 1);
> @@ -722,6 +730,8 @@ sub storage_migrate {
>  		die "import failed: $!\n" if $!;
>  		die "import failed: exit code ".($?>>8)."\n";
>  	    }
> +
> +	    die $send_error if $send_error;
>  	} else {
>  	    run_command([$send, @cstream, $recv], logfunc => $match_volid_and_log);
>  	}
> -- 
> 2.20.1
> 
> 
> 
> _______________________________________________
> pve-devel mailing list
> pve-devel@lists.proxmox.com
> https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
> 
> 
> 




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

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

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-01  8:11 [pve-devel] [PATCH storage 1/2] avoid output of zfs get command on volume import Fabian Ebner
2020-10-01  8:11 ` [pve-devel] [PATCH storage 2/2] fix #1452: also log stderr of remote command with insecure storage migration Fabian Ebner
2020-10-28 13:08   ` [pve-devel] applied-series: " Fabian Grünbichler

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