[pve-devel] [PATCH manager] ceph: services: broadcast versions: improve requesting old version

Fabian Ebner f.ebner at proxmox.com
Tue Nov 30 11:38:12 CET 2021


to avoid a "malformed JSON string" warning when there is no old
version present (e.g. after starting a cluster).

get_node_kv will always return something that evaluates to true, so
instead, test if the result has an entry for the current node. Also,
it's enough to request the kv for the current node only.

Signed-off-by: Fabian Ebner <f.ebner at proxmox.com>
---
 PVE/Ceph/Services.pm | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/PVE/Ceph/Services.pm b/PVE/Ceph/Services.pm
index cda13c6a..e0f31e8e 100644
--- a/PVE/Ceph/Services.pm
+++ b/PVE/Ceph/Services.pm
@@ -51,8 +51,9 @@ sub broadcast_ceph_versions {
     my ($version, $buildcommit, $vers_parts) = PVE::Ceph::Tools::get_local_version(1);
 
     if ($version) {
-	if (my $old = PVE::Cluster::get_node_kv("ceph-versions")) {
-	    my $nodename = PVE::INotify::nodename();
+	my $nodename = PVE::INotify::nodename();
+	my $old = PVE::Cluster::get_node_kv("ceph-versions", $nodename);
+	if (defined($old->{$nodename})) {
 	    $old = eval { decode_json($old->{$nodename}) };
 	    warn $@ if $@; # should not happen
 	    if (defined($old) && $old->{buildcommit} eq $buildcommit && $old->{version}->{str} eq $version) {
-- 
2.30.2






More information about the pve-devel mailing list