public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH storage 1/1] esxi: improve error handling for fuse mount tool
Date: Wed,  8 May 2024 14:41:12 +0200	[thread overview]
Message-ID: <20240508124112.2519552-3-d.csapak@proxmox.com> (raw)
In-Reply-To: <20240508124112.2519552-1-d.csapak@proxmox.com>

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
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
+	    open(STDERR, ">&", \*$wr) or die "unable to redirect STDERR: $!\n";
+
 	    # 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";
     }
 
-- 
2.39.2



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


  parent reply	other threads:[~2024-05-08 12:41 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 ` Dominik Csapak [this message]
2024-05-08 14:43   ` [pve-devel] [PATCH storage 1/1] esxi: improve error handling for fuse mount tool Thomas Lamprecht
2024-05-10 13:28     ` Dominik Csapak

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=20240508124112.2519552-3-d.csapak@proxmox.com \
    --to=d.csapak@proxmox.com \
    --cc=pve-devel@lists.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