public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: Thomas Lamprecht <t.lamprecht@proxmox.com>,
	Proxmox VE development discussion <pve-devel@lists.proxmox.com>
Subject: Re: [pve-devel] [PATCH storage 1/1] esxi: improve error handling for fuse mount tool
Date: Fri, 10 May 2024 15:28:25 +0200	[thread overview]
Message-ID: <da819292-136c-4273-b6c7-488c7a217269@proxmox.com> (raw)
In-Reply-To: <c4ae9f5c-88a4-4e4b-bca9-901ab0376289@proxmox.com>

On 5/8/24 16:43, Thomas Lamprecht wrote:
> On 08/05/2024 14:41, Dominik Csapak wrote:
>> if the fuse tool encounters an error early, it prints it like:
>>     Error: some error message
>> on stderr.
>>
>> We can capture that here by redirecting STDERR to $wr and die'ing with
> 
> using just a variable name like $wr without context in a commit message
> is hardly telling or useful, maybe replace above and the paragraph below
> with something like:
> 
> "Redirect the STDERR of the child process that mounts the ESXi instance to
> the pipe of the parent (API) process, so that it can pass a hopefully more
> meaningful message to the user than just an erroneous return code."
> 
> 

You're right, that sounds better

>> the error message.
>>
>> With this we die with the original error message instead of only
>> with the return code which is telling the user nothing and does not
>> help us debug.
>>
>> Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
>> ---
>>   src/PVE/Storage/ESXiPlugin.pm | 6 +++++-
>>   1 file changed, 5 insertions(+), 1 deletion(-)
>>
>> diff --git a/src/PVE/Storage/ESXiPlugin.pm b/src/PVE/Storage/ESXiPlugin.pm
>> index b8bce0e..8dc33fc 100644
>> --- a/src/PVE/Storage/ESXiPlugin.pm
>> +++ b/src/PVE/Storage/ESXiPlugin.pm
>> @@ -222,6 +222,10 @@ sub esxi_mount : prototype($$$;$) {
>>   		// die "failed to get file descriptor flags: $!\n";
>>   	    fcntl($wr, F_SETFD, $flags & ~FD_CLOEXEC)
>>   		// die "failed to remove CLOEXEC flag from fd: $!\n";
>> +
>> +	    # capture errors from stderr
> 
> nit: you capture all that gets printed to stderr, not just errors, and no
> hard feelings, but the comment feels a tiny bit superfluous, at least with
> the error message.

true, i'll remove the comment

> 
>> +	    open(STDERR, ">&", \*$wr) or die "unable to redirect STDERR: $!\n";
> 
> Don't the \ reference operator and the * dereference operator here cancel
> each other out?

yes, of course, i'll remove those

> 
>> +
>>   	    # FIXME: use the user/group options!
>>   	    exec {$ESXI_FUSE_TOOL}
>>   		$ESXI_FUSE_TOOL,
>> @@ -245,7 +249,7 @@ sub esxi_mount : prototype($$$;$) {
>>       undef $wr;
>>   
>>       my $result = do { local $/ = undef; <$rd> };
>> -    if ($result =~ /^ERROR: (.*)$/) {
>> +    if ($result =~ /^ERROR: (.*)$/i) {
>>   	die "$1\n";
>>       }
>>   
> 



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


      reply	other threads:[~2024-05-10 13:28 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-08 12:41 [pve-devel] [PATCH pve-esxi-import-tools/storage] improve error handling/logging Dominik Csapak
2024-05-08 12:41 ` [pve-devel] [PATCH pve-esxi-import-tools 1/1] improve error handling before mounting Dominik Csapak
2024-05-08 14:26   ` Thomas Lamprecht
2024-05-10 13:21     ` Dominik Csapak
2024-05-08 12:41 ` [pve-devel] [PATCH storage 1/1] esxi: improve error handling for fuse mount tool Dominik Csapak
2024-05-08 14:43   ` Thomas Lamprecht
2024-05-10 13:28     ` Dominik Csapak [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=da819292-136c-4273-b6c7-488c7a217269@proxmox.com \
    --to=d.csapak@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    --cc=t.lamprecht@proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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