[pve-devel] [PATCH container] lxc: fall back to 'unmanaged' on unknown ostype
Arnout Engelen
arnout at bzzt.net
Sat May 16 22:37:03 CEST 2020
Rather than failing, it would be nice to fall back to 'unmanaged' when
the ostype cannot be determined/found.
Signed-off-by: Arnout Engelen <arnout at bzzt.net>
---
src/PVE/LXC.pm | 2 +-
src/PVE/LXC/Setup.pm | 6 +++++-
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/PVE/LXC.pm b/src/PVE/LXC.pm
index f3aca7a..b32d70c 100644
--- a/src/PVE/LXC.pm
+++ b/src/PVE/LXC.pm
@@ -596,7 +596,7 @@ sub update_lxc_config {
my $custom_idmap = PVE::LXC::Config->has_lxc_entry($conf, 'lxc.idmap');
my $unprivileged = $conf->{unprivileged} || $custom_idmap;
- my $ostype = $conf->{ostype} || die "missing 'ostype' - internal error";
+ my $ostype = $conf->{ostype} || 'unmanaged';
my $cfgpath = '/usr/share/lxc/config';
my $inc = "$cfgpath/$ostype.common.conf";
diff --git a/src/PVE/LXC/Setup.pm b/src/PVE/LXC/Setup.pm
index c738e64..010c9b7 100644
--- a/src/PVE/LXC/Setup.pm
+++ b/src/PVE/LXC/Setup.pm
@@ -71,7 +71,7 @@ my $autodetect_type = sub {
} elsif (-f "$rootdir/etc/gentoo-release") {
return "gentoo";
}
- die "unable to detect OS distribution\n";
+ return "unmanaged";
};
sub new {
@@ -94,6 +94,10 @@ sub new {
if $type ne $expected_type;
}
+ if ($type eq 'unmanaged') {
+ return $self;
+ }
+
my $plugin_class = $plugins->{$type} ||
"no such OS type '$type'\n";
--
2.26.2
More information about the pve-devel
mailing list