[pve-devel] [PATCH cluster] parse_datacenter_config: return early if no raw data for parsing

Thomas Lamprecht t.lamprecht at proxmox.com
Mon Nov 15 15:00:35 CET 2021


On 15.11.21 13:58, Oguz Bektas wrote:
> in case datacenter.cfg file is missing (e.g. because node is
> standalone), it causes a warning message on 'split'.

datacenter.cfg has nothing to do with being a cluster, it applies to stand-alone
nodes too ;)

> 
> avoid the warnings by doing an early return to stop processing in case
> we got an empty config.
> 
> Signed-off-by: Oguz Bektas <o.bektas at proxmox.com>
> ---
>  data/PVE/DataCenterConfig.pm | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/data/PVE/DataCenterConfig.pm b/data/PVE/DataCenterConfig.pm
> index 2e802d3..8a5892d 100644
> --- a/data/PVE/DataCenterConfig.pm
> +++ b/data/PVE/DataCenterConfig.pm
> @@ -231,6 +231,8 @@ sub get_datacenter_schema { return $datacenter_schema };
>  sub parse_datacenter_config {
>      my ($filename, $raw) = @_;
>  
> +    return {} if !defined($raw);
> +

We fall back to '' in the parser, only the new split code did not respect that.
So, to avoid changing the behavior I went with not returning early:

https://git.proxmox.com/?p=pve-cluster.git;a=commitdiff;h=b5e2b244dd794e982811e37bff05c7559b800087

thanks for catching nonetheless!

>      # description may be comment or key-value pair (or both)
>      my $comment = '';
>      my @lines = split(/\n/, $raw);
> 






More information about the pve-devel mailing list