From d0415b8179bb2d0b585d94ed7448356d88e14dbf Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Thu, 3 Apr 2025 11:59:33 +0200 Subject: [PATCH] storage tunnel: add error handling for cleaning up unix socket file Warn if removing the socket failed and it still existed when trying to do so. Signed-off-by: Thomas Lamprecht --- src/PVE/StorageTunnel.pm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/PVE/StorageTunnel.pm b/src/PVE/StorageTunnel.pm index fa7889c..b0fb9e5 100644 --- a/src/PVE/StorageTunnel.pm +++ b/src/PVE/StorageTunnel.pm @@ -258,7 +258,7 @@ sub handle_query_disk_import { } my $unix = $state->{disk_import}->{socket}; - unlink $unix; + unlink $unix or $!{ENOENT} or warn "failed to unlink disk import socket – $!\n"; delete $state->{sockets}->{$unix}; delete $state->{disk_import}; @@ -276,10 +276,11 @@ sub handle_query_disk_import { waitpid($state->{disk_import}->{pid}, 0); my $unix = $state->{disk_import}->{socket}; - unlink $unix; + unlink $unix or $!{ENOENT} or warn "failed to unlink disk import socket – $!\n"; delete $state->{sockets}->{$unix}; delete $state->{disk_import}; $state->{cleanup}->{volumes}->{$volid} = 1; + my $cfg = PVE::Storage::config(); my ($storage, $volume) = PVE::Storage::parse_volume_id($volid); my $scfg = PVE::Storage::storage_config($cfg, $storage); @@ -288,6 +289,7 @@ sub handle_query_disk_import { my $path = PVE::Storage::path($cfg, $volid); PVE::Storage::file_size_info($path, undef, 1); } + return { status => "complete", volid => $volid,