From: Thomas Lamprecht <t.lamprecht@proxmox.com>
To: Proxmox VE development discussion <pve-devel@lists.proxmox.com>,
Oguz Bektas <o.bektas@proxmox.com>
Subject: Re: [pve-devel] [PATCH cluster] parse_datacenter_config: return early if no raw data for parsing
Date: Mon, 15 Nov 2021 15:00:35 +0100 [thread overview]
Message-ID: <851fc6f6-1717-03f6-47a1-8ddb78dedbbe@proxmox.com> (raw)
In-Reply-To: <20211115125846.1891390-1-o.bektas@proxmox.com>
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@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);
>
prev parent reply other threads:[~2021-11-15 14:00 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-15 12:58 Oguz Bektas
2021-11-15 14:00 ` Thomas Lamprecht [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=851fc6f6-1717-03f6-47a1-8ddb78dedbbe@proxmox.com \
--to=t.lamprecht@proxmox.com \
--cc=o.bektas@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.