[pve-devel] [PATCH container] lxc: fall back to 'unmanaged' when no OS detected

Thomas Lamprecht t.lamprecht at proxmox.com
Tue May 26 11:31:35 CEST 2020


On 5/18/20 1:17 PM, Arnout Engelen wrote:
> This is useful when the uploaded CT does not contain a full OS. When the
> autodetection detects an OS, that OS is returned. When it does not
> successfully detect a supported OS, but /etc/os-release exists and has an ID
> other than 'unmanaged', then the setup fails.
> 
> Perhaps it would be even more consistent to make 'unmanaged' a plugin
> next to the various OS plugins, but I wanted to keep the change as
> simple as possible for now.
> 
> I'm afraid the whitespace gets munged by my email client, sorry about that...

yeah they do and I cannot apply this as is. Please see:

https://pve.proxmox.com/wiki/Developer_Documentation#Preparing_Patches
https://pve.proxmox.com/wiki/Developer_Documentation#Sending_Patches

> 
> Signed-off-by: Arnout Engelen <arnout at bzzt.net>
> ---
>  src/PVE/LXC/Setup.pm | 12 ++++++++++--
>  1 file changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/src/PVE/LXC/Setup.pm b/src/PVE/LXC/Setup.pm
> index c738e64..56ccd90 100644
> --- a/src/PVE/LXC/Setup.pm
> +++ b/src/PVE/LXC/Setup.pm
> @@ -39,7 +39,7 @@ my $autodetect_type = sub {
>      my ($self, $rootdir, $os_release) = @_;
> 
>      if (my $id = $os_release->{ID}) {
> -    return $id if $plugins->{$id};
> +    return $id if $plugins->{$id} or $id eq "unmanaged";

I thought a bit about this, mabye it's really better to avoid fake
ostype for now?

>      return $plugin_alias->{$id} if $plugin_alias->{$id};
>      warn "unknown ID '$id' in /etc/os-release file, trying fallback
> detection\n";
>      }
> @@ -70,8 +70,11 @@ my $autodetect_type = sub {
>      return "alpine";
>      } elsif (-f  "$rootdir/etc/gentoo-release") {
>      return "gentoo";
> +    } elsif (-f "$rootdir/etc/os-release") {
> +    die "unable to detect OS distribution\n";
> +    } else {

I'd add a warning message here, i.e. something which stands out like:
warn "\nWARNING: unable to detect OS distribution and no os-release, fallback to 'unmanaged'\n";

> +    return "unmanaged";
>      }
> -    die "unable to detect OS distribution\n";
>  };
> 
>  sub new {
> @@ -94,6 +97,11 @@ sub new {
>          if $type ne $expected_type;
>      }
> 
> +    if ($type eq 'unmanaged') {
> +    $conf->{ostype} = $type;
> +    return $self;
> +    }
> +
>      my $plugin_class = $plugins->{$type} ||
>      "no such OS type '$type'\n";
> 





More information about the pve-devel mailing list