From 0a2f75ffd646dae4682d16943380efb8353a1cf1 Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Tue, 12 Mar 2024 18:34:33 +0100 Subject: [PATCH] esxi: deactivate storage if config gets updated to ensure that the next access actually uses the updated config for accessing the remote ESXi, for both manifest API and FUSE mount. Signed-off-by: Thomas Lamprecht --- src/PVE/Storage/ESXiPlugin.pm | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/PVE/Storage/ESXiPlugin.pm b/src/PVE/Storage/ESXiPlugin.pm index 72776e8..3f47577 100644 --- a/src/PVE/Storage/ESXiPlugin.pm +++ b/src/PVE/Storage/ESXiPlugin.pm @@ -314,12 +314,22 @@ sub on_add_hook { sub on_update_hook { my ($class, $storeid, $scfg, %sensitive) = @_; - return if !exists($sensitive{password}); + # FIXME: allow to actually determine this, e.g., through new $changed hash passed to the hook + my $connection_detail_changed = 1; - if (defined($sensitive{password})) { - esxi_set_credentials($sensitive{password}, $storeid); - } else { - esxi_delete_credentials($storeid); + if (exists($sensitive{password})) { + $connection_detail_changed = 1; + if (defined($sensitive{password})) { + esxi_set_credentials($sensitive{password}, $storeid); + } else { + esxi_delete_credentials($storeid); + } + } + + if ($connection_detail_changed) { + # best-effort deactivate storage so that it can get re-mounted with updated params + eval { $class->deactivate_storage($storeid, $scfg) }; + warn $@ if $@; } return;