increased the timeout for detect_arch from 5 to 10 seconds.

until now, on any error detect_architecture would fall back to amd64.
to avoid falling back due to an timeout error this function now dies
on timeout errors.

additionally minor changes to the error messages have been made.

Signed-off-by: Lorenz Stechauner <[email protected]>
---
changes to v1:
* implemented feedback
* do not remove `\n` in error message

 src/PVE/LXC/Create.pm | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/PVE/LXC/Create.pm b/src/PVE/LXC/Create.pm
index 82d7ad9..e8233b6 100644
--- a/src/PVE/LXC/Create.pm
+++ b/src/PVE/LXC/Create.pm
@@ -52,10 +52,16 @@ sub detect_architecture {
        return $arch;
     };
 
-    my $arch = eval { PVE::Tools::run_fork_with_timeout(5, $detect_arch) };
-    if (my $err = $@) {
+    my $arch = eval { PVE::Tools::run_fork_with_timeout(10, $detect_arch); };
+    my $err = $@;
+
+    if (!defined($arch) && !defined($err)) {
+       # on timeout
+       die "Architecture detection failed: timeout\n";
+    } elsif ($err) {
+       # any other error
        $arch = 'amd64';
-       print "Architecture detection failed: $err\nFalling back to amd64.\n" .
+       print "Architecture detection failed: $err\nFalling back to $arch.\n" .
              "Use `pct set VMID --arch ARCH` to change.\n";
     } else {
        print "Detected container architecture: $arch\n";
-- 
2.30.2



_______________________________________________
pve-devel mailing list
[email protected]
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to