Else we crash fatally on an existing but empty status file like
/etc/pve/manager_status , reproducible with:
$ > /etc/pve/ha/manager_status

We do not want to catch arbitrary errors as then users cannot
reconstruct what happened in the event of an error.

Signed-off-by: Thomas Lamprecht <t.lampre...@proxmox.com>
---

changes since v1:
* do not catch arbitrary errors, just empty files.
  arbitrary error should happen only in development and there its more usefull
  to not overwrite the file and crash instead, so that the culprit may be found.

 src/PVE/HA/Config.pm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/PVE/HA/Config.pm b/src/PVE/HA/Config.pm
index c9aa8a5..00b338d 100644
--- a/src/PVE/HA/Config.pm
+++ b/src/PVE/HA/Config.pm
@@ -38,7 +38,7 @@ cfs_register_file($ha_fence_config,
 sub json_reader {
     my ($filename, $data) = @_;
 
-    return defined($data) ? decode_json($data) : {};
+    return defined($data) && length($data) > 0 ? decode_json($data) : {};
 }
 
 sub json_writer {
-- 
2.1.4


_______________________________________________
pve-devel mailing list
pve-devel@pve.proxmox.com
http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to