Commit Graph

34 Commits

Author SHA1 Message Date
Christoph Heiss
54c76175f0 run env: always return proper value for default zfs max arc size
In preparation for fixing #6285 [0].

`0` means to just skip writing the module parameter. But (especially)
with the upcoming change in ZFS 2.3 - which makes the size basically
that of the system memory minus 1 GiB - we want to always write some
value.

[0] https://bugzilla.proxmox.com/show_bug.cgi?id=6285

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
2025-04-04 14:55:05 +02:00
Christoph Heiss
c21d13c084 run env: provide default ZFS ARC maximum size value
This can be then used by the Rust parts directly, without having to
duplicate the calculation.

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
2025-04-04 10:34:55 +02:00
Thomas Lamprecht
f357ae3d07 run env: always reduce max ARC size for systems with low memory
Reduce the maximum ARC size to 10% of total memory instead of the
default 50% not only for PVE, but always if the system has less than 2
GiB, or less than 4 GiB for PMG, i.e. less than the recommended
minimum memory we document.

We might want to fine-tune this further in the future, e.g. so that
PMG and PDM won't use 50% of memory even if they got more memory
installed. As they both are not IO-heavy, thus a big ARC won't gain
one that much, but as memory is mainly used for the base system there,
unlike PVE where it's mainly for virtual guests, it might make sense
to use something like 25% there for a better trade-of. Anyway, that's
something that needs closer evaluation, so not relevant for now.

Adapt the tests accordingly.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2025-02-26 16:54:43 +01:00
Thomas Lamprecht
91be6a71d5 run env: always leave 1 GiB for system when clamping ZFS ARC size
To not allow the max ARC size to be the same as the total memory size.
Note that 1 GiB is often still not enough for a fully working system,
but for one, this can only happen if the user manually overrides ARC
max, and for another, it's only a general crude safety net to allow
the basic system to boot so that one can correct this if it's a
problem as for some products, like PBS or PDM, the base system's RSS
usage might be below 1 GiB, and we are not doing product-aware stuff
here.

Adapt the tests accordingly.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2025-02-26 16:54:43 +01:00
Christoph Heiss
723afe2a4e run env: always re-create run env file in test mode
When debugging or otherwise deliberately running the `dump-env`
low-level installer command in test mode, chances are that you'd want
the run env file to be re-created as well.

No impact on the normal installation flow.

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
2024-11-11 23:18:45 +01:00
Christoph Heiss
8772ebc35a proxinstall: expose arc size setting for zfs bootdisks for all products
For non-PVE products, simply use the ZFS defaults (aka. 50%) and leave
unset, if the user never touches that setting.

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
2024-11-10 19:50:48 +01:00
Christoph Heiss
a0edc9f08a common: setup: deserialize secure_boot property from runtime env
Needed for the post-hook functionality, which sends this information as
part of its information set.

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
2024-11-10 19:26:30 +01:00
Christoph Heiss
24e2908567 low level: run env: ensure secure_boot property is dumped as int
Previously, in the "false" case, it would serialize to an empty string.
In the future this property will be deserialized by (type-safe) Rust
code.

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
2024-11-10 19:26:11 +01:00
Fabian Grünbichler
5364c0c116 move secure boot state to RunEnv
as preparation for using it in more than one place.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2024-04-23 15:18:29 +02:00
Christoph Heiss
176b7be680 run env: use default error message if country detection failed with empty string
Bit of perl fun again.
$err from detect_country_tracing_to() can be empty string under certain
circumstances (according to a forum post [0]). The // operator
evaluates an empty as true, thus `warn` receives an empty string to and
just prints

  Warning: something wrong at /usr/share/perl5/proxmox/Install/RunEnv.pm line 305

Which isn't particular helpful. Use the || operator instead, that
evaluates an empty string as false and thus would fall back to the
generic error message.

A minimal reproducer/example for completeness sake:

  #!/usr/bin/env perl
  use strict;
  use warnings;

  warn ('' // "unable to detect country\n");
  warn ('' || "unable to detect country\n");

gives

  Warning: something's wrong at ./test.pl line 5.
  unable to detect country

[0] https://forum.proxmox.com/threads/blank-screen-while-installing.143928/

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
2024-04-08 18:02:26 +02:00
Thomas Lamprecht
41c686d429 run command: use explicit return undef in closures on call sites
To avoid a misinterpretation of the auto-return value:

> In the absence of an explicit return, a subroutine, eval, or do FILE
> automatically returns the value of the last expression evaluated.
-- https://perldoc.perl.org/functions/return

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-02-26 14:39:03 +01:00
Christoph Heiss
8a1a7187ae fix #4872: run env: use run_command() for country detection
This fixes a rather longstanding issue [0][1] with the country
detection, in that it might get completely stuck and thus hangs the
installation.

This is due how Perl, signals and line reading interacts.

A minimal reproducer, how the installer currently works, looks like
this:
```
    #!/usr/bin/env perl

    use strict;
    use warnings;

    open (my $fh, '-|', 'sleep', '1000') or die;

    my $prev = alarm(2);
    eval {
	local $SIG{ALRM} = sub { die "timed out!\n" };

	my $line;
	while (defined ($line = <$fh>)) {
	    print "line: $line";
	}
    };

    alarm($prev);
    close($fh);
```

One might expect that this times out after 2 seconds, as specified in
`alarm(2)`. The thruth is that `$line = <$fh>` apparently prevents the
signal to go through. This then causes the installer to hang there
indefinitely, if `traceroute` never progresses - which seems to happen
on lots of (weird) networks, as evidently can be seen in the forum [1].

Proxmox::Sys::Command::run_command() handles of these weird cases, takes
care of the nitty-gritty details and - most importantly - interacts
properly with SIGALRM, so just use that instead.

This _should_ really fix that issue, but reproducing it 1:1 as part of
the installation process is _very_ hard, basically pure luck. But
rewriting the reproducer using run_command (in the exact same way that
this patch rewrites detect_country_tracing_to()) fixes the issue there,
so it's the best we can probably do.

NB: This causes that the traceroute command is now printed to the log
(as run_command() logs that by default), which we could also hide e.g.
through another parameter if wanted.

[0] https://bugzilla.proxmox.com/show_bug.cgi?id=4872
[1] https://forum.proxmox.com/threads/proxmox-installation-trying-to-detect-country.134301/

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
2024-02-23 14:19:56 +01:00
Thomas Lamprecht
5130de4d7d get fqdn: code/naming style cleanups
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-11-17 06:34:33 +01:00
Stoiko Ivanov
a805423305 run env: do not store emtpy hostname
without this patch the hostname ends up as the empty string in
run-env-info.json, which results in a parse-error in the TUI code
(an empty string is not None, but still too short as hostname)

Minimally tested on a VM.

Fixes: bda1cdf ("run env: retrieve and store hostname from DHCP lease
 if available")
Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
2023-11-17 06:25:43 +01:00
Christoph Heiss
c8f6256dab run env: remove debug print
Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
2023-11-07 16:40:15 +01:00
Christoph Heiss
42aa2fa7ef fix #4829: install: add new ZFS arc_max setup option
Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
2023-11-06 15:49:31 +01:00
Christoph Heiss
ed2b90a412 run env: add comment for query_total_memory()
This is mainly to explicitly document the unit of its return value.

No functional changes.

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
2023-11-03 13:00:40 +01:00
Christoph Heiss
bda1cdf699 run env: retrieve and store hostname from DHCP lease if available
Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
2023-10-20 12:31:22 +02:00
Thomas Lamprecht
5c4501655a add interface state to run-time environment
making this slowly compatible with our battle-proven ifaces entry..

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-10-19 13:34:37 +02:00
Christoph Heiss
4d8aec8af4 run env: add hardware-accelerated virtualization support flag
Can later be used by the installer frontends, as well as nicely alinging
with the 'single source of truth' "policy".

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
2023-07-13 15:48:02 +02:00
Thomas Lamprecht
a467ec47b8 add some more logging, especially at start up
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-06-21 16:56:35 +02:00
Thomas Lamprecht
e1b7469635 run env: re-used cached version to speed up GUI installer start
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-06-21 16:33:16 +02:00
Thomas Lamprecht
5ea718f66d run env: make addresses optional, include all interfaces
Similar to our actual battle proven get_ip_config, but as the TUI
uses this one, and switching to it rather more risk, make just
addresses optional, add skip for "lo" loopback and don't skip ifaces
that aren't UP in the current helper.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-06-21 11:54:41 +02:00
Thomas Lamprecht
fe06d7e94f move ipconf into run-env
This adds some duplication there, but much safer than restructuring
stuff at this point in time, we can deal with unification later.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-06-20 16:00:47 +02:00
Thomas Lamprecht
ceec3def24 run env: use single source of truth for block devices
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-06-20 14:24:46 +02:00
Wolfgang Bumiller
4532cff472 run env: replace lsblk with hd_list but fix it up a bit
Instead of lsblk we use the original `hd_list` to be closer
to what we originally had.
However, from the PVE codebase I copied over the use of the
`E: DEVNAME` property to find the `/dev` node like (since
some weird devices can have '!' in /sys with '/' in /dev),
drop the check for `/sys/block/$d/dev`, and provide both the
`/dev` and `/sys/block` path in the output array.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-06-20 14:00:00 +02:00
Thomas Lamprecht
88adf31586 run env: add kernel cmdline info
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-06-20 07:54:31 +02:00
Thomas Lamprecht
ea3b7cae80 provide a global singleton for RunEnv
we should only use the exact same set of values everywhere any way
for this, a good hint that a singleton is a good fit and this is
global info.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-06-20 07:54:31 +02:00
Thomas Lamprecht
71583761ea move getting boot mode into runtime env
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-06-19 21:49:00 +02:00
Thomas Lamprecht
b91f9cadf2 run env: add & use helper to query total memory
maybe there's a better place soon as just adding it top-level into
the install runtime env.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-06-19 21:49:00 +02:00
Wolfgang Bumiller
1c5e103adf move dns into network section in runtime info
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-06-19 13:27:53 +02:00
Thomas Lamprecht
0d27321b79 run env: do not export non-existing is_test_mode method
Probably left over from using ISOEnv as base

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-06-19 12:19:37 +02:00
Wolfgang Bumiller
37545cce04 RunEnv: exclude zfs in query_blockdevs
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-06-19 12:19:37 +02:00
Wolfgang Bumiller
2231d22680 add Proxmox::Install::RunEnv module
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-06-19 12:19:37 +02:00