* [pve-devel] [PATCH cluster] parse_datacenter_config: return early if no raw data for parsing
@ 2021-11-15 12:58 Oguz Bektas
2021-11-15 14:00 ` Thomas Lamprecht
0 siblings, 1 reply; 2+ messages in thread
From: Oguz Bektas @ 2021-11-15 12:58 UTC (permalink / raw)
To: pve-devel
in case datacenter.cfg file is missing (e.g. because node is
standalone), it causes a warning message on 'split'.
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);
+
# description may be comment or key-value pair (or both)
my $comment = '';
my @lines = split(/\n/, $raw);
--
2.30.2
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [pve-devel] [PATCH cluster] parse_datacenter_config: return early if no raw data for parsing
2021-11-15 12:58 [pve-devel] [PATCH cluster] parse_datacenter_config: return early if no raw data for parsing Oguz Bektas
@ 2021-11-15 14:00 ` Thomas Lamprecht
0 siblings, 0 replies; 2+ messages in thread
From: Thomas Lamprecht @ 2021-11-15 14:00 UTC (permalink / raw)
To: Proxmox VE development discussion, Oguz Bektas
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);
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-11-15 14:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-15 12:58 [pve-devel] [PATCH cluster] parse_datacenter_config: return early if no raw data for parsing Oguz Bektas
2021-11-15 14:00 ` Thomas Lamprecht
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox